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