Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 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 | #define LOG_TAG "HwcPassthrough" |
| 18 | |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 19 | #include <type_traits> |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 20 | |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 21 | #include <log/log.h> |
| 22 | |
| 23 | #include "Hwc.h" |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 24 | #include "HwcClient.h" |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 25 | |
| 26 | namespace android { |
| 27 | namespace hardware { |
| 28 | namespace graphics { |
| 29 | namespace composer { |
| 30 | namespace V2_1 { |
| 31 | namespace implementation { |
| 32 | |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 33 | HwcHal::HwcHal(const hw_module_t* module) |
| 34 | : mDevice(nullptr), mDispatch() |
| 35 | { |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 36 | int status = hwc2_open(module, &mDevice); |
| 37 | if (status) { |
| 38 | LOG_ALWAYS_FATAL("failed to open hwcomposer2 device: %s", |
| 39 | strerror(-status)); |
| 40 | } |
| 41 | |
| 42 | initCapabilities(); |
| 43 | initDispatch(); |
| 44 | } |
| 45 | |
| 46 | HwcHal::~HwcHal() |
| 47 | { |
| 48 | hwc2_close(mDevice); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | void HwcHal::initCapabilities() |
| 52 | { |
| 53 | uint32_t count = 0; |
| 54 | mDevice->getCapabilities(mDevice, &count, nullptr); |
| 55 | |
| 56 | std::vector<Capability> caps(count); |
| 57 | mDevice->getCapabilities(mDevice, &count, reinterpret_cast< |
| 58 | std::underlying_type<Capability>::type*>(caps.data())); |
| 59 | caps.resize(count); |
| 60 | |
| 61 | mCapabilities.insert(caps.cbegin(), caps.cend()); |
| 62 | } |
| 63 | |
| 64 | template<typename T> |
| 65 | void HwcHal::initDispatch(T& func, hwc2_function_descriptor_t desc) |
| 66 | { |
| 67 | auto pfn = mDevice->getFunction(mDevice, desc); |
| 68 | if (!pfn) { |
| 69 | LOG_ALWAYS_FATAL("failed to get hwcomposer2 function %d", desc); |
| 70 | } |
| 71 | |
| 72 | func = reinterpret_cast<T>(pfn); |
| 73 | } |
| 74 | |
| 75 | void HwcHal::initDispatch() |
| 76 | { |
| 77 | initDispatch(mDispatch.acceptDisplayChanges, |
| 78 | HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES); |
| 79 | initDispatch(mDispatch.createLayer, HWC2_FUNCTION_CREATE_LAYER); |
| 80 | initDispatch(mDispatch.createVirtualDisplay, |
| 81 | HWC2_FUNCTION_CREATE_VIRTUAL_DISPLAY); |
| 82 | initDispatch(mDispatch.destroyLayer, HWC2_FUNCTION_DESTROY_LAYER); |
| 83 | initDispatch(mDispatch.destroyVirtualDisplay, |
| 84 | HWC2_FUNCTION_DESTROY_VIRTUAL_DISPLAY); |
| 85 | initDispatch(mDispatch.dump, HWC2_FUNCTION_DUMP); |
| 86 | initDispatch(mDispatch.getActiveConfig, HWC2_FUNCTION_GET_ACTIVE_CONFIG); |
| 87 | initDispatch(mDispatch.getChangedCompositionTypes, |
| 88 | HWC2_FUNCTION_GET_CHANGED_COMPOSITION_TYPES); |
| 89 | initDispatch(mDispatch.getClientTargetSupport, |
| 90 | HWC2_FUNCTION_GET_CLIENT_TARGET_SUPPORT); |
| 91 | initDispatch(mDispatch.getColorModes, HWC2_FUNCTION_GET_COLOR_MODES); |
| 92 | initDispatch(mDispatch.getDisplayAttribute, |
| 93 | HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE); |
| 94 | initDispatch(mDispatch.getDisplayConfigs, |
| 95 | HWC2_FUNCTION_GET_DISPLAY_CONFIGS); |
| 96 | initDispatch(mDispatch.getDisplayName, HWC2_FUNCTION_GET_DISPLAY_NAME); |
| 97 | initDispatch(mDispatch.getDisplayRequests, |
| 98 | HWC2_FUNCTION_GET_DISPLAY_REQUESTS); |
| 99 | initDispatch(mDispatch.getDisplayType, HWC2_FUNCTION_GET_DISPLAY_TYPE); |
| 100 | initDispatch(mDispatch.getDozeSupport, HWC2_FUNCTION_GET_DOZE_SUPPORT); |
| 101 | initDispatch(mDispatch.getHdrCapabilities, |
| 102 | HWC2_FUNCTION_GET_HDR_CAPABILITIES); |
| 103 | initDispatch(mDispatch.getMaxVirtualDisplayCount, |
| 104 | HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT); |
| 105 | initDispatch(mDispatch.getReleaseFences, |
| 106 | HWC2_FUNCTION_GET_RELEASE_FENCES); |
| 107 | initDispatch(mDispatch.presentDisplay, HWC2_FUNCTION_PRESENT_DISPLAY); |
| 108 | initDispatch(mDispatch.registerCallback, HWC2_FUNCTION_REGISTER_CALLBACK); |
| 109 | initDispatch(mDispatch.setActiveConfig, HWC2_FUNCTION_SET_ACTIVE_CONFIG); |
| 110 | initDispatch(mDispatch.setClientTarget, HWC2_FUNCTION_SET_CLIENT_TARGET); |
| 111 | initDispatch(mDispatch.setColorMode, HWC2_FUNCTION_SET_COLOR_MODE); |
| 112 | initDispatch(mDispatch.setColorTransform, |
| 113 | HWC2_FUNCTION_SET_COLOR_TRANSFORM); |
| 114 | initDispatch(mDispatch.setCursorPosition, |
| 115 | HWC2_FUNCTION_SET_CURSOR_POSITION); |
| 116 | initDispatch(mDispatch.setLayerBlendMode, |
| 117 | HWC2_FUNCTION_SET_LAYER_BLEND_MODE); |
| 118 | initDispatch(mDispatch.setLayerBuffer, HWC2_FUNCTION_SET_LAYER_BUFFER); |
| 119 | initDispatch(mDispatch.setLayerColor, HWC2_FUNCTION_SET_LAYER_COLOR); |
| 120 | initDispatch(mDispatch.setLayerCompositionType, |
| 121 | HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE); |
| 122 | initDispatch(mDispatch.setLayerDataspace, |
| 123 | HWC2_FUNCTION_SET_LAYER_DATASPACE); |
| 124 | initDispatch(mDispatch.setLayerDisplayFrame, |
| 125 | HWC2_FUNCTION_SET_LAYER_DISPLAY_FRAME); |
| 126 | initDispatch(mDispatch.setLayerPlaneAlpha, |
| 127 | HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA); |
| 128 | |
| 129 | if (hasCapability(Capability::SIDEBAND_STREAM)) { |
| 130 | initDispatch(mDispatch.setLayerSidebandStream, |
| 131 | HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM); |
| 132 | } |
| 133 | |
| 134 | initDispatch(mDispatch.setLayerSourceCrop, |
| 135 | HWC2_FUNCTION_SET_LAYER_SOURCE_CROP); |
| 136 | initDispatch(mDispatch.setLayerSurfaceDamage, |
| 137 | HWC2_FUNCTION_SET_LAYER_SURFACE_DAMAGE); |
| 138 | initDispatch(mDispatch.setLayerTransform, |
| 139 | HWC2_FUNCTION_SET_LAYER_TRANSFORM); |
| 140 | initDispatch(mDispatch.setLayerVisibleRegion, |
| 141 | HWC2_FUNCTION_SET_LAYER_VISIBLE_REGION); |
| 142 | initDispatch(mDispatch.setLayerZOrder, HWC2_FUNCTION_SET_LAYER_Z_ORDER); |
| 143 | initDispatch(mDispatch.setOutputBuffer, HWC2_FUNCTION_SET_OUTPUT_BUFFER); |
| 144 | initDispatch(mDispatch.setPowerMode, HWC2_FUNCTION_SET_POWER_MODE); |
| 145 | initDispatch(mDispatch.setVsyncEnabled, HWC2_FUNCTION_SET_VSYNC_ENABLED); |
| 146 | initDispatch(mDispatch.validateDisplay, HWC2_FUNCTION_VALIDATE_DISPLAY); |
| 147 | } |
| 148 | |
| 149 | bool HwcHal::hasCapability(Capability capability) const |
| 150 | { |
| 151 | return (mCapabilities.count(capability) > 0); |
| 152 | } |
| 153 | |
| 154 | Return<void> HwcHal::getCapabilities(getCapabilities_cb hidl_cb) |
| 155 | { |
| 156 | std::vector<Capability> caps( |
| 157 | mCapabilities.cbegin(), mCapabilities.cend()); |
| 158 | |
| 159 | hidl_vec<Capability> caps_reply; |
| 160 | caps_reply.setToExternal(caps.data(), caps.size()); |
| 161 | hidl_cb(caps_reply); |
| 162 | |
| 163 | return Void(); |
| 164 | } |
| 165 | |
| 166 | Return<void> HwcHal::dumpDebugInfo(dumpDebugInfo_cb hidl_cb) |
| 167 | { |
| 168 | uint32_t len; |
| 169 | mDispatch.dump(mDevice, &len, nullptr); |
| 170 | |
| 171 | std::vector<char> buf(len + 1); |
| 172 | mDispatch.dump(mDevice, &len, buf.data()); |
| 173 | buf.resize(len + 1); |
| 174 | buf[len] = '\0'; |
| 175 | |
| 176 | hidl_string buf_reply; |
| 177 | buf_reply.setToExternal(buf.data(), len); |
| 178 | hidl_cb(buf_reply); |
| 179 | |
| 180 | return Void(); |
| 181 | } |
| 182 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 183 | Return<void> HwcHal::createClient(createClient_cb hidl_cb) |
| 184 | { |
| 185 | Error err = Error::NONE; |
| 186 | sp<HwcClient> client; |
| 187 | |
| 188 | { |
| 189 | std::lock_guard<std::mutex> lock(mClientMutex); |
| 190 | |
| 191 | // only one client is allowed |
| 192 | if (mClient == nullptr) { |
| 193 | client = new HwcClient(*this); |
| 194 | mClient = client; |
| 195 | } else { |
| 196 | err = Error::NO_RESOURCES; |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | hidl_cb(err, client); |
| 201 | |
| 202 | return Void(); |
| 203 | } |
| 204 | |
| 205 | sp<HwcClient> HwcHal::getClient() |
| 206 | { |
| 207 | std::lock_guard<std::mutex> lock(mClientMutex); |
| 208 | return (mClient != nullptr) ? mClient.promote() : nullptr; |
| 209 | } |
| 210 | |
| 211 | void HwcHal::removeClient() |
| 212 | { |
| 213 | std::lock_guard<std::mutex> lock(mClientMutex); |
| 214 | mClient = nullptr; |
| 215 | } |
| 216 | |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 217 | void HwcHal::hotplugHook(hwc2_callback_data_t callbackData, |
| 218 | hwc2_display_t display, int32_t connected) |
| 219 | { |
| 220 | auto hal = reinterpret_cast<HwcHal*>(callbackData); |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 221 | auto client = hal->getClient(); |
| 222 | if (client != nullptr) { |
| 223 | client->onHotplug(display, |
| 224 | static_cast<IComposerCallback::Connection>(connected)); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 225 | } |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | void HwcHal::refreshHook(hwc2_callback_data_t callbackData, |
| 229 | hwc2_display_t display) |
| 230 | { |
| 231 | auto hal = reinterpret_cast<HwcHal*>(callbackData); |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 232 | auto client = hal->getClient(); |
| 233 | if (client != nullptr) { |
| 234 | client->onRefresh(display); |
| 235 | } |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | void HwcHal::vsyncHook(hwc2_callback_data_t callbackData, |
| 239 | hwc2_display_t display, int64_t timestamp) |
| 240 | { |
| 241 | auto hal = reinterpret_cast<HwcHal*>(callbackData); |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 242 | auto client = hal->getClient(); |
| 243 | if (client != nullptr) { |
| 244 | client->onVsync(display, timestamp); |
| 245 | } |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 246 | } |
| 247 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 248 | void HwcHal::enableCallback(bool enable) |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 249 | { |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 250 | if (enable) { |
| 251 | mDispatch.registerCallback(mDevice, HWC2_CALLBACK_HOTPLUG, this, |
| 252 | reinterpret_cast<hwc2_function_pointer_t>(hotplugHook)); |
| 253 | mDispatch.registerCallback(mDevice, HWC2_CALLBACK_REFRESH, this, |
| 254 | reinterpret_cast<hwc2_function_pointer_t>(refreshHook)); |
| 255 | mDispatch.registerCallback(mDevice, HWC2_CALLBACK_VSYNC, this, |
| 256 | reinterpret_cast<hwc2_function_pointer_t>(vsyncHook)); |
| 257 | } else { |
| 258 | mDispatch.registerCallback(mDevice, HWC2_CALLBACK_HOTPLUG, this, |
| 259 | nullptr); |
| 260 | mDispatch.registerCallback(mDevice, HWC2_CALLBACK_REFRESH, this, |
| 261 | nullptr); |
| 262 | mDispatch.registerCallback(mDevice, HWC2_CALLBACK_VSYNC, this, |
| 263 | nullptr); |
| 264 | } |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 265 | } |
| 266 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 267 | uint32_t HwcHal::getMaxVirtualDisplayCount() |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 268 | { |
| 269 | return mDispatch.getMaxVirtualDisplayCount(mDevice); |
| 270 | } |
| 271 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 272 | Error HwcHal::createVirtualDisplay(uint32_t width, uint32_t height, |
| 273 | PixelFormat& format, Display& display) |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 274 | { |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 275 | int32_t hwc_format = static_cast<int32_t>(format); |
| 276 | int32_t err = mDispatch.createVirtualDisplay(mDevice, width, height, |
| 277 | &hwc_format, &display); |
| 278 | format = static_cast<PixelFormat>(hwc_format); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 279 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 280 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 281 | } |
| 282 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 283 | Error HwcHal::destroyVirtualDisplay(Display display) |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 284 | { |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 285 | int32_t err = mDispatch.destroyVirtualDisplay(mDevice, display); |
| 286 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 287 | } |
| 288 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 289 | Error HwcHal::createLayer(Display display, Layer& layer) |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 290 | { |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 291 | int32_t err = mDispatch.createLayer(mDevice, display, &layer); |
| 292 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 293 | } |
| 294 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 295 | Error HwcHal::destroyLayer(Display display, Layer layer) |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 296 | { |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 297 | int32_t err = mDispatch.destroyLayer(mDevice, display, layer); |
| 298 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 299 | } |
| 300 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 301 | Error HwcHal::getActiveConfig(Display display, Config& config) |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 302 | { |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 303 | int32_t err = mDispatch.getActiveConfig(mDevice, display, &config); |
| 304 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 305 | } |
| 306 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 307 | Error HwcHal::getClientTargetSupport(Display display, |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 308 | uint32_t width, uint32_t height, |
| 309 | PixelFormat format, Dataspace dataspace) |
| 310 | { |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 311 | int32_t err = mDispatch.getClientTargetSupport(mDevice, display, |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 312 | width, height, static_cast<int32_t>(format), |
| 313 | static_cast<int32_t>(dataspace)); |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 314 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 315 | } |
| 316 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 317 | Error HwcHal::getColorModes(Display display, hidl_vec<ColorMode>& modes) |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 318 | { |
| 319 | uint32_t count = 0; |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 320 | int32_t err = mDispatch.getColorModes(mDevice, display, &count, nullptr); |
| 321 | if (err != HWC2_ERROR_NONE) { |
| 322 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 323 | } |
| 324 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 325 | modes.resize(count); |
| 326 | err = mDispatch.getColorModes(mDevice, display, &count, |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 327 | reinterpret_cast<std::underlying_type<ColorMode>::type*>( |
| 328 | modes.data())); |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 329 | if (err != HWC2_ERROR_NONE) { |
| 330 | modes = hidl_vec<ColorMode>(); |
| 331 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 332 | } |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 333 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 334 | return Error::NONE; |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 335 | } |
| 336 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 337 | Error HwcHal::getDisplayAttribute(Display display, Config config, |
| 338 | IComposerClient::Attribute attribute, int32_t& value) |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 339 | { |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 340 | int32_t err = mDispatch.getDisplayAttribute(mDevice, display, config, |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 341 | static_cast<int32_t>(attribute), &value); |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 342 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 343 | } |
| 344 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 345 | Error HwcHal::getDisplayConfigs(Display display, hidl_vec<Config>& configs) |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 346 | { |
| 347 | uint32_t count = 0; |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 348 | int32_t err = mDispatch.getDisplayConfigs(mDevice, display, |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 349 | &count, nullptr); |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 350 | if (err != HWC2_ERROR_NONE) { |
| 351 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 352 | } |
| 353 | |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 354 | configs.resize(count); |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 355 | err = mDispatch.getDisplayConfigs(mDevice, display, |
| 356 | &count, configs.data()); |
| 357 | if (err != HWC2_ERROR_NONE) { |
| 358 | configs = hidl_vec<Config>(); |
| 359 | return static_cast<Error>(err); |
| 360 | } |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 361 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 362 | return Error::NONE; |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 363 | } |
| 364 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 365 | Error HwcHal::getDisplayName(Display display, hidl_string& name) |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 366 | { |
| 367 | uint32_t count = 0; |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 368 | int32_t err = mDispatch.getDisplayName(mDevice, display, &count, nullptr); |
| 369 | if (err != HWC2_ERROR_NONE) { |
| 370 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 371 | } |
| 372 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 373 | std::vector<char> buf(count + 1); |
| 374 | err = mDispatch.getDisplayName(mDevice, display, &count, buf.data()); |
| 375 | if (err != HWC2_ERROR_NONE) { |
| 376 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 377 | } |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 378 | buf.resize(count + 1); |
| 379 | buf[count] = '\0'; |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 380 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 381 | name = buf.data(); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 382 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 383 | return Error::NONE; |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 384 | } |
| 385 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 386 | Error HwcHal::getDisplayType(Display display, IComposerClient::DisplayType& type) |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 387 | { |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 388 | int32_t hwc_type = HWC2_DISPLAY_TYPE_INVALID; |
| 389 | int32_t err = mDispatch.getDisplayType(mDevice, display, &hwc_type); |
| 390 | type = static_cast<IComposerClient::DisplayType>(hwc_type); |
| 391 | |
| 392 | return static_cast<Error>(err); |
| 393 | } |
| 394 | |
| 395 | Error HwcHal::getDozeSupport(Display display, bool& support) |
| 396 | { |
| 397 | int32_t hwc_support = 0; |
| 398 | int32_t err = mDispatch.getDozeSupport(mDevice, display, &hwc_support); |
| 399 | support = hwc_support; |
| 400 | |
| 401 | return static_cast<Error>(err); |
| 402 | } |
| 403 | |
| 404 | Error HwcHal::getHdrCapabilities(Display display, hidl_vec<Hdr>& types, |
| 405 | float& maxLuminance, float& maxAverageLuminance, float& minLuminance) |
| 406 | { |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 407 | uint32_t count = 0; |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 408 | int32_t err = mDispatch.getHdrCapabilities(mDevice, display, &count, |
| 409 | nullptr, &maxLuminance, &maxAverageLuminance, &minLuminance); |
| 410 | if (err != HWC2_ERROR_NONE) { |
| 411 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 412 | } |
| 413 | |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 414 | types.resize(count); |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 415 | err = mDispatch.getHdrCapabilities(mDevice, display, &count, |
| 416 | reinterpret_cast<std::underlying_type<Hdr>::type*>(types.data()), |
| 417 | &maxLuminance, &maxAverageLuminance, &minLuminance); |
| 418 | if (err != HWC2_ERROR_NONE) { |
| 419 | return static_cast<Error>(err); |
| 420 | } |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 421 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 422 | return Error::NONE; |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 423 | } |
| 424 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 425 | Error HwcHal::setActiveConfig(Display display, Config config) |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 426 | { |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 427 | int32_t err = mDispatch.setActiveConfig(mDevice, display, config); |
| 428 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 429 | } |
| 430 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 431 | Error HwcHal::setColorMode(Display display, ColorMode mode) |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 432 | { |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 433 | int32_t err = mDispatch.setColorMode(mDevice, display, |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 434 | static_cast<int32_t>(mode)); |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 435 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 436 | } |
| 437 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 438 | Error HwcHal::setPowerMode(Display display, IComposerClient::PowerMode mode) |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 439 | { |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 440 | int32_t err = mDispatch.setPowerMode(mDevice, display, |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 441 | static_cast<int32_t>(mode)); |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 442 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 443 | } |
| 444 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 445 | Error HwcHal::setVsyncEnabled(Display display, IComposerClient::Vsync enabled) |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 446 | { |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 447 | int32_t err = mDispatch.setVsyncEnabled(mDevice, display, |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 448 | static_cast<int32_t>(enabled)); |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 449 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 450 | } |
| 451 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 452 | Error HwcHal::setColorTransform(Display display, const float* matrix, |
| 453 | int32_t hint) |
| 454 | { |
| 455 | int32_t err = mDispatch.setColorTransform(mDevice, display, matrix, hint); |
| 456 | return static_cast<Error>(err); |
| 457 | } |
| 458 | |
| 459 | Error HwcHal::setClientTarget(Display display, buffer_handle_t target, |
| 460 | int32_t acquireFence, int32_t dataspace, |
| 461 | const std::vector<hwc_rect_t>& damage) |
| 462 | { |
| 463 | hwc_region region = { damage.size(), damage.data() }; |
| 464 | int32_t err = mDispatch.setClientTarget(mDevice, display, target, |
| 465 | acquireFence, dataspace, region); |
| 466 | return static_cast<Error>(err); |
| 467 | } |
| 468 | |
| 469 | Error HwcHal::setOutputBuffer(Display display, buffer_handle_t buffer, |
| 470 | int32_t releaseFence) |
| 471 | { |
| 472 | int32_t err = mDispatch.setOutputBuffer(mDevice, display, buffer, |
| 473 | releaseFence); |
| 474 | // unlike in setClientTarget, releaseFence is owned by us |
| 475 | if (err == HWC2_ERROR_NONE && releaseFence >= 0) { |
| 476 | close(releaseFence); |
| 477 | } |
| 478 | |
| 479 | return static_cast<Error>(err); |
| 480 | } |
| 481 | |
| 482 | Error HwcHal::validateDisplay(Display display, |
| 483 | std::vector<Layer>& changedLayers, |
| 484 | std::vector<IComposerClient::Composition>& compositionTypes, |
| 485 | uint32_t& displayRequestMask, |
| 486 | std::vector<Layer>& requestedLayers, |
| 487 | std::vector<uint32_t>& requestMasks) |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 488 | { |
| 489 | uint32_t types_count = 0; |
| 490 | uint32_t reqs_count = 0; |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 491 | int32_t err = mDispatch.validateDisplay(mDevice, display, |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 492 | &types_count, &reqs_count); |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 493 | if (err != HWC2_ERROR_NONE && err != HWC2_ERROR_HAS_CHANGES) { |
| 494 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 495 | } |
| 496 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 497 | err = mDispatch.getChangedCompositionTypes(mDevice, display, |
| 498 | &types_count, nullptr, nullptr); |
| 499 | if (err != HWC2_ERROR_NONE) { |
| 500 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 501 | } |
| 502 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 503 | changedLayers.resize(types_count); |
| 504 | compositionTypes.resize(types_count); |
| 505 | err = mDispatch.getChangedCompositionTypes(mDevice, display, |
| 506 | &types_count, changedLayers.data(), |
| 507 | reinterpret_cast< |
| 508 | std::underlying_type<IComposerClient::Composition>::type*>( |
| 509 | compositionTypes.data())); |
| 510 | if (err != HWC2_ERROR_NONE) { |
| 511 | changedLayers.clear(); |
| 512 | compositionTypes.clear(); |
| 513 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 514 | } |
| 515 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 516 | int32_t display_reqs = 0; |
| 517 | err = mDispatch.getDisplayRequests(mDevice, display, &display_reqs, |
| 518 | &reqs_count, nullptr, nullptr); |
| 519 | if (err != HWC2_ERROR_NONE) { |
| 520 | changedLayers.clear(); |
| 521 | compositionTypes.clear(); |
| 522 | return static_cast<Error>(err); |
| 523 | } |
| 524 | |
| 525 | requestedLayers.resize(reqs_count); |
| 526 | requestMasks.resize(reqs_count); |
| 527 | err = mDispatch.getDisplayRequests(mDevice, display, &display_reqs, |
| 528 | &reqs_count, requestedLayers.data(), |
| 529 | reinterpret_cast<int32_t*>(requestMasks.data())); |
| 530 | if (err != HWC2_ERROR_NONE) { |
| 531 | changedLayers.clear(); |
| 532 | compositionTypes.clear(); |
| 533 | |
| 534 | requestedLayers.clear(); |
| 535 | requestMasks.clear(); |
| 536 | return static_cast<Error>(err); |
| 537 | } |
| 538 | |
| 539 | displayRequestMask = display_reqs; |
| 540 | |
| 541 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 542 | } |
| 543 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 544 | Error HwcHal::acceptDisplayChanges(Display display) |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 545 | { |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 546 | int32_t err = mDispatch.acceptDisplayChanges(mDevice, display); |
| 547 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 548 | } |
| 549 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 550 | Error HwcHal::presentDisplay(Display display, int32_t& presentFence, |
| 551 | std::vector<Layer>& layers, std::vector<int32_t>& releaseFences) |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 552 | { |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 553 | presentFence = -1; |
| 554 | int32_t err = mDispatch.presentDisplay(mDevice, display, &presentFence); |
| 555 | if (err != HWC2_ERROR_NONE) { |
| 556 | return static_cast<Error>(err); |
| 557 | } |
| 558 | |
| 559 | uint32_t count = 0; |
| 560 | err = mDispatch.getReleaseFences(mDevice, display, &count, |
| 561 | nullptr, nullptr); |
| 562 | if (err != HWC2_ERROR_NONE) { |
| 563 | ALOGW("failed to get release fences"); |
| 564 | return Error::NONE; |
| 565 | } |
| 566 | |
| 567 | layers.resize(count); |
| 568 | releaseFences.resize(count); |
| 569 | err = mDispatch.getReleaseFences(mDevice, display, &count, |
| 570 | layers.data(), releaseFences.data()); |
| 571 | if (err != HWC2_ERROR_NONE) { |
| 572 | ALOGW("failed to get release fences"); |
| 573 | layers.clear(); |
| 574 | releaseFences.clear(); |
| 575 | return Error::NONE; |
| 576 | } |
| 577 | |
| 578 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 579 | } |
| 580 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 581 | Error HwcHal::setLayerCursorPosition(Display display, Layer layer, |
| 582 | int32_t x, int32_t y) |
| 583 | { |
| 584 | int32_t err = mDispatch.setCursorPosition(mDevice, display, layer, x, y); |
| 585 | return static_cast<Error>(err); |
| 586 | } |
| 587 | |
| 588 | Error HwcHal::setLayerBuffer(Display display, Layer layer, |
| 589 | buffer_handle_t buffer, int32_t acquireFence) |
| 590 | { |
| 591 | int32_t err = mDispatch.setLayerBuffer(mDevice, display, layer, |
| 592 | buffer, acquireFence); |
| 593 | return static_cast<Error>(err); |
| 594 | } |
| 595 | |
| 596 | Error HwcHal::setLayerSurfaceDamage(Display display, Layer layer, |
| 597 | const std::vector<hwc_rect_t>& damage) |
| 598 | { |
| 599 | hwc_region region = { damage.size(), damage.data() }; |
| 600 | int32_t err = mDispatch.setLayerSurfaceDamage(mDevice, display, layer, |
| 601 | region); |
| 602 | return static_cast<Error>(err); |
| 603 | } |
| 604 | |
| 605 | Error HwcHal::setLayerBlendMode(Display display, Layer layer, int32_t mode) |
| 606 | { |
| 607 | int32_t err = mDispatch.setLayerBlendMode(mDevice, display, layer, mode); |
| 608 | return static_cast<Error>(err); |
| 609 | } |
| 610 | |
| 611 | Error HwcHal::setLayerColor(Display display, Layer layer, |
| 612 | IComposerClient::Color color) |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 613 | { |
| 614 | hwc_color_t hwc_color{color.r, color.g, color.b, color.a}; |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 615 | int32_t err = mDispatch.setLayerColor(mDevice, display, layer, hwc_color); |
| 616 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 617 | } |
| 618 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 619 | Error HwcHal::setLayerCompositionType(Display display, Layer layer, |
| 620 | int32_t type) |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 621 | { |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 622 | int32_t err = mDispatch.setLayerCompositionType(mDevice, display, layer, |
| 623 | type); |
| 624 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 625 | } |
| 626 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 627 | Error HwcHal::setLayerDataspace(Display display, Layer layer, |
| 628 | int32_t dataspace) |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 629 | { |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 630 | int32_t err = mDispatch.setLayerDataspace(mDevice, display, layer, |
| 631 | dataspace); |
| 632 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 633 | } |
| 634 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 635 | Error HwcHal::setLayerDisplayFrame(Display display, Layer layer, |
| 636 | const hwc_rect_t& frame) |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 637 | { |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 638 | int32_t err = mDispatch.setLayerDisplayFrame(mDevice, display, layer, |
| 639 | frame); |
| 640 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 641 | } |
| 642 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 643 | Error HwcHal::setLayerPlaneAlpha(Display display, Layer layer, float alpha) |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 644 | { |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 645 | int32_t err = mDispatch.setLayerPlaneAlpha(mDevice, display, layer, |
| 646 | alpha); |
| 647 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 648 | } |
| 649 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 650 | Error HwcHal::setLayerSidebandStream(Display display, Layer layer, |
| 651 | buffer_handle_t stream) |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 652 | { |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 653 | int32_t err = mDispatch.setLayerSidebandStream(mDevice, display, layer, |
| 654 | stream); |
| 655 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 656 | } |
| 657 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 658 | Error HwcHal::setLayerSourceCrop(Display display, Layer layer, |
| 659 | const hwc_frect_t& crop) |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 660 | { |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 661 | int32_t err = mDispatch.setLayerSourceCrop(mDevice, display, layer, crop); |
| 662 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 663 | } |
| 664 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 665 | Error HwcHal::setLayerTransform(Display display, Layer layer, |
| 666 | int32_t transform) |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 667 | { |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 668 | int32_t err = mDispatch.setLayerTransform(mDevice, display, layer, |
| 669 | transform); |
| 670 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 671 | } |
| 672 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 673 | Error HwcHal::setLayerVisibleRegion(Display display, Layer layer, |
| 674 | const std::vector<hwc_rect_t>& visible) |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 675 | { |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 676 | hwc_region_t region = { visible.size(), visible.data() }; |
| 677 | int32_t err = mDispatch.setLayerVisibleRegion(mDevice, display, layer, |
| 678 | region); |
| 679 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 680 | } |
| 681 | |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 682 | Error HwcHal::setLayerZOrder(Display display, Layer layer, uint32_t z) |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 683 | { |
Chia-I Wu | bb61a72 | 2016-10-24 15:40:20 +0800 | [diff] [blame] | 684 | int32_t err = mDispatch.setLayerZOrder(mDevice, display, layer, z); |
| 685 | return static_cast<Error>(err); |
Chia-I Wu | 7f8d396 | 2016-09-28 21:04:23 +0800 | [diff] [blame] | 686 | } |
| 687 | |
| 688 | IComposer* HIDL_FETCH_IComposer(const char*) |
| 689 | { |
| 690 | const hw_module_t* module; |
| 691 | int err = hw_get_module(HWC_HARDWARE_MODULE_ID, &module); |
| 692 | if (err) { |
| 693 | ALOGE("failed to get hwcomposer module"); |
| 694 | return nullptr; |
| 695 | } |
| 696 | |
| 697 | return new HwcHal(module); |
| 698 | } |
| 699 | |
| 700 | } // namespace implementation |
| 701 | } // namespace V2_1 |
| 702 | } // namespace composer |
| 703 | } // namespace graphics |
| 704 | } // namespace hardware |
| 705 | } // namespace android |