virtgpu_drm.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. #define VIRTGPU_PARAM_CAPSET_QUERY_FIX 2 /* do we have the capset fix */
  58. struct drm_virtgpu_getparam {
  59. uint64_t param;
  60. uint64_t value;
  61. };
  62. /* NO_BO flags? NO resource flag? */
  63. /* resource flag for y_0_top */
  64. struct drm_virtgpu_resource_create {
  65. uint32_t target;
  66. uint32_t format;
  67. uint32_t bind;
  68. uint32_t width;
  69. uint32_t height;
  70. uint32_t depth;
  71. uint32_t array_size;
  72. uint32_t last_level;
  73. uint32_t nr_samples;
  74. uint32_t flags;
  75. uint32_t bo_handle; /* if this is set - recreate a new resource attached to this bo ? */
  76. uint32_t res_handle; /* returned by kernel */
  77. uint32_t size; /* validate transfer in the host */
  78. uint32_t stride; /* validate transfer in the host */
  79. };
  80. struct drm_virtgpu_resource_info {
  81. uint32_t bo_handle;
  82. uint32_t res_handle;
  83. uint32_t size;
  84. uint32_t stride;
  85. };
  86. struct drm_virtgpu_3d_box {
  87. uint32_t x;
  88. uint32_t y;
  89. uint32_t z;
  90. uint32_t w;
  91. uint32_t h;
  92. uint32_t d;
  93. };
  94. struct drm_virtgpu_3d_transfer_to_host {
  95. uint32_t bo_handle;
  96. struct drm_virtgpu_3d_box box;
  97. uint32_t level;
  98. uint32_t offset;
  99. };
  100. struct drm_virtgpu_3d_transfer_from_host {
  101. uint32_t bo_handle;
  102. struct drm_virtgpu_3d_box box;
  103. uint32_t level;
  104. uint32_t offset;
  105. };
  106. #define VIRTGPU_WAIT_NOWAIT 1 /* like it */
  107. struct drm_virtgpu_3d_wait {
  108. uint32_t handle; /* 0 is an invalid handle */
  109. uint32_t flags;
  110. };
  111. struct drm_virtgpu_get_caps {
  112. uint32_t cap_set_id;
  113. uint32_t cap_set_ver;
  114. uint64_t addr;
  115. uint32_t size;
  116. uint32_t pad;
  117. };
  118. #define DRM_IOCTL_VIRTGPU_MAP \
  119. DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_MAP, struct drm_virtgpu_map)
  120. #define DRM_IOCTL_VIRTGPU_EXECBUFFER \
  121. DRM_IOW(DRM_COMMAND_BASE + DRM_VIRTGPU_EXECBUFFER,\
  122. struct drm_virtgpu_execbuffer)
  123. #define DRM_IOCTL_VIRTGPU_GETPARAM \
  124. DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_GETPARAM,\
  125. struct drm_virtgpu_getparam)
  126. #define DRM_IOCTL_VIRTGPU_RESOURCE_CREATE \
  127. DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_RESOURCE_CREATE, \
  128. struct drm_virtgpu_resource_create)
  129. #define DRM_IOCTL_VIRTGPU_RESOURCE_INFO \
  130. DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_RESOURCE_INFO, \
  131. struct drm_virtgpu_resource_info)
  132. #define DRM_IOCTL_VIRTGPU_TRANSFER_FROM_HOST \
  133. DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_TRANSFER_FROM_HOST, \
  134. struct drm_virtgpu_3d_transfer_from_host)
  135. #define DRM_IOCTL_VIRTGPU_TRANSFER_TO_HOST \
  136. DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_TRANSFER_TO_HOST, \
  137. struct drm_virtgpu_3d_transfer_to_host)
  138. #define DRM_IOCTL_VIRTGPU_WAIT \
  139. DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_WAIT, \
  140. struct drm_virtgpu_3d_wait)
  141. #define DRM_IOCTL_VIRTGPU_GET_CAPS \
  142. DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_GET_CAPS, \
  143. struct drm_virtgpu_get_caps)
  144. #endif