1 /* 2 * Copyright 2018 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 #pragma once 18 19 #include <string> 20 #include <vector> 21 22 #include <android/hardware/graphics/composer/2.1/IComposer.h> 23 #include <android/hardware/graphics/composer/2.1/IComposerClient.h> 24 25 // TODO remove hwcomposer2.h dependency 26 #define HWC2_INCLUDE_STRINGIFICATION 27 #define HWC2_USE_CPP11 28 #include <hardware/hwcomposer2.h> 29 #undef HWC2_INCLUDE_STRINGIFICATION 30 #undef HWC2_USE_CPP11 31 32 namespace android { 33 namespace hardware { 34 namespace graphics { 35 namespace composer { 36 namespace V2_1 { 37 namespace hal { 38 39 using common::V1_0::ColorMode; 40 using common::V1_0::ColorTransform; 41 using common::V1_0::Dataspace; 42 using common::V1_0::Hdr; 43 using common::V1_0::PixelFormat; 44 using common::V1_0::Transform; 45 46 class ComposerHal { 47 public: 48 virtual ~ComposerHal() = default; 49 50 virtual bool hasCapability(hwc2_capability_t capability) = 0; 51 52 // dump the debug information 53 virtual std::string dumpDebugInfo() = 0; 54 55 class EventCallback { 56 public: 57 virtual ~EventCallback() = default; 58 virtual void onHotplug(Display display, IComposerCallback::Connection connected) = 0; 59 virtual void onRefresh(Display display) = 0; 60 virtual void onVsync(Display display, int64_t timestamp) = 0; 61 }; 62 63 // Register the event callback object. The event callback object is valid 64 // until it is unregistered. A hotplug event must be generated for each 65 // connected physical display, before or after this function returns. 66 virtual void registerEventCallback(EventCallback* callback) = 0; 67 68 // Unregister the event callback object. It must block if there is any 69 // callback in-flight. 70 virtual void unregisterEventCallback() = 0; 71 72 virtual uint32_t getMaxVirtualDisplayCount() = 0; 73 virtual Error createVirtualDisplay(uint32_t width, uint32_t height, PixelFormat* format, 74 Display* outDisplay) = 0; 75 virtual Error destroyVirtualDisplay(Display display) = 0; 76 virtual Error createLayer(Display display, Layer* outLayer) = 0; 77 virtual Error destroyLayer(Display display, Layer layer) = 0; 78 79 virtual Error getActiveConfig(Display display, Config* outConfig) = 0; 80 virtual Error getClientTargetSupport(Display display, uint32_t width, uint32_t height, 81 PixelFormat format, Dataspace dataspace) = 0; 82 virtual Error getColorModes(Display display, hidl_vec<ColorMode>* outModes) = 0; 83 virtual Error getDisplayAttribute(Display display, Config config, 84 IComposerClient::Attribute attribute, int32_t* outValue) = 0; 85 virtual Error getDisplayConfigs(Display display, hidl_vec<Config>* outConfigs) = 0; 86 virtual Error getDisplayName(Display display, hidl_string* outName) = 0; 87 virtual Error getDisplayType(Display display, IComposerClient::DisplayType* outType) = 0; 88 virtual Error getDozeSupport(Display display, bool* outSupport) = 0; 89 virtual Error getHdrCapabilities(Display display, hidl_vec<Hdr>* outTypes, 90 float* outMaxLuminance, float* outMaxAverageLuminance, 91 float* outMinLuminance) = 0; 92 93 virtual Error setActiveConfig(Display display, Config config) = 0; 94 virtual Error setColorMode(Display display, ColorMode mode) = 0; 95 virtual Error setPowerMode(Display display, IComposerClient::PowerMode mode) = 0; 96 virtual Error setVsyncEnabled(Display display, IComposerClient::Vsync enabled) = 0; 97 98 virtual Error setColorTransform(Display display, const float* matrix, int32_t hint) = 0; 99 virtual Error setClientTarget(Display display, buffer_handle_t target, int32_t acquireFence, 100 int32_t dataspace, const std::vector<hwc_rect_t>& damage) = 0; 101 virtual Error setOutputBuffer(Display display, buffer_handle_t buffer, 102 int32_t releaseFence) = 0; 103 virtual Error validateDisplay(Display display, std::vector<Layer>* outChangedLayers, 104 std::vector<IComposerClient::Composition>* outCompositionTypes, 105 uint32_t* outDisplayRequestMask, 106 std::vector<Layer>* outRequestedLayers, 107 std::vector<uint32_t>* outRequestMasks) = 0; 108 virtual Error acceptDisplayChanges(Display display) = 0; 109 virtual Error presentDisplay(Display display, int32_t* outPresentFence, 110 std::vector<Layer>* outLayers, 111 std::vector<int32_t>* outReleaseFences) = 0; 112 113 virtual Error setLayerCursorPosition(Display display, Layer layer, int32_t x, int32_t y) = 0; 114 virtual Error setLayerBuffer(Display display, Layer layer, buffer_handle_t buffer, 115 int32_t acquireFence) = 0; 116 virtual Error setLayerSurfaceDamage(Display display, Layer layer, 117 const std::vector<hwc_rect_t>& damage) = 0; 118 virtual Error setLayerBlendMode(Display display, Layer layer, int32_t mode) = 0; 119 virtual Error setLayerColor(Display display, Layer layer, IComposerClient::Color color) = 0; 120 virtual Error setLayerCompositionType(Display display, Layer layer, int32_t type) = 0; 121 virtual Error setLayerDataspace(Display display, Layer layer, int32_t dataspace) = 0; 122 virtual Error setLayerDisplayFrame(Display display, Layer layer, const hwc_rect_t& frame) = 0; 123 virtual Error setLayerPlaneAlpha(Display display, Layer layer, float alpha) = 0; 124 virtual Error setLayerSidebandStream(Display display, Layer layer, buffer_handle_t stream) = 0; 125 virtual Error setLayerSourceCrop(Display display, Layer layer, const hwc_frect_t& crop) = 0; 126 virtual Error setLayerTransform(Display display, Layer layer, int32_t transform) = 0; 127 virtual Error setLayerVisibleRegion(Display display, Layer layer, 128 const std::vector<hwc_rect_t>& visible) = 0; 129 virtual Error setLayerZOrder(Display display, Layer layer, uint32_t z) = 0; 130 }; 131 132 } // namespace hal 133 } // namespace V2_1 134 } // namespace composer 135 } // namespace graphics 136 } // namespace hardware 137 } // namespace android 138