qxl_drm.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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 QXL_DRM_H
  25. #define QXL_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 QXL_GEM_DOMAIN_CPU 0
  35. #define QXL_GEM_DOMAIN_VRAM 1
  36. #define QXL_GEM_DOMAIN_SURFACE 2
  37. #define DRM_QXL_ALLOC 0x00
  38. #define DRM_QXL_MAP 0x01
  39. #define DRM_QXL_EXECBUFFER 0x02
  40. #define DRM_QXL_UPDATE_AREA 0x03
  41. #define DRM_QXL_GETPARAM 0x04
  42. #define DRM_QXL_CLIENTCAP 0x05
  43. #define DRM_QXL_ALLOC_SURF 0x06
  44. struct drm_qxl_alloc {
  45. uint32_t size;
  46. uint32_t handle; /* 0 is an invalid handle */
  47. };
  48. struct drm_qxl_map {
  49. uint64_t offset; /* use for mmap system call */
  50. uint32_t handle;
  51. uint32_t pad;
  52. };
  53. /*
  54. * dest is the bo we are writing the relocation into
  55. * src is bo we are relocating.
  56. * *(dest_handle.base_addr + dest_offset) = physical_address(src_handle.addr +
  57. * src_offset)
  58. */
  59. #define QXL_RELOC_TYPE_BO 1
  60. #define QXL_RELOC_TYPE_SURF 2
  61. struct drm_qxl_reloc {
  62. uint64_t src_offset; /* offset into src_handle or src buffer */
  63. uint64_t dst_offset; /* offset in dest handle */
  64. uint32_t src_handle; /* dest handle to compute address from */
  65. uint32_t dst_handle; /* 0 if to command buffer */
  66. uint32_t reloc_type;
  67. uint32_t pad;
  68. };
  69. struct drm_qxl_command {
  70. uint64_t command; /* void* */
  71. uint64_t relocs; /* struct drm_qxl_reloc* */
  72. uint32_t type;
  73. uint32_t command_size;
  74. uint32_t relocs_num;
  75. uint32_t pad;
  76. };
  77. /* XXX: call it drm_qxl_commands? */
  78. struct drm_qxl_execbuffer {
  79. uint32_t flags; /* for future use */
  80. uint32_t commands_num;
  81. uint64_t commands; /* struct drm_qxl_command* */
  82. };
  83. struct drm_qxl_update_area {
  84. uint32_t handle;
  85. uint32_t top;
  86. uint32_t left;
  87. uint32_t bottom;
  88. uint32_t right;
  89. uint32_t pad;
  90. };
  91. #define QXL_PARAM_NUM_SURFACES 1 /* rom->n_surfaces */
  92. #define QXL_PARAM_MAX_RELOCS 2
  93. struct drm_qxl_getparam {
  94. uint64_t param;
  95. uint64_t value;
  96. };
  97. /* these are one bit values */
  98. struct drm_qxl_clientcap {
  99. uint32_t index;
  100. uint32_t pad;
  101. };
  102. struct drm_qxl_alloc_surf {
  103. uint32_t format;
  104. uint32_t width;
  105. uint32_t height;
  106. int32_t stride;
  107. uint32_t handle;
  108. uint32_t pad;
  109. };
  110. #define DRM_IOCTL_QXL_ALLOC \
  111. DRM_IOWR(DRM_COMMAND_BASE + DRM_QXL_ALLOC, struct drm_qxl_alloc)
  112. #define DRM_IOCTL_QXL_MAP \
  113. DRM_IOWR(DRM_COMMAND_BASE + DRM_QXL_MAP, struct drm_qxl_map)
  114. #define DRM_IOCTL_QXL_EXECBUFFER \
  115. DRM_IOW(DRM_COMMAND_BASE + DRM_QXL_EXECBUFFER,\
  116. struct drm_qxl_execbuffer)
  117. #define DRM_IOCTL_QXL_UPDATE_AREA \
  118. DRM_IOW(DRM_COMMAND_BASE + DRM_QXL_UPDATE_AREA,\
  119. struct drm_qxl_update_area)
  120. #define DRM_IOCTL_QXL_GETPARAM \
  121. DRM_IOWR(DRM_COMMAND_BASE + DRM_QXL_GETPARAM,\
  122. struct drm_qxl_getparam)
  123. #define DRM_IOCTL_QXL_CLIENTCAP \
  124. DRM_IOW(DRM_COMMAND_BASE + DRM_QXL_CLIENTCAP,\
  125. struct drm_qxl_clientcap)
  126. #define DRM_IOCTL_QXL_ALLOC_SURF \
  127. DRM_IOWR(DRM_COMMAND_BASE + DRM_QXL_ALLOC_SURF,\
  128. struct drm_qxl_alloc_surf)
  129. #endif