virtgpu_drm.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /*
  2. * Copyright 2013 Red Hat
  3. * All Rights Reserved.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a
  6. * copy of this software and associated documentation files (the "Software"),
  7. * to deal in the Software without restriction, including without limitation
  8. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9. * and/or sell copies of the Software, and to permit persons to whom the
  10. * Software is furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice (including the next
  13. * paragraph) shall be included in all copies or substantial portions of the
  14. * Software.
  15. *
  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
  19. * THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  20. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  21. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  22. * OTHER DEALINGS IN THE SOFTWARE.
  23. */
  24. #ifndef VIRTGPU_DRM_H
  25. #define VIRTGPU_DRM_H
  26. #include <stddef.h>
  27. #include "drm/drm.h"
  28. /* Please note that modifications to all structs defined here are
  29. * subject to backwards-compatibility constraints.
  30. *
  31. * Do not use pointers, use uint64_t instead for 32 bit / 64 bit user/kernel
  32. * compatibility Keep fields aligned to their size
  33. */
  34. #define DRM_VIRTGPU_MAP 0x01
  35. #define DRM_VIRTGPU_EXECBUFFER 0x02
  36. #define DRM_VIRTGPU_GETPARAM 0x03
  37. #define DRM_VIRTGPU_RESOURCE_CREATE 0x04
  38. #define DRM_VIRTGPU_RESOURCE_INFO 0x05
  39. #define DRM_VIRTGPU_TRANSFER_FROM_HOST 0x06
  40. #define DRM_VIRTGPU_TRANSFER_TO_HOST 0x07
  41. #define DRM_VIRTGPU_WAIT 0x08
  42. #define DRM_VIRTGPU_GET_CAPS 0x09
  43. struct drm_virtgpu_map {
  44. uint64_t offset; /* use for mmap system call */
  45. uint32_t handle;
  46. uint32_t pad;
  47. };
  48. struct drm_virtgpu_execbuffer {
  49. uint32_t flags; /* for future use */
  50. uint32_t size;
  51. uint64_t command; /* void* */
  52. uint64_t bo_handles;
  53. uint32_t num_bo_handles;
  54. uint32_t pad;
  55. };
  56. #define VIRTGPU_PARAM_3D_FEATURES 1 /* do we have 3D features in the hw */
  57. struct drm_virtgpu_getparam {
  58. uint64_t param;
  59. uint64_t value;
  60. };
  61. /* NO_BO flags? NO resource flag? */
  62. /* resource flag for y_0_top */
  63. struct drm_virtgpu_resource_create {
  64. uint32_t target;
  65. uint32_t format;
  66. uint32_t bind;
  67. uint32_t width;
  68. uint32_t height;
  69. uint32_t depth;
  70. uint32_t array_size;
  71. uint32_t last_level;
  72. uint32_t nr_samples;
  73. uint32_t flags;
  74. uint32_t bo_handle; /* if this is set - recreate a new resource attached to this bo ? */
  75. uint32_t res_handle; /* returned by kernel */
  76. uint32_t size; /* validate transfer in the host */
  77. uint32_t stride; /* validate transfer in the host */
  78. };
  79. struct drm_virtgpu_resource_info {
  80. uint32_t bo_handle;
  81. uint32_t res_handle;
  82. uint32_t size;
  83. uint32_t stride;
  84. };
  85. struct drm_virtgpu_3d_box {
  86. uint32_t x;
  87. uint32_t y;
  88. uint32_t z;
  89. uint32_t w;
  90. uint32_t h;
  91. uint32_t d;
  92. };
  93. struct drm_virtgpu_3d_transfer_to_host {
  94. uint32_t bo_handle;
  95. struct drm_virtgpu_3d_box box;
  96. uint32_t level;
  97. uint32_t offset;
  98. };
  99. struct drm_virtgpu_3d_transfer_from_host {
  100. uint32_t bo_handle;
  101. struct drm_virtgpu_3d_box box;
  102. uint32_t level;
  103. uint32_t offset;
  104. };
  105. #define VIRTGPU_WAIT_NOWAIT 1 /* like it */
  106. struct drm_virtgpu_3d_wait {
  107. uint32_t handle; /* 0 is an invalid handle */
  108. uint32_t flags;
  109. };
  110. struct drm_virtgpu_get_caps {
  111. uint32_t cap_set_id;
  112. uint32_t cap_set_ver;
  113. uint64_t addr;
  114. uint32_t size;
  115. uint32_t pad;
  116. };
  117. #define DRM_IOCTL_VIRTGPU_MAP \
  118. DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_MAP, struct drm_virtgpu_map)
  119. #define DRM_IOCTL_VIRTGPU_EXECBUFFER \
  120. DRM_IOW(DRM_COMMAND_BASE + DRM_VIRTGPU_EXECBUFFER,\
  121. struct drm_virtgpu_execbuffer)
  122. #define DRM_IOCTL_VIRTGPU_GETPARAM \
  123. DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_GETPARAM,\
  124. struct drm_virtgpu_getparam)
  125. #define DRM_IOCTL_VIRTGPU_RESOURCE_CREATE \
  126. DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_RESOURCE_CREATE, \
  127. struct drm_virtgpu_resource_create)
  128. #define DRM_IOCTL_VIRTGPU_RESOURCE_INFO \
  129. DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_RESOURCE_INFO, \
  130. struct drm_virtgpu_resource_info)
  131. #define DRM_IOCTL_VIRTGPU_TRANSFER_FROM_HOST \
  132. DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_TRANSFER_FROM_HOST, \
  133. struct drm_virtgpu_3d_transfer_from_host)
  134. #define DRM_IOCTL_VIRTGPU_TRANSFER_TO_HOST \
  135. DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_TRANSFER_TO_HOST, \
  136. struct drm_virtgpu_3d_transfer_to_host)
  137. #define DRM_IOCTL_VIRTGPU_WAIT \
  138. DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_WAIT, \
  139. struct drm_virtgpu_3d_wait)
  140. #define DRM_IOCTL_VIRTGPU_GET_CAPS \
  141. DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_GET_CAPS, \
  142. struct drm_virtgpu_get_caps)
  143. #endif