1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef HDI_BACKEND_HDI_DEVICE_H 17 #define HDI_BACKEND_HDI_DEVICE_H 18 19 #include <vector> 20 #include <refbase.h> 21 #include <unordered_map> 22 #include <sync_fence.h> 23 #include "hdi_display_type.h" 24 25 namespace OHOS { 26 namespace Rosen { 27 class HdiDevice { 28 public: 29 static HdiDevice* GetInstance(); 30 HdiDevice() = default; 31 virtual ~HdiDevice() = default; 32 /* set & get device screen info begin */ 33 virtual int32_t RegHotPlugCallback(HotPlugCallback callback, void *data) = 0; 34 virtual int32_t RegScreenVBlankCallback(uint32_t screenId, VBlankCallback callback, void *data) = 0; 35 virtual bool RegHwcDeadCallback(OnHwcDeadCallback callback, void *data) = 0; 36 virtual int32_t GetScreenCapability(uint32_t screenId, GraphicDisplayCapability &info) = 0; 37 virtual int32_t GetScreenSupportedModes(uint32_t screenId, std::vector<GraphicDisplayModeInfo> &modes) = 0; 38 virtual int32_t GetScreenMode(uint32_t screenId, uint32_t &modeId) = 0; 39 virtual int32_t SetScreenMode(uint32_t screenId, uint32_t modeId) = 0; 40 virtual int32_t GetScreenPowerStatus(uint32_t screenId, GraphicDispPowerStatus &status) = 0; 41 virtual int32_t SetScreenPowerStatus(uint32_t screenId, GraphicDispPowerStatus status) = 0; 42 virtual int32_t GetScreenBacklight(uint32_t screenId, uint32_t &level) = 0; 43 virtual int32_t SetScreenBacklight(uint32_t screenId, uint32_t level) = 0; 44 virtual int32_t PrepareScreenLayers(uint32_t screenId, bool &needFlushFb) = 0; 45 virtual int32_t GetScreenCompChange(uint32_t screenId, std::vector<uint32_t> &layersId, 46 std::vector<int32_t> &types) = 0; 47 virtual int32_t SetScreenClientBuffer(uint32_t screenId, const BufferHandle *buffer, uint32_t cacheIndex, 48 const sptr<SyncFence> &fence) = 0; 49 virtual int32_t SetScreenClientBufferCacheCount(uint32_t screen, uint32_t count) = 0; 50 virtual int32_t SetScreenClientDamage(uint32_t screenId, const std::vector<GraphicIRect> &damageRect) = 0; 51 virtual int32_t SetScreenVsyncEnabled(uint32_t screenId, bool enabled) = 0; 52 virtual int32_t GetScreenReleaseFence(uint32_t screenId, std::vector<uint32_t> &layersId, 53 std::vector<sptr<SyncFence>> &fences) = 0; 54 virtual int32_t GetScreenSupportedColorGamuts(uint32_t screenId, std::vector<GraphicColorGamut> &gamuts) = 0; 55 virtual int32_t SetScreenColorGamut(uint32_t screenId, GraphicColorGamut gamut) = 0; 56 virtual int32_t GetScreenColorGamut(uint32_t screenId, GraphicColorGamut &gamut) = 0; 57 virtual int32_t SetScreenGamutMap(uint32_t screenId, GraphicGamutMap gamutMap) = 0; 58 virtual int32_t GetScreenGamutMap(uint32_t screenId, GraphicGamutMap &gamutMap) = 0; 59 virtual int32_t SetScreenColorTransform(uint32_t screenId, const std::vector<float> &matrix) = 0; 60 virtual int32_t GetHDRCapabilityInfos(uint32_t screenId, GraphicHDRCapability &info) = 0; 61 virtual int32_t GetSupportedMetaDataKey(uint32_t screenId, std::vector<GraphicHDRMetadataKey> &keys) = 0; 62 virtual int32_t Commit(uint32_t screenId, sptr<SyncFence> &fence) = 0; 63 /* set & get device screen info end */ 64 65 /* set & get device layer info begin */ 66 virtual int32_t SetLayerAlpha(uint32_t screenId, uint32_t layerId, const GraphicLayerAlpha &alpha) = 0; 67 virtual int32_t SetLayerSize(uint32_t screenId, uint32_t layerId, const GraphicIRect &layerRect) = 0; 68 virtual int32_t SetTransformMode(uint32_t screenId, uint32_t layerId, GraphicTransformType type) = 0; 69 virtual int32_t SetLayerVisibleRegion(uint32_t screenId, uint32_t layerId, 70 const std::vector<GraphicIRect> &visibles) = 0; 71 virtual int32_t SetLayerDirtyRegion(uint32_t screenId, uint32_t layerId, 72 const std::vector<GraphicIRect> &dirtyRegions) = 0; 73 virtual int32_t SetLayerBuffer(uint32_t screenId, uint32_t layerId, const GraphicLayerBuffer &layerBuffer) = 0; 74 virtual int32_t SetLayerCompositionType(uint32_t screenId, uint32_t layerId, GraphicCompositionType type) = 0; 75 virtual int32_t SetLayerBlendType(uint32_t screenId, uint32_t layerId, GraphicBlendType type) = 0; 76 virtual int32_t SetLayerCrop(uint32_t screenId, uint32_t layerId, const GraphicIRect &crop) = 0; 77 virtual int32_t SetLayerZorder(uint32_t screenId, uint32_t layerId, uint32_t zorder) = 0; 78 virtual int32_t SetLayerPreMulti(uint32_t screenId, uint32_t layerId, bool isPreMulti) = 0; 79 virtual int32_t SetLayerColor(uint32_t screenId, uint32_t layerId, GraphicLayerColor layerColor) = 0; 80 virtual int32_t SetLayerColorTransform(uint32_t screenId, uint32_t layerId, const std::vector<float> &matrix) = 0; 81 virtual int32_t SetLayerColorDataSpace(uint32_t screenId, uint32_t layerId, GraphicColorDataSpace colorSpace) = 0; 82 virtual int32_t GetLayerColorDataSpace(uint32_t screenId, uint32_t layerId, GraphicColorDataSpace &colorSpace) = 0; 83 virtual int32_t SetLayerMetaData(uint32_t screenId, uint32_t layerId, 84 const std::vector<GraphicHDRMetaData> &graphicMetaData) = 0; 85 virtual int32_t SetLayerMetaDataSet(uint32_t screenId, uint32_t layerId, GraphicHDRMetadataKey gkey, 86 const std::vector<uint8_t> &metaData) = 0; 87 virtual int32_t SetLayerTunnelHandle(uint32_t screenId, uint32_t layerId, GraphicExtDataHandle *handle) = 0; 88 virtual int32_t GetSupportedPresentTimestampType(uint32_t screenId, uint32_t layerId, 89 GraphicPresentTimestampType &type) = 0; 90 virtual int32_t GetPresentTimestamp(uint32_t screenId, uint32_t layerId, GraphicPresentTimestamp ×tamp) = 0; 91 virtual int32_t SetLayerMaskInfo(uint32_t screenId, uint32_t layerId, uint32_t maskInfo) = 0; 92 /* set & get device layer info end */ 93 94 virtual int32_t CreateLayer(uint32_t screenId, const GraphicLayerInfo &layerInfo, uint32_t cacheCount, 95 uint32_t &layerId) = 0; 96 virtual int32_t CloseLayer(uint32_t screenId, uint32_t layerId) = 0; 97 virtual void Destroy() = 0; 98 99 private: 100 HdiDevice(const HdiDevice& rhs) = delete; 101 HdiDevice& operator=(const HdiDevice& rhs) = delete; 102 HdiDevice(HdiDevice&& rhs) = delete; 103 HdiDevice& operator=(HdiDevice&& rhs) = delete; 104 }; 105 } // namespace Rosen 106 } // namespace OHOS 107 #endif // HDI_BACKEND_HDI_DEVICE_H