2 * Copyright (c) 2017-2019, 2021 Arm Limited.
4 * SPDX-License-Identifier: MIT
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28 #include <wayland-client.h>
29 #include <linux-dmabuf-unstable-v1-client-protocol.h>
30 #include "util/custom_allocator.hpp"
31 struct drm_format_pair
38 * @brief Get supported formats and modifiers using the zwp_linux_dmabuf_v1 interface.
40 * @param[in] display The wl_display that is being used.
41 * @param[in] dmabuf_interface Object of the zwp_linux_dmabuf_v1 interface.
42 * @param[out] supported_formats Vector which will contain the supported drm
43 * formats and their modifiers.
45 * @retval VK_SUCCESS Indicates success.
46 * @retval VK_ERROR_UNKNOWN Indicates one of the Wayland functions failed.
47 * @retval VK_ERROR_OUT_OF_DEVICE_MEMORY Indicates the host went out of memory.
49 VkResult get_supported_formats_and_modifiers(
50 struct wl_display* display, struct zwp_linux_dmabuf_v1 *dmabuf_interface,
51 util::vector<drm_format_pair> &supported_formats);
54 void registry_handler(void *data, struct wl_registry *wl_registry, uint32_t name, const char *interface,
58 * @brief Dispatch events from a Wayland event queue
60 * Dispatch events from a given Wayland display event queue, including calling event handlers, and flush out any
61 * requests the event handlers may have written. Specification of a timeout allows the wait to be bounded. If any
62 * events are already pending dispatch (have been read from the display by another thread or event queue), they
63 * will be dispatched and the function will return immediately, without waiting for new events to arrive.
65 * @param display Wayland display to dispatch events from
66 * @param queue Event queue to dispatch events from; other event queues will not have their handlers called from
67 * within this function
68 * @param timeout Maximum time to wait for events to arrive, in milliseconds
69 * @return 1 if one or more events were dispatched on this queue, 0 if the timeout was reached without any
70 * events being dispatched, or -1 on error.
72 int dispatch_queue(struct wl_display *display, struct wl_event_queue *queue, int timeout);