1 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
4 * Xen para-virtual DRM device
6 * Copyright (C) 2016-2018 EPAM Systems Inc.
11 #ifndef __XEN_DRM_FRONT_SHBUF_H_
12 #define __XEN_DRM_FRONT_SHBUF_H_
14 #include <linux/kernel.h>
15 #include <linux/scatterlist.h>
17 #include <xen/grant_table.h>
19 struct xen_drm_front_shbuf {
21 * number of references granted for the backend use:
22 * - for allocated/imported dma-buf's this holds number of grant
23 * references for the page directory and pages of the buffer
24 * - for the buffer provided by the backend this holds number of
25 * grant references for the page directory as grant references for
26 * the buffer will be provided by the backend
30 unsigned char *directory;
35 struct xenbus_device *xb_dev;
37 /* these are the ops used internally depending on be_alloc mode */
38 const struct xen_drm_front_shbuf_ops *ops;
40 /* Xen map handles for the buffer allocated by the backend */
41 grant_handle_t *backend_map_handles;
44 struct xen_drm_front_shbuf_cfg {
45 struct xenbus_device *xb_dev;
51 struct xen_drm_front_shbuf *
52 xen_drm_front_shbuf_alloc(struct xen_drm_front_shbuf_cfg *cfg);
54 grant_ref_t xen_drm_front_shbuf_get_dir_start(struct xen_drm_front_shbuf *buf);
56 int xen_drm_front_shbuf_map(struct xen_drm_front_shbuf *buf);
58 int xen_drm_front_shbuf_unmap(struct xen_drm_front_shbuf *buf);
60 void xen_drm_front_shbuf_flush(struct xen_drm_front_shbuf *buf);
62 void xen_drm_front_shbuf_free(struct xen_drm_front_shbuf *buf);
64 #endif /* __XEN_DRM_FRONT_SHBUF_H_ */