1b8e80941Smrg/*
2b8e80941Smrg * Copyright © 2017 Keith Packard
3b8e80941Smrg *
4b8e80941Smrg * Permission to use, copy, modify, distribute, and sell this software and its
5b8e80941Smrg * documentation for any purpose is hereby granted without fee, provided that
6b8e80941Smrg * the above copyright notice appear in all copies and that both that copyright
7b8e80941Smrg * notice and this permission notice appear in supporting documentation, and
8b8e80941Smrg * that the name of the copyright holders not be used in advertising or
9b8e80941Smrg * publicity pertaining to distribution of the software without specific,
10b8e80941Smrg * written prior permission.  The copyright holders make no representations
11b8e80941Smrg * about the suitability of this software for any purpose.  It is provided "as
12b8e80941Smrg * is" without express or implied warranty.
13b8e80941Smrg *
14b8e80941Smrg * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15b8e80941Smrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16b8e80941Smrg * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17b8e80941Smrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18b8e80941Smrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19b8e80941Smrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20b8e80941Smrg * OF THIS SOFTWARE.
21b8e80941Smrg */
22b8e80941Smrg
23b8e80941Smrg#ifndef WSI_COMMON_DISPLAY_H
24b8e80941Smrg#define WSI_COMMON_DISPLAY_H
25b8e80941Smrg
26b8e80941Smrg#include "wsi_common.h"
27b8e80941Smrg#include <xf86drm.h>
28b8e80941Smrg#include <xf86drmMode.h>
29b8e80941Smrg
30b8e80941Smrg#define typed_memcpy(dest, src, count) ({ \
31b8e80941Smrg   STATIC_ASSERT(sizeof(*src) == sizeof(*dest)); \
32b8e80941Smrg   memcpy((dest), (src), (count) * sizeof(*(src))); \
33b8e80941Smrg})
34b8e80941Smrg
35b8e80941SmrgVkResult
36b8e80941Smrgwsi_display_get_physical_device_display_properties(
37b8e80941Smrg   VkPhysicalDevice physical_device,
38b8e80941Smrg   struct wsi_device *wsi_device,
39b8e80941Smrg   uint32_t *property_count,
40b8e80941Smrg   VkDisplayPropertiesKHR *properties);
41b8e80941Smrg
42b8e80941SmrgVkResult
43b8e80941Smrgwsi_display_get_physical_device_display_properties2(
44b8e80941Smrg   VkPhysicalDevice physical_device,
45b8e80941Smrg   struct wsi_device *wsi_device,
46b8e80941Smrg   uint32_t *pPropertyCount,
47b8e80941Smrg   VkDisplayProperties2KHR *pProperties);
48b8e80941Smrg
49b8e80941SmrgVkResult
50b8e80941Smrgwsi_display_get_physical_device_display_plane_properties(
51b8e80941Smrg   VkPhysicalDevice physical_device,
52b8e80941Smrg   struct wsi_device *wsi_device,
53b8e80941Smrg   uint32_t *property_count,
54b8e80941Smrg   VkDisplayPlanePropertiesKHR *properties);
55b8e80941Smrg
56b8e80941SmrgVkResult
57b8e80941Smrgwsi_display_get_physical_device_display_plane_properties2(
58b8e80941Smrg   VkPhysicalDevice physical_device,
59b8e80941Smrg   struct wsi_device *wsi_device,
60b8e80941Smrg   uint32_t *property_count,
61b8e80941Smrg   VkDisplayPlaneProperties2KHR *properties);
62b8e80941Smrg
63b8e80941SmrgVkResult
64b8e80941Smrgwsi_display_get_display_plane_supported_displays(
65b8e80941Smrg   VkPhysicalDevice physical_device,
66b8e80941Smrg   struct wsi_device *wsi_device,
67b8e80941Smrg   uint32_t plane_index,
68b8e80941Smrg   uint32_t *display_count,
69b8e80941Smrg   VkDisplayKHR *displays);
70b8e80941Smrg
71b8e80941SmrgVkResult
72b8e80941Smrgwsi_display_get_display_mode_properties(VkPhysicalDevice physical_device,
73b8e80941Smrg                                        struct wsi_device *wsi_device,
74b8e80941Smrg                                        VkDisplayKHR display,
75b8e80941Smrg                                        uint32_t *property_count,
76b8e80941Smrg                                        VkDisplayModePropertiesKHR *properties);
77b8e80941Smrg
78b8e80941SmrgVkResult
79b8e80941Smrgwsi_display_get_display_mode_properties2(VkPhysicalDevice physical_device,
80b8e80941Smrg                                         struct wsi_device *wsi_device,
81b8e80941Smrg                                         VkDisplayKHR display,
82b8e80941Smrg                                         uint32_t *property_count,
83b8e80941Smrg                                         VkDisplayModeProperties2KHR *properties);
84b8e80941Smrg
85b8e80941SmrgVkResult
86b8e80941Smrgwsi_display_create_display_mode(VkPhysicalDevice physical_device,
87b8e80941Smrg                                struct wsi_device *wsi_device,
88b8e80941Smrg                                VkDisplayKHR display,
89b8e80941Smrg                                const VkDisplayModeCreateInfoKHR *create_info,
90b8e80941Smrg                                const VkAllocationCallbacks *allocator,
91b8e80941Smrg                                VkDisplayModeKHR *mode);
92b8e80941Smrg
93b8e80941SmrgVkResult
94b8e80941Smrgwsi_get_display_plane_capabilities(VkPhysicalDevice physical_device,
95b8e80941Smrg                                   struct wsi_device *wsi_device,
96b8e80941Smrg                                   VkDisplayModeKHR mode_khr,
97b8e80941Smrg                                   uint32_t plane_index,
98b8e80941Smrg                                   VkDisplayPlaneCapabilitiesKHR *capabilities);
99b8e80941Smrg
100b8e80941SmrgVkResult
101b8e80941Smrgwsi_get_display_plane_capabilities2(VkPhysicalDevice physical_device,
102b8e80941Smrg                                    struct wsi_device *wsi_device,
103b8e80941Smrg                                    const VkDisplayPlaneInfo2KHR *pDisplayPlaneInfo,
104b8e80941Smrg                                    VkDisplayPlaneCapabilities2KHR *capabilities);
105b8e80941Smrg
106b8e80941SmrgVkResult
107b8e80941Smrgwsi_create_display_surface(VkInstance instance,
108b8e80941Smrg                           const VkAllocationCallbacks *pAllocator,
109b8e80941Smrg                           const VkDisplaySurfaceCreateInfoKHR *pCreateInfo,
110b8e80941Smrg                           VkSurfaceKHR *pSurface);
111b8e80941Smrg
112b8e80941SmrgVkResult
113b8e80941Smrgwsi_release_display(VkPhysicalDevice            physical_device,
114b8e80941Smrg                    struct wsi_device           *wsi_device,
115b8e80941Smrg                    VkDisplayKHR                display);
116b8e80941Smrg
117b8e80941Smrg
118b8e80941Smrg#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
119b8e80941SmrgVkResult
120b8e80941Smrgwsi_acquire_xlib_display(VkPhysicalDevice       physical_device,
121b8e80941Smrg                         struct wsi_device      *wsi_device,
122b8e80941Smrg                         Display                *dpy,
123b8e80941Smrg                         VkDisplayKHR           display);
124b8e80941Smrg
125b8e80941SmrgVkResult
126b8e80941Smrgwsi_get_randr_output_display(VkPhysicalDevice   physical_device,
127b8e80941Smrg                             struct wsi_device  *wsi_device,
128b8e80941Smrg                             Display            *dpy,
129b8e80941Smrg                             RROutput           output,
130b8e80941Smrg                             VkDisplayKHR       *display);
131b8e80941Smrg
132b8e80941Smrg#endif /* VK_USE_PLATFORM_XLIB_XRANDR_EXT */
133b8e80941Smrg
134b8e80941Smrg/* VK_EXT_display_control */
135b8e80941SmrgVkResult
136b8e80941Smrgwsi_display_power_control(VkDevice                      device,
137b8e80941Smrg                          struct wsi_device             *wsi_device,
138b8e80941Smrg                          VkDisplayKHR                  display,
139b8e80941Smrg                          const VkDisplayPowerInfoEXT   *display_power_info);
140b8e80941Smrg
141b8e80941SmrgVkResult
142b8e80941Smrgwsi_register_device_event(VkDevice                      device,
143b8e80941Smrg                          struct wsi_device             *wsi_device,
144b8e80941Smrg                          const VkDeviceEventInfoEXT    *device_event_info,
145b8e80941Smrg                          const VkAllocationCallbacks   *allocator,
146b8e80941Smrg                          struct wsi_fence              **fence);
147b8e80941Smrg
148b8e80941SmrgVkResult
149b8e80941Smrgwsi_register_display_event(VkDevice                     device,
150b8e80941Smrg                           struct wsi_device            *wsi_device,
151b8e80941Smrg                           VkDisplayKHR                 display,
152b8e80941Smrg                           const VkDisplayEventInfoEXT  *display_event_info,
153b8e80941Smrg                           const VkAllocationCallbacks  *allocator,
154b8e80941Smrg                           struct wsi_fence             **fence);
155b8e80941Smrg
156b8e80941SmrgVkResult
157b8e80941Smrgwsi_get_swapchain_counter(VkDevice                      device,
158b8e80941Smrg                          struct wsi_device             *wsi_device,
159b8e80941Smrg                          VkSwapchainKHR                swapchain,
160b8e80941Smrg                          VkSurfaceCounterFlagBitsEXT   flag_bits,
161b8e80941Smrg                          uint64_t                      *value);
162b8e80941Smrg
163b8e80941Smrg#endif
164