xen_drm_front_shbuf.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* SPDX-License-Identifier: GPL-2.0 OR MIT */
  2. /*
  3. * Xen para-virtual DRM device
  4. *
  5. * Copyright (C) 2016-2018 EPAM Systems Inc.
  6. *
  7. * Author: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
  8. */
  9. #ifndef __XEN_DRM_FRONT_SHBUF_H_
  10. #define __XEN_DRM_FRONT_SHBUF_H_
  11. #include <linux/kernel.h>
  12. #include <linux/scatterlist.h>
  13. #include <xen/grant_table.h>
  14. struct xen_drm_front_shbuf {
  15. /*
  16. * number of references granted for the backend use:
  17. * - for allocated/imported dma-buf's this holds number of grant
  18. * references for the page directory and pages of the buffer
  19. * - for the buffer provided by the backend this holds number of
  20. * grant references for the page directory as grant references for
  21. * the buffer will be provided by the backend
  22. */
  23. int num_grefs;
  24. grant_ref_t *grefs;
  25. unsigned char *directory;
  26. int num_pages;
  27. struct page **pages;
  28. struct xenbus_device *xb_dev;
  29. /* these are the ops used internally depending on be_alloc mode */
  30. const struct xen_drm_front_shbuf_ops *ops;
  31. /* Xen map handles for the buffer allocated by the backend */
  32. grant_handle_t *backend_map_handles;
  33. };
  34. struct xen_drm_front_shbuf_cfg {
  35. struct xenbus_device *xb_dev;
  36. size_t size;
  37. struct page **pages;
  38. bool be_alloc;
  39. };
  40. struct xen_drm_front_shbuf *
  41. xen_drm_front_shbuf_alloc(struct xen_drm_front_shbuf_cfg *cfg);
  42. grant_ref_t xen_drm_front_shbuf_get_dir_start(struct xen_drm_front_shbuf *buf);
  43. int xen_drm_front_shbuf_map(struct xen_drm_front_shbuf *buf);
  44. int xen_drm_front_shbuf_unmap(struct xen_drm_front_shbuf *buf);
  45. void xen_drm_front_shbuf_flush(struct xen_drm_front_shbuf *buf);
  46. void xen_drm_front_shbuf_free(struct xen_drm_front_shbuf *buf);
  47. #endif /* __XEN_DRM_FRONT_SHBUF_H_ */