• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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_IMPL_H
17 #define HDI_BACKEND_HDI_DEVICE_IMPL_H
18 
19 #include "hdi_device.h"
20 #include "v1_2/include/idisplay_composer_interface.h"
21 #include "v1_3/include/idisplay_composer_interface.h"
22 
23 namespace OHOS {
24 namespace Rosen {
25 class HdiDeviceImpl : public HdiDevice {
26 public:
27     HdiDeviceImpl();
28     virtual ~HdiDeviceImpl();
29     bool Init();
30     /* set & get device screen info begin */
31     int32_t RegHotPlugCallback(HotPlugCallback callback, void *data) override;
32     int32_t RegRefreshCallback(RefreshCallback callback, void *data) override;
33     int32_t RegScreenVBlankCallback(uint32_t screenId, VBlankCallback callback, void *data) override;
34     bool RegHwcDeadCallback(OnHwcDeadCallback callback, void *data) override;
35     int32_t RegScreenVBlankIdleCallback(OnVBlankIdleCallback callback, void *data) override;
36     int32_t SetScreenConstraint(uint32_t screenId, uint64_t frameId, uint64_t timestamp, uint32_t type) override;
37     int32_t GetDisplayProperty(uint32_t screenId, uint32_t propertyId, uint64_t& propertyValue) override;
38     int32_t GetScreenCapability(uint32_t screenId, GraphicDisplayCapability &info) override;
39     int32_t GetScreenSupportedModes(uint32_t screenId, std::vector<GraphicDisplayModeInfo> &modes) override;
40     int32_t GetScreenMode(uint32_t screenId, uint32_t &modeId) override;
41     int32_t SetScreenMode(uint32_t screenId, uint32_t modeId) override;
42     int32_t SetScreenActiveRect(uint32_t screenId, const GraphicIRect& activeRect) override;
43     int32_t SetScreenOverlayResolution(uint32_t screenId, uint32_t width, uint32_t height) override;
44     int32_t GetScreenPowerStatus(uint32_t screenId, GraphicDispPowerStatus &status) override;
45     int32_t SetScreenPowerStatus(uint32_t screenId, GraphicDispPowerStatus status) override;
46     int32_t GetScreenBacklight(uint32_t screenId, uint32_t &level) override;
47     int32_t SetScreenBacklight(uint32_t screenId, uint32_t level) override;
48     int32_t PrepareScreenLayers(uint32_t screenId, bool &needFlushFb) override;
49     int32_t GetScreenCompChange(uint32_t screenId, std::vector<uint32_t> &layersId,
50                                 std::vector<int32_t> &types) override;
51     int32_t SetScreenClientBuffer(uint32_t screenId, const BufferHandle *buffer, uint32_t cacheIndex,
52                                   const sptr<SyncFence> &fence) override;
53     int32_t SetScreenClientBufferCacheCount(uint32_t screen, uint32_t count) override;
54     int32_t SetScreenClientDamage(uint32_t screenId, const std::vector<GraphicIRect> &damageRect) override;
55     int32_t SetScreenVsyncEnabled(uint32_t screenId, bool enabled) override;
56     int32_t GetScreenSupportedColorGamuts(uint32_t screenId, std::vector<GraphicColorGamut> &gamuts) override;
57     int32_t SetScreenColorGamut(uint32_t screenId, GraphicColorGamut gamut) override;
58     int32_t GetScreenColorGamut(uint32_t screenId, GraphicColorGamut &gamut) override;
59     int32_t SetScreenGamutMap(uint32_t screenId, GraphicGamutMap gamutMap) override;
60     int32_t GetScreenGamutMap(uint32_t screenId, GraphicGamutMap &gamutMap) override;
61     int32_t SetScreenColorTransform(uint32_t screenId, const std::vector<float>& matrix) override;
62     int32_t GetHDRCapabilityInfos(uint32_t screenId, GraphicHDRCapability &info) override;
63     int32_t GetSupportedMetaDataKey(uint32_t screenId, std::vector<GraphicHDRMetadataKey> &keys) override;
64     int32_t Commit(uint32_t screenId, sptr<SyncFence> &fence) override;
65     int32_t CommitAndGetReleaseFence(uint32_t screenId, sptr<SyncFence> &fence, int32_t &skipState, bool &needFlush,
66         std::vector<uint32_t>& layers, std::vector<sptr<SyncFence>>& fences, bool isValidated) override;
67     int32_t GetDisplayIdentificationData(uint32_t screenId, uint8_t& outPort, std::vector<uint8_t>& edidData) override;
68     /* set & get device screen info end */
69 
70     /* set & get device layer info begin */
71     int32_t SetLayerAlpha(uint32_t screenId, uint32_t layerId, const GraphicLayerAlpha &alpha) override;
72     int32_t SetLayerSize(uint32_t screenId, uint32_t layerId, const GraphicIRect &layerRect) override;
73     int32_t SetTransformMode(uint32_t screenId, uint32_t layerId, GraphicTransformType type) override;
74     int32_t SetLayerVisibleRegion(uint32_t screenId, uint32_t layerId,
75                                   const std::vector<GraphicIRect> &visibles) override;
76     int32_t SetLayerDirtyRegion(uint32_t screenId, uint32_t layerId,
77                                 const std::vector<GraphicIRect> &dirtyRegions) override;
78     int32_t SetLayerBuffer(uint32_t screenId, uint32_t layerId, const GraphicLayerBuffer &layerBuffer) override;
79     int32_t SetLayerCompositionType(uint32_t screenId, uint32_t layerId, GraphicCompositionType type) override;
80     int32_t SetLayerBlendType(uint32_t screenId, uint32_t layerId, GraphicBlendType type) override;
81     int32_t SetLayerCrop(uint32_t screenId, uint32_t layerId, const GraphicIRect &crop) override;
82     int32_t SetLayerZorder(uint32_t screenId, uint32_t layerId, uint32_t zorder) override;
83     int32_t SetLayerPreMulti(uint32_t screenId, uint32_t layerId, bool isPreMulti) override;
84     int32_t SetLayerColor(uint32_t screenId, uint32_t layerId, GraphicLayerColor layerColor) override;
85     int32_t SetLayerColorTransform(uint32_t screenId, uint32_t layerId, const std::vector<float> &matrix) override;
86     int32_t SetLayerColorDataSpace(uint32_t screenId, uint32_t layerId, GraphicColorDataSpace colorSpace) override;
87     int32_t GetLayerColorDataSpace(uint32_t screenId, uint32_t layerId, GraphicColorDataSpace &colorSpace) override;
88     int32_t SetLayerMetaData(uint32_t screenId, uint32_t layerId,
89                              const std::vector<GraphicHDRMetaData> &metaData) override;
90     int32_t SetLayerMetaDataSet(uint32_t screenId, uint32_t layerId, GraphicHDRMetadataKey key,
91                                 const std::vector<uint8_t> &metaData) override;
92     std::vector<std::string>& GetSupportedLayerPerFrameParameterKey() override;
93     int32_t SetLayerPerFrameParameter(uint32_t devId, uint32_t layerId, const std::string& key,
94                                       const std::vector<int8_t>& value) override;
95     int32_t SetLayerPerFrameParameterSmq(uint32_t devId, uint32_t layerId, const std::string& key,
96                                          const std::vector<int8_t>& value) override;
97     int32_t SetDisplayPerFrameParameterSmq(uint32_t devId, const std::string& key,
98                                            const std::vector<int8_t>& value) override;
99     int32_t SetLayerTunnelHandle(uint32_t screenId, uint32_t layerId, GraphicExtDataHandle *handle) override;
100     int32_t GetSupportedPresentTimestampType(uint32_t screenId, uint32_t layerId,
101                                              GraphicPresentTimestampType &type) override;
102     int32_t SetTunnelLayerId(uint32_t devId, uint32_t layerId, uint64_t tunnleId) override;
103     int32_t SetTunnelLayerProperty(uint32_t devId, uint32_t layerId, uint32_t property) override;
104     int32_t GetPresentTimestamp(uint32_t screenId, uint32_t layerId, GraphicPresentTimestamp &timestamp) override;
105     int32_t SetLayerMaskInfo(uint32_t screenId, uint32_t layerId, uint32_t maskInfo) override;
106     /* set & get device layer info end */
107 
108     int32_t CreateLayer(uint32_t screenId, const GraphicLayerInfo &layerInfo, uint32_t cacheCount,
109                         uint32_t &layerId) override;
110     int32_t CloseLayer(uint32_t screenId, uint32_t layerId) override;
111     int32_t ClearLayerBuffer(uint32_t screenId, uint32_t layerId) override;
112     int32_t ClearClientBuffer(uint32_t screenId) override;
113     void Destroy() override;
114     int32_t RegHwcEventCallback(const RSHwcEventCallback& callback, void *data) override;
115 
116 private:
117     HdiDeviceImpl(const HdiDeviceImpl& rhs) = delete;
118     HdiDeviceImpl& operator=(const HdiDeviceImpl& rhs) = delete;
119     HdiDeviceImpl(HdiDeviceImpl&& rhs) = delete;
120     HdiDeviceImpl& operator=(HdiDeviceImpl&& rhs) = delete;
121 
122     std::once_flag layerPerFrameParameterKeyCreateFlag_;
123     std::vector<std::string> layerPerFrameParameterKeys_{};
124 };
125 
126 } // namespace Rosen
127 } // namespace OHOS
128 #endif // HDI_BACKEND_HDI_DEVICE_IMPL_H