1 /*
2  * Copyright (c) 2023 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 OHOS_HDI_DISPLAY_V1_1_IDISPLAY_COMPOSER_INTERFACE_H
17 #define OHOS_HDI_DISPLAY_V1_1_IDISPLAY_COMPOSER_INTERFACE_H
18 
19 #include "v1_0/include/idisplay_composer_interface.h"
20 #include "v1_1/display_composer_type.h"
21 
22 namespace OHOS {
23 namespace HDI {
24 namespace Display {
25 namespace Composer {
26 namespace V1_1 {
27 
28 class IDisplayComposerInterface : public V1_0::IDisplayComposerInterface {
29 public:
30     /**
31      * @brief Obtains all interfaces of IDisplayComposerInterface.
32      *
33      * @return Returns <b>IDisplayComposerInterface*</b> if the operation is successful;
34      * returns an null point otherwise.
35      * @since 4.0
36      * @version 1.1
37      */
38     static IDisplayComposerInterface* Get(bool needSMQ = true);
39 
40     /**
41      * @brief Registers the callback to be invoked when it's ready to change framerate.
42      *
43      * @param cb Indicates the callback
44      * @param data Data used by cb
45      *
46      * @return Returns <b>0</b> if the operation is successful; returns an error code defined
47      * in {@link DispErrCode} otherwise.
48      * @since 4.1
49      * @version 1.1
50      */
51     virtual int32_t RegSeamlessChangeCallback(SeamlessChangeCallback cb, void* data) = 0;
52 
53     /**
54      * @brief Obtains the display modes supported by a display device.
55      *
56      * @param devId Indicates the ID of the display device.
57      * @param modes Indicates the vector of the information about all modes supported by the display device,
58      * including all supported resolutions, refresh rates and groupId. Each mode has an ID, which will be used when
59      * the mode is set or obtained. For details, see {@link DisplayModeInfoExt}.
60      *
61      * @return Returns <b>0</b> if the operation is successful; returns an error code defined
62      * in {@link DispErrCode} otherwise.
63      * @since 4.1
64      * @version 1.1
65      */
66     virtual int32_t GetDisplaySupportedModesExt(unsigned int devId, std::vector<DisplayModeInfoExt>& modes) = 0;
67 
68     /**
69      * @brief Sets the display mode of a display device.
70      *
71      * @param devId Indicates the ID of the display device.
72      * @param modeId Indicates the ID of the display mode. The device is switched to the display mode specified by
73      * this parameter in this interface.
74      * @param cb Indicates the callback to be invoked when mode is change.
75      *
76      * @return Returns <b>0</b> if the operation is successful; returns an error code defined
77      * in {@link DispErrCode} otherwise.
78      * @since 4.1
79      * @version 1.1
80      */
81     virtual int32_t SetDisplayModeAsync(uint32_t devId, uint32_t modeId, ModeCallback cb) = 0;
82 
83     /**
84      * @brief Get the current vblank period.
85      * @param devId Indicates the ID of the display device.
86      * @param period Indicates the vblank period(ns).
87      *
88      * @return Returns <b>0</b> if the operation is successful; returns an error code defined
89      * in {@link DispErrCode} otherwise.
90      * @since 4.1
91      * @version 1.1
92      */
93     virtual int32_t GetDisplayVBlankPeriod(uint32_t devId, uint64_t &period) = 0;
94 
95     /* *
96      * @brief Set the layer per frame keys supported by a display device.
97      *
98      * @param devId Indicates the ID of the display device.
99      * @param layerId Indicates the layer ID, which uniquely identifies a layer. You can perform operations on the layer
100      * with the specified layer ID.
101      * @param key Indicates the metadata key.
102      * @param value Indicates the property to get.
103      *
104      * @return Returns <b>0</b> if the operation is successful; returns an error code defined
105      * in {@link DispErrCode} otherwise.
106      * @since 4.1
107      * @version 1.1
108      */
109     virtual int32_t SetLayerPerFrameParameter(uint32_t devId, uint32_t layerId, const std::string& key,
110         const std::vector<int8_t>& value) = 0;
111 
112     /* *
113      * @brief Obtains the layer per frame keys supported by a display device.
114      *
115      * @param keys Indicates the vector of the information about all HDR metadata keys supported by the display device.
116      *
117      * @return Returns <b>0</b> if the operation is successful; returns an error code defined
118      * in {@link DispErrCode} otherwise.
119      * @since 4.1
120      * @version 1.1
121      */
122     virtual int32_t GetSupportedLayerPerFrameParameterKey(std::vector<std::string>& keys) = 0;
123 
124     /* *
125      * @brief Set display width and height of a display device.
126      *
127      * @param devId Indicates the ID of the display device.
128      * @param width Indicates the pixel width of the display device.
129      * @param height Indicates the pixel height of the display device.
130      *
131      * @return Returns <b>0</b> if the operation is successful; returns an error code defined
132      * in {@link DispErrCode} otherwise.
133      * @since 4.1
134      * @version 1.1
135      */
136     virtual int32_t SetDisplayOverlayResolution(uint32_t devId, uint32_t width, uint32_t height) = 0;
137 
138     /**
139      * @brief Registers the callback to be invoked when a refresh event occurs.
140      *
141      * @param cb Indicates the instance used to notify the graphics service of a refresh event occurred.
142      * @param data Indicates the pointer to the private data returned to the graphics service in the
143      * <b>RefreshCallback</b> callback.
144      *
145      * @return Returns <b>0</b> if the operation is successful; returns an error code defined
146      * in {@link DispErrCode} otherwise.
147      * @since 4.1
148      * @version 1.1
149      */
150     virtual int32_t RegRefreshCallback(RefreshCallback cb, void *data) = 0;
151 
152     /* *
153      * @brief Obtains the capabilities of a display device.
154      *
155      * @param devId Indicates the ID of the display device.
156      * @param gamuts Indicates the vector of the information about all color gamuts supported by the display device.
157      *
158      * @return Returns <b>0</b> if the operation is successful; returns an error code defined
159      * in {@link DispErrCode} otherwise.
160      * @since 4.1
161      * @version 1.1
162      */
163     virtual int32_t GetDisplaySupportedColorGamuts(uint32_t devId, std::vector<ColorGamut>& gamuts) = 0;
164 
165     /* *
166      * @brief Obtains the capabilities of a display device.
167      *
168      * @param devId Indicates the ID of the display device.
169      * @param info Indicates the pointer to the capabilities supported by the hdr device.
170      *
171      * @return Returns <b>0</b> if the operation is successful; returns an error code defined
172      * in {@link DispErrCode} otherwise.
173      * @since 4.1
174      * @version 1.1
175      */
176     virtual int32_t GetHDRCapabilityInfos(uint32_t devId, HDRCapability& info) = 0;
177 };
178 } // V1_1
179 } // Composer
180 } // Display
181 } // HDI
182 } // OHOS
183 #endif // OHOS_HDI_DISPLAY_V1_1_IDISPLAY_COMPOSER_INTERFACE_H
184