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
16package ohos.hdi.display.composer.v1_0;
17
18import ohos.hdi.display.composer.v1_0.DisplayComposerType;
19import ohos.hdi.display.composer.v1_0.IHotPlugCallback;
20import ohos.hdi.display.composer.v1_0.IVBlankCallback;
21import ohos.hdi.display.composer.v1_0.IRefreshCallback;
22
23sequenceable OHOS.HDI.Display.HdifdParcelable;
24
25interface IDisplayComposer {
26    /* *
27     * @brief Registers the callback to be invoked when a hot plug event occurs.
28     *
29     * @param cb Indicates the instance used to notify the graphics service of a hot plug event occurred.
30
31     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
32     * in {@link DispErrCode} otherwise.
33     * @since 4.0
34     * @version 1.0
35     */
36    RegHotPlugCallback([in] IHotPlugCallback cb);
37
38    /**
39     * @brief Sets the client buffer cache count of a display device.
40     *
41     * @param devId Indicates the ID of the display device.
42     * @param count client buffer cache count.
43     *
44     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
45     * in {@link DispErrCode} otherwise.
46     * @since 4.0
47     * @version 1.0
48     */
49    SetClientBufferCacheCount([in] unsigned int devId, [in] unsigned int count);
50
51    /* *
52     * @brief Registers the callback to be invoked when a VBLANK event occurs.
53     *
54     * @param devId Indicates the ID of the display device.
55     * @param cb Indicates the instance used to notify the graphics service of the VBLANK event occurred when
56     * <b>DisplayVsync</b> is enabled.
57     *
58     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
59     * in {@link DispErrCode} otherwise.
60     * @since 4.0
61     * @version 1.0
62     */
63    RegDisplayVBlankCallback([in] unsigned int devId, [in] IVBlankCallback cb);
64
65    /* *
66     * @brief Obtains the capabilities of a display device.
67     *
68     * @param devId Indicates the ID of the display device.
69     * @param info Indicates the pointer to the capabilities supported by the display device. For details,
70     * see {@link DisplayCapability}.
71     *
72     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
73     * in {@link DispErrCode} otherwise.
74     * @since 4.0
75     * @version 1.0
76     */
77    GetDisplayCapability([in] unsigned int devId, [out] struct DisplayCapability info);
78
79    /* *
80     * @brief Obtains the display modes supported by a display device.
81     *
82     * @param devId Indicates the ID of the display device.
83     * @param modes Indicates the vector of the information about all modes supported by the display device,
84     * including all supported resolutions and refresh rates. Each mode has an ID, which will be used when
85     * the mode is set or obtained. For details, see {@link DisplayModeInfo}.
86     *
87     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
88     * in {@link DispErrCode} otherwise.
89     * @since 4.0
90     * @version 1.0
91     */
92    GetDisplaySupportedModes([in] unsigned int devId, [out] struct DisplayModeInfo[] modes);
93
94    /* *
95     * @brief Obtains the current display mode of a display device.
96     *
97     * @param devId Indicates the ID of the display device.
98     * @param modeId indicates the pointer to the ID of the current display mode of the device. The display mode ID
99     * is written by this API.
100     *
101     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
102     * in {@link DispErrCode} otherwise.
103     * @since 4.0
104     * @version 1.0
105     */
106    GetDisplayMode([in] unsigned int devId, [out] unsigned int modeId);
107
108    /* *
109     * @brief Sets the display mode of a display device.
110     *
111     * @param devId Indicates the ID of the display device.
112     * @param modeId Indicates the ID of the display mode. The device is switched to the display mode specified by
113     * this parameter in this interface.
114     *
115     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
116     * in {@link DispErrCode} otherwise.
117     * @since 4.0
118     * @version 1.0
119     */
120    SetDisplayMode([in] unsigned int devId, [in] unsigned int modeId);
121
122    /* *
123     * @brief Obtains the power status of a display device.
124     *
125     * @param devId Indicates the ID of the display device.
126     * @param status Indicates the pointer to the power status of the device. The status is written by this interface.
127     *
128     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
129     * in {@link DispErrCode} otherwise.
130     * @since 4.0
131     * @version 1.0
132     */
133    GetDisplayPowerStatus([in] unsigned int devId, [out] enum DispPowerStatus status);
134
135    /* *
136     * @brief Sets the power status of a display device.
137     *
138     * @param devId Indicates the ID of the display device.
139     * @param status Indicates the power status to set.
140     *
141     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
142     * in {@link DispErrCode} otherwise.
143     * @since 4.0
144     * @version 1.0
145     */
146    SetDisplayPowerStatus([in] unsigned int devId, [in] enum DispPowerStatus status);
147
148    /* *
149     * @brief Obtains the backlight value of a display device.
150     *
151     * @param devId Indicates the ID of the display device.
152     * @param level Indicates the pointer to the backlight value of the device. The backlight value is written
153     * by this interface.
154     *
155     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
156     * in {@link DispErrCode} otherwise.
157     * @since 4.0
158     * @version 1.0
159     */
160    GetDisplayBacklight([in] unsigned int devId, [out] unsigned int level);
161
162    /* *
163     * @brief Sets the backlight value for a display device.
164     *
165     * @param devId Indicates the ID of the display device.
166     * @param level Indicates the backlight value to set.
167     *
168     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
169     * in {@link DispErrCode} otherwise.
170     * @since 4.0
171     * @version 1.0
172     */
173    SetDisplayBacklight([in] unsigned int devId, [in] unsigned int level);
174
175    /* *
176     * @brief Enables or disables the vertical sync signal.
177     *
178     * When the vertical sync signal is generated, the <b>VBlankCallback</b> callback registered
179     * by <b>RegDisplayVBlankCallback</b> will be invoked. The vertical sync signal must be enabled when the graphics
180     * service needs to refresh the display, and disabled when display refresh is not required. The display does not
181     * need to refresh when <b>VBlankCallback</b> is invoked and the graphics service composes layers and sends the
182     * composition result to the device for display.
183     *
184     * @param devId Indicates the ID of the display device.
185     * @param enabled Specifies whether to enable the vertical sync signal. The value <b>true</b> means to enable the
186     * vertical sync signal, and <b>false</b> means to disable it.
187     *
188     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
189     * in {@link DispErrCode}otherwise.
190     * @since 4.0
191     * @version 1.0
192     */
193    SetDisplayVsyncEnabled([in] unsigned int devId, [in] boolean enabled);
194
195    /**
196     * @brief Opens a layer on a specified display device.
197     *
198     * Before using a layer on the GUI, you must open the layer based on the layer information. After the layer is
199     * opened, you can obtain the layer ID and then use other functions based on the layer ID.
200     *
201     * @param devId Indicates the ID of the display device. The value ranges from 0 to 4, where 0 indicates the first
202     * display device, and 4 indicates the last display device.
203     * @param layerInfo Indicates the pointer to the layer information passed to open a layer, including the layer
204     * type, layer size, and pixel format.
205     * @param cacheCount Indicates the count of buffer cache.
206     * @param layerId Indicates the pointer to the layer ID, which uniquely identifies a layer. The layer ID is returned
207     * to the GUI after the layer is successfully opened.
208     *
209     * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
210     * otherwise.
211     * @see DestroyLayer
212     * @since 4.0
213     * @version 1.0
214     */
215    CreateLayer([in] unsigned int devId, [in] struct LayerInfo layerInfo, [in] unsigned int cacheCount,
216        [out] unsigned int layerId);
217
218    /**
219     * @brief Opens a layer on a specified display device.
220     *
221     * Before using a layer on the GUI, you must open the layer based on the layer information. After the layer is
222     * opened, you can obtain the layer ID and then use other functions based on the layer ID.
223     *
224     * @param devId Indicates the ID of the display device. The value ranges from 0 to 4, where 0 indicates the first
225     * display device, and 4 indicates the last display device.
226     * @param layerId Indicates the pointer to the layer ID, which uniquely identifies a layer. The layer ID is returned
227     * to the GUI after the layer is successfully opened.
228     *
229     * @return Returns <b>0</b> if the operation is successful; returns an error code defined in {@link DispErrCode}
230     * otherwise.
231     * @see DestroyLayer
232     * @since 4.0
233     * @version 1.0
234     */
235    DestroyLayer([in] unsigned int devId, [in] unsigned int layerId);
236
237     /* *
238     * @brief Sets the cropped region for a display device.
239     *
240     * You can use this interface to set the cropped region of the client buffer of the display device.
241     * The cropped region cannot exceed the size of the client buffer.
242     *
243     * @param devId Indicates the ID of the display device.
244     * @param rect Indicates the pointer to the cropped region of the client buffer.
245     *
246     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
247     * in {@link DispErrCode} otherwise.
248     * @since 4.0
249     * @version 1.0
250     */
251    SetDisplayClientCrop([in] unsigned int devId, [in] struct IRect rect);
252
253    /* *
254     * @brief Obtains the fences of the display layers after the commit operation.
255     *
256     * @param devId Indicates the ID of the display device.
257     * @param layers Indicates the vector of the start address of the layer array.
258     * @param fences Indicates the vector of the start address of the fence array.
259     *
260     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
261     * in {@link DispErrCode} otherwise.
262     * @since 4.0
263     * @version 1.0
264     */
265    GetDisplayReleaseFence([in] unsigned int devId, [out] unsigned int[] layers, [out] HdifdParcelable[] fences);
266
267     /* *
268     * @brief Creates a virtual display device.
269     *
270     * @param width Indicates the pixel width of the display device.
271     * @param height Indicates the pixel height of the display device.
272     * @param format Indicates the pointer to the pixel format of the display device.
273     * @param devId Indicates the ID of the display device.
274     * For details, see {@link PixelFormat}. The <b>format</b> can be modified based on hardware requirements and
275     * returned to the graphics service.
276     *
277     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
278     * in {@link DispErrCode} otherwise.
279     * @since 4.0
280     * @version 1.0
281     */
282    CreateVirtualDisplay([in] unsigned int width, [in] unsigned int height, [out] int format, [out] unsigned int devId);
283
284    /* *
285     * @brief Destroys a virtual display device.
286     *
287     * @param devId Indicates the ID of the display device.
288     *
289     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
290     * in {@link DispErrCode} otherwise.
291     * @since 4.0
292     * @version 1.0
293     */
294    DestroyVirtualDisplay([in] unsigned int devId);
295
296    /* *
297     * @brief Sets the output buffer for a virtual display device.
298     *
299     * This buffer stores the output of the virtual display device. The buffer can be used only after the sync fence
300     * is in the signaled state.
301     *
302     * @param devId Indicates the ID of the display device.
303     * @param buffer Indicates the pointer to the output buffer.
304     * @param fence Indicates the sync fence.
305     *
306     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
307     * in {@link DispErrCode} otherwise.
308     * @since 4.0
309     * @version 1.0
310     */
311    SetVirtualDisplayBuffer([in] unsigned int devId, [in] NativeBuffer buffer, [in] HdifdParcelable fence);
312
313    /* *
314     * @brief Sets the property for a display device.
315     *
316     * @param devId Indicates the ID of the display device.
317     * @param id Indicates the property ID returned by <b>GetDisplayCapability</b>.
318     * @param value Indicates the property to set.
319     *
320     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
321     * in {@link DispErrCode} otherwise.
322     * @since 4.0
323     * @version 1.0
324     */
325    SetDisplayProperty([in] unsigned int devId, [in] unsigned int id, [in] unsigned long value);
326
327    /* *
328     * @brief Obtains the property for a display device.
329     *
330     * @param devId Indicates the ID of the display device.
331     * @param id Indicates the property ID returned by <b>GetDisplayCapability</b>.
332     * @param value Indicates the property to get.
333     *
334     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
335     * in {@link DispErrCode} otherwise.
336     * @since 4.0
337     * @version 1.0
338     */
339    GetDisplayProperty([in] unsigned int devId, [in] unsigned int id, [out] unsigned long value);
340
341    /* func for smq transfer */
342    /* *
343     * @brief Initializes a command request object.
344     *
345     * @param request Indicates the SharedMemQueue to Initializes.
346     *
347     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
348     * in {@link DispErrCode} otherwise.
349     * @since 4.0
350     * @version 1.0
351     */
352    InitCmdRequest([in] SharedMemQueue<int> request);
353
354    /* *
355     * @brief Send a command request.
356     *
357     * @param inEleCnt Indicates the number of element.
358     * @param inFds Indicates the ID of HdifdParcelable.
359     * @param outEleCnt outEleCnt inEleCnt Indicates the number of element to get.
360     * @param outFds outEleCnt Indicates the ID of HdifdParcelable to get.
361     *
362     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
363     * in {@link DispErrCode} otherwise.
364     * @since 4.0
365     * @version 1.0
366     */
367    CmdRequest([in] unsigned int inEleCnt, [in] struct HdifdInfo[] inFds, [out] unsigned int outEleCnt,
368        [out] struct HdifdInfo[] outFds);
369
370    /* *
371     * @brief Gets the return result of a command request.
372     *
373     * @param reply Indicates the the return result.
374     *
375     * @return Returns <b>0</b> if the operation is successful; returns an error code defined
376     * in {@link DispErrCode} otherwise.
377     * @since 4.0
378     * @version 1.0
379     */
380    GetCmdReply([out] SharedMemQueue<int> reply);
381}
382