• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // clang-format off
2 /*
3  * Copyright (C) 2010 The Android Open Source Project
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_DEFS_H
19 #define ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_DEFS_H
20 
21 #include <stdint.h>
22 #include <sys/cdefs.h>
23 
24 #include <hardware/gralloc.h>
25 #include <hardware/hardware.h>
26 #include <cutils/native_handle.h>
27 
28 __BEGIN_DECLS
29 
30 /* Shared by HWC1 and HWC2 */
31 
32 #define HWC_HEADER_VERSION          1
33 
34 #define HWC_MODULE_API_VERSION_0_1  HARDWARE_MODULE_API_VERSION(0, 1)
35 
36 #define HWC_DEVICE_API_VERSION_1_0  HARDWARE_DEVICE_API_VERSION_2(1, 0, HWC_HEADER_VERSION)
37 #define HWC_DEVICE_API_VERSION_1_1  HARDWARE_DEVICE_API_VERSION_2(1, 1, HWC_HEADER_VERSION)
38 #define HWC_DEVICE_API_VERSION_1_2  HARDWARE_DEVICE_API_VERSION_2(1, 2, HWC_HEADER_VERSION)
39 #define HWC_DEVICE_API_VERSION_1_3  HARDWARE_DEVICE_API_VERSION_2(1, 3, HWC_HEADER_VERSION)
40 #define HWC_DEVICE_API_VERSION_1_4  HARDWARE_DEVICE_API_VERSION_2(1, 4, HWC_HEADER_VERSION)
41 #define HWC_DEVICE_API_VERSION_1_5  HARDWARE_DEVICE_API_VERSION_2(1, 5, HWC_HEADER_VERSION)
42 
43 #define HWC_DEVICE_API_VERSION_2_0  HARDWARE_DEVICE_API_VERSION_2(2, 0, HWC_HEADER_VERSION)
44 
45 /**
46  * The id of this module
47  */
48 #define HWC_HARDWARE_MODULE_ID "hwcomposer"
49 
50 /**
51  * Name of the sensors device to open
52  */
53 #define HWC_HARDWARE_COMPOSER "composer"
54 
55 typedef struct hwc_color {
56     uint8_t r;
57     uint8_t g;
58     uint8_t b;
59     uint8_t a;
60 } hwc_color_t;
61 
62 typedef struct hwc_float_color {
63     float r;
64     float g;
65     float b;
66     float a;
67 } hwc_float_color_t;
68 
69 typedef struct hwc_frect {
70     float left;
71     float top;
72     float right;
73     float bottom;
74 } hwc_frect_t;
75 
76 typedef struct hwc_rect {
77     int left;
78     int top;
79     int right;
80     int bottom;
81 } hwc_rect_t;
82 
83 typedef struct hwc_region {
84     size_t numRects;
85     hwc_rect_t const* rects;
86 } hwc_region_t;
87 
88 /*
89  * hwc_layer_t::transform values
90  */
91 typedef enum {
92     /* flip source image horizontally */
93     HWC_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H,
94     /* flip source image vertically */
95     HWC_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V,
96     /* rotate source image 90 degrees clock-wise */
97     HWC_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90,
98     /* rotate source image 180 degrees */
99     HWC_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180,
100     /* rotate source image 270 degrees clock-wise */
101     HWC_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270,
102     /* flip source image horizontally, the rotate 90 degrees clock-wise */
103     HWC_TRANSFORM_FLIP_H_ROT_90 = HAL_TRANSFORM_FLIP_H | HAL_TRANSFORM_ROT_90,
104     /* flip source image vertically, the rotate 90 degrees clock-wise */
105     HWC_TRANSFORM_FLIP_V_ROT_90 = HAL_TRANSFORM_FLIP_V | HAL_TRANSFORM_ROT_90,
106 } hwc_transform_t;
107 
108 /* Constraints for changing vsync period */
109 typedef struct hwc_vsync_period_change_constraints {
110     /* Time in CLOCK_MONOTONIC after which the vsync period may change
111      * (i.e., the vsync period must not change before this time). */
112     int64_t desiredTimeNanos;
113     /*
114      * If true, requires that the vsync period change must happen seamlessly without
115      * a noticeable visual artifact. */
116     uint8_t seamlessRequired;
117 } hwc_vsync_period_change_constraints_t;
118 
119 /* Timing for a vsync period change. */
120 typedef struct hwc_vsync_period_change_timeline {
121     /* The time in CLOCK_MONOTONIC when the new display will start to refresh at
122      * the new vsync period. */
123     int64_t newVsyncAppliedTimeNanos;
124 
125     /* Set to true if the client is required to sent a frame to be displayed before
126      * the change can take place. */
127     uint8_t refreshRequired;
128 
129     /* The time in CLOCK_MONOTONIC when the client is expected to send the new frame.
130      * Should be ignored if refreshRequired is false. */
131     int64_t refreshTimeNanos;
132 } hwc_vsync_period_change_timeline_t;
133 
134 typedef struct hwc_client_target_property {
135     // The pixel format of client target requested by hardware composer.
136     int32_t pixelFormat;
137     // The dataspace of the client target requested by hardware composer.
138     int32_t dataspace;
139 } hwc_client_target_property_t;
140 
141 /*******************************************************************************
142  * Beyond this point are things only used by HWC1, which should be ignored when
143  * implementing a HWC2 device
144  ******************************************************************************/
145 
146 enum {
147     /* hwc_composer_device_t::set failed in EGL */
148     HWC_EGL_ERROR = -1
149 };
150 
151 /*
152  * hwc_layer_t::hints values
153  * Hints are set by the HAL and read by SurfaceFlinger
154  */
155 enum {
156     /*
157      * HWC can set the HWC_HINT_TRIPLE_BUFFER hint to indicate to SurfaceFlinger
158      * that it should triple buffer this layer. Typically HWC does this when
159      * the layer will be unavailable for use for an extended period of time,
160      * e.g. if the display will be fetching data directly from the layer and
161      * the layer can not be modified until after the next set().
162      */
163     HWC_HINT_TRIPLE_BUFFER  = 0x00000001,
164 
165     /*
166      * HWC sets HWC_HINT_CLEAR_FB to tell SurfaceFlinger that it should clear the
167      * framebuffer with transparent pixels where this layer would be.
168      * SurfaceFlinger will only honor this flag when the layer has no blending
169      *
170      */
171     HWC_HINT_CLEAR_FB       = 0x00000002
172 };
173 
174 /*
175  * hwc_layer_t::flags values
176  * Flags are set by SurfaceFlinger and read by the HAL
177  */
178 enum {
179     /*
180      * HWC_SKIP_LAYER is set by SurfaceFlinger to indicate that the HAL
181      * shall not consider this layer for composition as it will be handled
182      * by SurfaceFlinger (just as if compositionType was set to HWC_FRAMEBUFFER).
183      */
184     HWC_SKIP_LAYER = 0x00000001,
185 
186     /*
187      * HWC_IS_CURSOR_LAYER is set by surfaceflinger to indicate that this
188      * layer is being used as a cursor on this particular display, and that
189      * surfaceflinger can potentially perform asynchronous position updates for
190      * this layer. If a call to prepare() returns HWC_CURSOR_OVERLAY for the
191      * composition type of this layer, then the hwcomposer will allow async
192      * position updates to this layer via setCursorPositionAsync().
193      */
194     HWC_IS_CURSOR_LAYER = 0x00000002
195 };
196 
197 /*
198  * hwc_layer_t::compositionType values
199  */
200 enum {
201     /* this layer is to be drawn into the framebuffer by SurfaceFlinger */
202     HWC_FRAMEBUFFER = 0,
203 
204     /* this layer will be handled in the HWC */
205     HWC_OVERLAY = 1,
206 
207     /* this is the background layer. it's used to set the background color.
208      * there is only a single background layer */
209     HWC_BACKGROUND = 2,
210 
211     /* this layer holds the result of compositing the HWC_FRAMEBUFFER layers.
212      * Added in HWC_DEVICE_API_VERSION_1_1. */
213     HWC_FRAMEBUFFER_TARGET = 3,
214 
215     /* this layer's contents are taken from a sideband buffer stream.
216      * Added in HWC_DEVICE_API_VERSION_1_4. */
217     HWC_SIDEBAND = 4,
218 
219     /* this layer's composition will be handled by hwcomposer by dedicated
220        cursor overlay hardware. hwcomposer will also all async position updates
221        of this layer outside of the normal prepare()/set() loop. Added in
222        HWC_DEVICE_API_VERSION_1_4. */
223     HWC_CURSOR_OVERLAY =  5
224  };
225 /*
226  * hwc_layer_t::blending values
227  */
228 enum {
229     /* no blending */
230     HWC_BLENDING_NONE     = 0x0100,
231 
232     /* ONE / ONE_MINUS_SRC_ALPHA */
233     HWC_BLENDING_PREMULT  = 0x0105,
234 
235     /* SRC_ALPHA / ONE_MINUS_SRC_ALPHA */
236     HWC_BLENDING_COVERAGE = 0x0405
237 };
238 
239 /* attributes queriable with query() */
240 enum {
241     /*
242      * Must return 1 if the background layer is supported, 0 otherwise.
243      */
244     HWC_BACKGROUND_LAYER_SUPPORTED      = 0,
245 
246     /*
247      * Returns the vsync period in nanoseconds.
248      *
249      * This query is not used for HWC_DEVICE_API_VERSION_1_1 and later.
250      * Instead, the per-display attribute HWC_DISPLAY_VSYNC_PERIOD is used.
251      */
252     HWC_VSYNC_PERIOD                    = 1,
253 
254     /*
255      * Availability: HWC_DEVICE_API_VERSION_1_1
256      * Returns a mask of supported display types.
257      */
258     HWC_DISPLAY_TYPES_SUPPORTED         = 2,
259 };
260 
261 /* display attributes returned by getDisplayAttributes() */
262 enum {
263     /* Indicates the end of an attribute list */
264     HWC_DISPLAY_NO_ATTRIBUTE                = 0,
265 
266     /* The vsync period in nanoseconds */
267     HWC_DISPLAY_VSYNC_PERIOD                = 1,
268 
269     /* The number of pixels in the horizontal and vertical directions. */
270     HWC_DISPLAY_WIDTH                       = 2,
271     HWC_DISPLAY_HEIGHT                      = 3,
272 
273     /* The number of pixels per thousand inches of this configuration.
274      *
275      * Scaling DPI by 1000 allows it to be stored in an int without losing
276      * too much precision.
277      *
278      * If the DPI for a configuration is unavailable or the HWC implementation
279      * considers it unreliable, it should set these attributes to zero.
280      */
281     HWC_DISPLAY_DPI_X                       = 4,
282     HWC_DISPLAY_DPI_Y                       = 5,
283 
284     /* Indicates which of the vendor-defined color transforms is provided by
285      * this configuration. */
286     HWC_DISPLAY_COLOR_TRANSFORM             = 6,
287 
288     /* The configuration group this config is associated to. The groups are defined
289      * to mark certain configs as similar and changing configs within a certain group
290      * may be done seamlessly in some conditions. setActiveConfigWithConstraints. */
291     HWC_DISPLAY_CONFIG_GROUP                = 7,
292 };
293 
294 /* Allowed events for hwc_methods::eventControl() */
295 enum {
296     HWC_EVENT_VSYNC     = 0
297 };
298 
299 /* Display types and associated mask bits. */
300 enum {
301     HWC_DISPLAY_PRIMARY     = 0,
302     HWC_DISPLAY_EXTERNAL    = 1,    // HDMI, DP, etc.
303     HWC_DISPLAY_VIRTUAL     = 2,
304 
305     HWC_NUM_PHYSICAL_DISPLAY_TYPES = 2,
306     HWC_NUM_DISPLAY_TYPES          = 3,
307 };
308 
309 enum {
310     HWC_DISPLAY_PRIMARY_BIT     = 1 << HWC_DISPLAY_PRIMARY,
311     HWC_DISPLAY_EXTERNAL_BIT    = 1 << HWC_DISPLAY_EXTERNAL,
312     HWC_DISPLAY_VIRTUAL_BIT     = 1 << HWC_DISPLAY_VIRTUAL,
313 };
314 
315 /* Display power modes */
316 enum {
317     /* The display is turned off (blanked). */
318     HWC_POWER_MODE_OFF      = 0,
319     /* The display is turned on and configured in a low power state
320      * that is suitable for presenting ambient information to the user,
321      * possibly with lower fidelity than normal but greater efficiency. */
322     HWC_POWER_MODE_DOZE     = 1,
323     /* The display is turned on normally. */
324     HWC_POWER_MODE_NORMAL   = 2,
325     /* The display is configured as in HWC_POWER_MODE_DOZE but may
326      * stop applying frame buffer updates from the graphics subsystem.
327      * This power mode is effectively a hint from the doze dream to
328      * tell the hardware that it is done drawing to the display for the
329      * time being and that the display should remain on in a low power
330      * state and continue showing its current contents indefinitely
331      * until the mode changes.
332      *
333      * This mode may also be used as a signal to enable hardware-based doze
334      * functionality.  In this case, the doze dream is effectively
335      * indicating that the hardware is free to take over the display
336      * and manage it autonomously to implement low power always-on display
337      * functionality. */
338     HWC_POWER_MODE_DOZE_SUSPEND  = 3,
339 };
340 
341 /*****************************************************************************/
342 
343 __END_DECLS
344 
345 #endif /* ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_DEFS_H */
346