• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_DEFS_H
18 #define ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_DEFS_H
19 
20 #include <stdint.h>
21 #include <sys/cdefs.h>
22 
23 #include <hardware/gralloc.h>
24 #include <hardware/hardware.h>
25 #include <cutils/native_handle.h>
26 
27 __BEGIN_DECLS
28 
29 /*****************************************************************************/
30 
31 #define HWC_HEADER_VERSION          1
32 
33 #define HWC_MODULE_API_VERSION_0_1  HARDWARE_MODULE_API_VERSION(0, 1)
34 
35 #define HWC_DEVICE_API_VERSION_0_1  HARDWARE_DEVICE_API_VERSION_2(0, 1, HWC_HEADER_VERSION)
36 #define HWC_DEVICE_API_VERSION_0_2  HARDWARE_DEVICE_API_VERSION_2(0, 2, HWC_HEADER_VERSION)
37 #define HWC_DEVICE_API_VERSION_0_3  HARDWARE_DEVICE_API_VERSION_2(0, 3, HWC_HEADER_VERSION)
38 #define HWC_DEVICE_API_VERSION_1_0  HARDWARE_DEVICE_API_VERSION_2(1, 0, HWC_HEADER_VERSION)
39 #define HWC_DEVICE_API_VERSION_1_1  HARDWARE_DEVICE_API_VERSION_2(1, 1, HWC_HEADER_VERSION)
40 #define HWC_DEVICE_API_VERSION_1_2  HARDWARE_DEVICE_API_VERSION_2(1, 2, HWC_HEADER_VERSION)
41 
42 enum {
43     /* hwc_composer_device_t::set failed in EGL */
44     HWC_EGL_ERROR = -1
45 };
46 
47 /*
48  * hwc_layer_t::hints values
49  * Hints are set by the HAL and read by SurfaceFlinger
50  */
51 enum {
52     /*
53      * HWC can set the HWC_HINT_TRIPLE_BUFFER hint to indicate to SurfaceFlinger
54      * that it should triple buffer this layer. Typically HWC does this when
55      * the layer will be unavailable for use for an extended period of time,
56      * e.g. if the display will be fetching data directly from the layer and
57      * the layer can not be modified until after the next set().
58      */
59     HWC_HINT_TRIPLE_BUFFER  = 0x00000001,
60 
61     /*
62      * HWC sets HWC_HINT_CLEAR_FB to tell SurfaceFlinger that it should clear the
63      * framebuffer with transparent pixels where this layer would be.
64      * SurfaceFlinger will only honor this flag when the layer has no blending
65      *
66      */
67     HWC_HINT_CLEAR_FB       = 0x00000002
68 };
69 
70 /*
71  * hwc_layer_t::flags values
72  * Flags are set by SurfaceFlinger and read by the HAL
73  */
74 enum {
75     /*
76      * HWC_SKIP_LAYER is set by SurfaceFlnger to indicate that the HAL
77      * shall not consider this layer for composition as it will be handled
78      * by SurfaceFlinger (just as if compositionType was set to HWC_OVERLAY).
79      */
80     HWC_SKIP_LAYER = 0x00000001,
81 };
82 
83 /*
84  * hwc_layer_t::compositionType values
85  */
86 enum {
87     /* this layer is to be drawn into the framebuffer by SurfaceFlinger */
88     HWC_FRAMEBUFFER = 0,
89 
90     /* this layer will be handled in the HWC */
91     HWC_OVERLAY = 1,
92 
93     /* this is the background layer. it's used to set the background color.
94      * there is only a single background layer */
95     HWC_BACKGROUND = 2,
96 
97     /* this layer holds the result of compositing the HWC_FRAMEBUFFER layers.
98      * Added in HWC_DEVICE_API_VERSION_1_1. */
99     HWC_FRAMEBUFFER_TARGET = 3,
100 };
101 
102 /*
103  * hwc_layer_t::blending values
104  */
105 enum {
106     /* no blending */
107     HWC_BLENDING_NONE     = 0x0100,
108 
109     /* ONE / ONE_MINUS_SRC_ALPHA */
110     HWC_BLENDING_PREMULT  = 0x0105,
111 
112     /* SRC_ALPHA / ONE_MINUS_SRC_ALPHA */
113     HWC_BLENDING_COVERAGE = 0x0405
114 };
115 
116 /*
117  * hwc_layer_t::transform values
118  */
119 enum {
120     /* flip source image horizontally */
121     HWC_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H,
122     /* flip source image vertically */
123     HWC_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V,
124     /* rotate source image 90 degrees clock-wise */
125     HWC_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90,
126     /* rotate source image 180 degrees */
127     HWC_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180,
128     /* rotate source image 270 degrees clock-wise */
129     HWC_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270,
130 };
131 
132 /* attributes queriable with query() */
133 enum {
134     /*
135      * Availability: HWC_DEVICE_API_VERSION_0_2
136      * Must return 1 if the background layer is supported, 0 otherwise.
137      */
138     HWC_BACKGROUND_LAYER_SUPPORTED      = 0,
139 
140     /*
141      * Availability: HWC_DEVICE_API_VERSION_0_3
142      * Returns the vsync period in nanoseconds.
143      *
144      * This query is not used for HWC_DEVICE_API_VERSION_1_1 and later.
145      * Instead, the per-display attribute HWC_DISPLAY_VSYNC_PERIOD is used.
146      */
147     HWC_VSYNC_PERIOD                    = 1,
148 
149     /*
150      * Availability: HWC_DEVICE_API_VERSION_1_1
151      * Returns a mask of supported display types.
152      */
153     HWC_DISPLAY_TYPES_SUPPORTED         = 2,
154 };
155 
156 /* display attributes returned by getDisplayAttributes() */
157 enum {
158     /* Indicates the end of an attribute list */
159     HWC_DISPLAY_NO_ATTRIBUTE                = 0,
160 
161     /* The vsync period in nanoseconds */
162     HWC_DISPLAY_VSYNC_PERIOD                = 1,
163 
164     /* The number of pixels in the horizontal and vertical directions. */
165     HWC_DISPLAY_WIDTH                       = 2,
166     HWC_DISPLAY_HEIGHT                      = 3,
167 
168     /* The number of pixels per thousand inches of this configuration.
169      *
170      * Scaling DPI by 1000 allows it to be stored in an int without losing
171      * too much precision.
172      *
173      * If the DPI for a configuration is unavailable or the HWC implementation
174      * considers it unreliable, it should set these attributes to zero.
175      */
176     HWC_DISPLAY_DPI_X                       = 4,
177     HWC_DISPLAY_DPI_Y                       = 5,
178 };
179 
180 /* Allowed events for hwc_methods::eventControl() */
181 enum {
182     HWC_EVENT_VSYNC     = 0
183 };
184 
185 /* Display types and associated mask bits. */
186 enum {
187     HWC_DISPLAY_PRIMARY     = 0,
188     HWC_DISPLAY_EXTERNAL    = 1,    // HDMI, DP, etc.
189     HWC_NUM_DISPLAY_TYPES
190 };
191 
192 enum {
193     HWC_DISPLAY_PRIMARY_BIT     = 1 << HWC_DISPLAY_PRIMARY,
194     HWC_DISPLAY_EXTERNAL_BIT    = 1 << HWC_DISPLAY_EXTERNAL,
195 };
196 
197 /*****************************************************************************/
198 
199 __END_DECLS
200 
201 #endif /* ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_DEFS_H */
202