virtgpu_drm.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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 "drm.h"
  27. #if defined(__cplusplus)
  28. extern "C" {
  29. #endif
  30. /* Please note that modifications to all structs defined here are
  31. * subject to backwards-compatibility constraints.
  32. *
  33. * Do not use pointers, use __u64 instead for 32 bit / 64 bit user/kernel
  34. * compatibility Keep fields aligned to their size
  35. */
  36. #define DRM_VIRTGPU_MAP 0x01
  37. #define DRM_VIRTGPU_EXECBUFFER 0x02
  38. #define DRM_VIRTGPU_GETPARAM 0x03
  39. #define DRM_VIRTGPU_RESOURCE_CREATE 0x04
  40. #define DRM_VIRTGPU_RESOURCE_INFO 0x05
  41. #define DRM_VIRTGPU_TRANSFER_FROM_HOST 0x06
  42. #define DRM_VIRTGPU_TRANSFER_TO_HOST 0x07
  43. #define DRM_VIRTGPU_WAIT 0x08
  44. #define DRM_VIRTGPU_GET_CAPS 0x09
  45. struct drm_virtgpu_map {
  46. __u64 offset; /* use for mmap system call */
  47. __u32 handle;
  48. __u32 pad;
  49. };
  50. struct drm_virtgpu_execbuffer {
  51. __u32 flags; /* for future use */
  52. __u32 size;
  53. __u64 command; /* void* */
  54. __u64 bo_handles;
  55. __u32 num_bo_handles;
  56. __u32 pad;
  57. };
  58. #define VIRTGPU_PARAM_3D_FEATURES 1 /* do we have 3D features in the hw */
  59. #define VIRTGPU_PARAM_CAPSET_QUERY_FIX 2 /* do we have the capset fix */
  60. struct drm_virtgpu_getparam {
  61. __u64 param;
  62. __u64 value;
  63. };
  64. /* NO_BO flags? NO resource flag? */
  65. /* resource flag for y_0_top */
  66. struct drm_virtgpu_resource_create {
  67. __u32 target;
  68. __u32 format;
  69. __u32 bind;
  70. __u32 width;
  71. __u32 height;
  72. __u32 depth;
  73. __u32 array_size;
  74. __u32 last_level;
  75. __u32 nr_samples;
  76. __u32 flags;
  77. __u32 bo_handle; /* if this is set - recreate a new resource attached to this bo ? */
  78. __u32 res_handle; /* returned by kernel */
  79. __u32 size; /* validate transfer in the host */
  80. __u32 stride; /* validate transfer in the host */
  81. };
  82. struct drm_virtgpu_resource_info {
  83. __u32 bo_handle;
  84. __u32 res_handle;
  85. __u32 size;
  86. __u32 stride;
  87. };
  88. struct drm_virtgpu_3d_box {
  89. __u32 x;
  90. __u32 y;
  91. __u32 z;
  92. __u32 w;
  93. __u32 h;
  94. __u32 d;
  95. };
  96. struct drm_virtgpu_3d_transfer_to_host {
  97. __u32 bo_handle;
  98. struct drm_virtgpu_3d_box box;
  99. __u32 level;
  100. __u32 offset;
  101. };
  102. struct drm_virtgpu_3d_transfer_from_host {
  103. __u32 bo_handle;
  104. struct drm_virtgpu_3d_box box;
  105. __u32 level;
  106. __u32 offset;
  107. };
  108. #define VIRTGPU_WAIT_NOWAIT 1 /* like it */
  109. struct drm_virtgpu_3d_wait {
  110. __u32 handle; /* 0 is an invalid handle */
  111. __u32 flags;
  112. };
  113. struct drm_virtgpu_get_caps {
  114. __u32 cap_set_id;
  115. __u32 cap_set_ver;
  116. __u64 addr;
  117. __u32 size;
  118. __u32 pad;
  119. };
  120. #define DRM_IOCTL_VIRTGPU_MAP \
  121. DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_MAP, struct drm_virtgpu_map)
  122. #define DRM_IOCTL_VIRTGPU_EXECBUFFER \
  123. DRM_IOW(DRM_COMMAND_BASE + DRM_VIRTGPU_EXECBUFFER,\
  124. struct drm_virtgpu_execbuffer)
  125. #define DRM_IOCTL_VIRTGPU_GETPARAM \
  126. DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_GETPARAM,\
  127. struct drm_virtgpu_getparam)
  128. #define DRM_IOCTL_VIRTGPU_RESOURCE_CREATE \
  129. DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_RESOURCE_CREATE, \
  130. struct drm_virtgpu_resource_create)
  131. #define DRM_IOCTL_VIRTGPU_RESOURCE_INFO \
  132. DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_RESOURCE_INFO, \
  133. struct drm_virtgpu_resource_info)
  134. #define DRM_IOCTL_VIRTGPU_TRANSFER_FROM_HOST \
  135. DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_TRANSFER_FROM_HOST, \
  136. struct drm_virtgpu_3d_transfer_from_host)
  137. #define DRM_IOCTL_VIRTGPU_TRANSFER_TO_HOST \
  138. DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_TRANSFER_TO_HOST, \
  139. struct drm_virtgpu_3d_transfer_to_host)
  140. #define DRM_IOCTL_VIRTGPU_WAIT \
  141. DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_WAIT, \
  142. struct drm_virtgpu_3d_wait)
  143. #define DRM_IOCTL_VIRTGPU_GET_CAPS \
  144. DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_GET_CAPS, \
  145. struct drm_virtgpu_get_caps)
  146. #if defined(__cplusplus)
  147. }
  148. #endif
  149. #endif