drm/msm/hdmi: Enable HPD after HDMI IRQ is set up
[linux/fpc-iii.git] / drivers / gpu / drm / xen / xen_drm_front.h
blob5693b4a4b02b1a951d897f30bd60bf2e74a6297d
1 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
3 /*
4 * Xen para-virtual DRM device
6 * Copyright (C) 2016-2018 EPAM Systems Inc.
8 * Author: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
9 */
11 #ifndef __XEN_DRM_FRONT_H_
12 #define __XEN_DRM_FRONT_H_
14 #include <drm/drmP.h>
15 #include <drm/drm_simple_kms_helper.h>
17 #include <linux/scatterlist.h>
19 #include "xen_drm_front_cfg.h"
21 /**
22 * DOC: Driver modes of operation in terms of display buffers used
24 * Depending on the requirements for the para-virtualized environment, namely
25 * requirements dictated by the accompanying DRM/(v)GPU drivers running in both
26 * host and guest environments, display buffers can be allocated by either
27 * frontend driver or backend.
30 /**
31 * DOC: Buffers allocated by the frontend driver
33 * In this mode of operation driver allocates buffers from system memory.
35 * Note! If used with accompanying DRM/(v)GPU drivers this mode of operation
36 * may require IOMMU support on the platform, so accompanying DRM/vGPU
37 * hardware can still reach display buffer memory while importing PRIME
38 * buffers from the frontend driver.
41 /**
42 * DOC: Buffers allocated by the backend
44 * This mode of operation is run-time configured via guest domain configuration
45 * through XenStore entries.
47 * For systems which do not provide IOMMU support, but having specific
48 * requirements for display buffers it is possible to allocate such buffers
49 * at backend side and share those with the frontend.
50 * For example, if host domain is 1:1 mapped and has DRM/GPU hardware expecting
51 * physically contiguous memory, this allows implementing zero-copying
52 * use-cases.
54 * Note, while using this scenario the following should be considered:
56 * #. If guest domain dies then pages/grants received from the backend
57 * cannot be claimed back
59 * #. Misbehaving guest may send too many requests to the
60 * backend exhausting its grant references and memory
61 * (consider this from security POV)
64 /**
65 * DOC: Driver limitations
67 * #. Only primary plane without additional properties is supported.
69 * #. Only one video mode per connector supported which is configured
70 * via XenStore.
72 * #. All CRTCs operate at fixed frequency of 60Hz.
75 /* timeout in ms to wait for backend to respond */
76 #define XEN_DRM_FRONT_WAIT_BACK_MS 3000
78 #ifndef GRANT_INVALID_REF
80 * Note on usage of grant reference 0 as invalid grant reference:
81 * grant reference 0 is valid, but never exposed to a PV driver,
82 * because of the fact it is already in use/reserved by the PV console.
84 #define GRANT_INVALID_REF 0
85 #endif
87 struct xen_drm_front_info {
88 struct xenbus_device *xb_dev;
89 struct xen_drm_front_drm_info *drm_info;
91 /* to protect data between backend IO code and interrupt handler */
92 spinlock_t io_lock;
94 int num_evt_pairs;
95 struct xen_drm_front_evtchnl_pair *evt_pairs;
96 struct xen_drm_front_cfg cfg;
98 /* display buffers */
99 struct list_head dbuf_list;
102 struct xen_drm_front_drm_pipeline {
103 struct xen_drm_front_drm_info *drm_info;
105 int index;
107 struct drm_simple_display_pipe pipe;
109 struct drm_connector conn;
110 /* These are only for connector mode checking */
111 int width, height;
113 struct drm_pending_vblank_event *pending_event;
115 struct delayed_work pflip_to_worker;
117 bool conn_connected;
120 struct xen_drm_front_drm_info {
121 struct xen_drm_front_info *front_info;
122 struct drm_device *drm_dev;
124 struct xen_drm_front_drm_pipeline pipeline[XEN_DRM_FRONT_MAX_CRTCS];
127 static inline u64 xen_drm_front_fb_to_cookie(struct drm_framebuffer *fb)
129 return (uintptr_t)fb;
132 static inline u64 xen_drm_front_dbuf_to_cookie(struct drm_gem_object *gem_obj)
134 return (uintptr_t)gem_obj;
137 int xen_drm_front_mode_set(struct xen_drm_front_drm_pipeline *pipeline,
138 u32 x, u32 y, u32 width, u32 height,
139 u32 bpp, u64 fb_cookie);
141 int xen_drm_front_dbuf_create(struct xen_drm_front_info *front_info,
142 u64 dbuf_cookie, u32 width, u32 height,
143 u32 bpp, u64 size, struct page **pages);
145 int xen_drm_front_fb_attach(struct xen_drm_front_info *front_info,
146 u64 dbuf_cookie, u64 fb_cookie, u32 width,
147 u32 height, u32 pixel_format);
149 int xen_drm_front_fb_detach(struct xen_drm_front_info *front_info,
150 u64 fb_cookie);
152 int xen_drm_front_page_flip(struct xen_drm_front_info *front_info,
153 int conn_idx, u64 fb_cookie);
155 void xen_drm_front_on_frame_done(struct xen_drm_front_info *front_info,
156 int conn_idx, u64 fb_cookie);
158 #endif /* __XEN_DRM_FRONT_H_ */