drm_legacy.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. #ifndef __DRM_LEGACY_H__
  2. #define __DRM_LEGACY_H__
  3. /*
  4. * Copyright (c) 2014 David Herrmann <dh.herrmann@gmail.com>
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the "Software"),
  8. * to deal in the Software without restriction, including without limitation
  9. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. * and/or sell copies of the Software, and to permit persons to whom the
  11. * Software is furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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. /*
  25. * This file contains legacy interfaces that modern drm drivers
  26. * should no longer be using. They cannot be removed as legacy
  27. * drivers use them, and removing them are API breaks.
  28. */
  29. #include <linux/list.h>
  30. #include <drm/drm.h>
  31. #include <drm/drm_device.h>
  32. #include <drm/drm_legacy.h>
  33. struct agp_memory;
  34. struct drm_device;
  35. struct drm_file;
  36. struct drm_buf_desc;
  37. /*
  38. * Generic DRM Contexts
  39. */
  40. #define DRM_KERNEL_CONTEXT 0
  41. #define DRM_RESERVED_CONTEXTS 1
  42. #if IS_ENABLED(CONFIG_DRM_LEGACY)
  43. void drm_legacy_ctxbitmap_init(struct drm_device *dev);
  44. void drm_legacy_ctxbitmap_cleanup(struct drm_device *dev);
  45. void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file);
  46. #else
  47. static inline void drm_legacy_ctxbitmap_init(struct drm_device *dev) {}
  48. static inline void drm_legacy_ctxbitmap_cleanup(struct drm_device *dev) {}
  49. static inline void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file) {}
  50. #endif
  51. void drm_legacy_ctxbitmap_free(struct drm_device *dev, int ctx_handle);
  52. #if IS_ENABLED(CONFIG_DRM_LEGACY)
  53. int drm_legacy_resctx(struct drm_device *d, void *v, struct drm_file *f);
  54. int drm_legacy_addctx(struct drm_device *d, void *v, struct drm_file *f);
  55. int drm_legacy_getctx(struct drm_device *d, void *v, struct drm_file *f);
  56. int drm_legacy_switchctx(struct drm_device *d, void *v, struct drm_file *f);
  57. int drm_legacy_newctx(struct drm_device *d, void *v, struct drm_file *f);
  58. int drm_legacy_rmctx(struct drm_device *d, void *v, struct drm_file *f);
  59. int drm_legacy_setsareactx(struct drm_device *d, void *v, struct drm_file *f);
  60. int drm_legacy_getsareactx(struct drm_device *d, void *v, struct drm_file *f);
  61. #endif
  62. /*
  63. * Generic Buffer Management
  64. */
  65. #define DRM_MAP_HASH_OFFSET 0x10000000
  66. #if IS_ENABLED(CONFIG_DRM_LEGACY)
  67. static inline int drm_legacy_create_map_hash(struct drm_device *dev)
  68. {
  69. return drm_ht_create(&dev->map_hash, 12);
  70. }
  71. static inline void drm_legacy_remove_map_hash(struct drm_device *dev)
  72. {
  73. drm_ht_remove(&dev->map_hash);
  74. }
  75. #else
  76. static inline int drm_legacy_create_map_hash(struct drm_device *dev)
  77. {
  78. return 0;
  79. }
  80. static inline void drm_legacy_remove_map_hash(struct drm_device *dev) {}
  81. #endif
  82. #if IS_ENABLED(CONFIG_DRM_LEGACY)
  83. int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
  84. struct drm_file *file_priv);
  85. int drm_legacy_addmap_ioctl(struct drm_device *d, void *v, struct drm_file *f);
  86. int drm_legacy_rmmap_ioctl(struct drm_device *d, void *v, struct drm_file *f);
  87. int drm_legacy_addbufs(struct drm_device *d, void *v, struct drm_file *f);
  88. int drm_legacy_infobufs(struct drm_device *d, void *v, struct drm_file *f);
  89. int drm_legacy_markbufs(struct drm_device *d, void *v, struct drm_file *f);
  90. int drm_legacy_freebufs(struct drm_device *d, void *v, struct drm_file *f);
  91. int drm_legacy_mapbufs(struct drm_device *d, void *v, struct drm_file *f);
  92. int drm_legacy_dma_ioctl(struct drm_device *d, void *v, struct drm_file *f);
  93. #endif
  94. int __drm_legacy_infobufs(struct drm_device *, void *, int *,
  95. int (*)(void *, int, struct drm_buf_entry *));
  96. int __drm_legacy_mapbufs(struct drm_device *, void *, int *,
  97. void __user **,
  98. int (*)(void *, int, unsigned long, struct drm_buf *),
  99. struct drm_file *);
  100. #if IS_ENABLED(CONFIG_DRM_LEGACY)
  101. void drm_legacy_master_rmmaps(struct drm_device *dev,
  102. struct drm_master *master);
  103. void drm_legacy_rmmaps(struct drm_device *dev);
  104. #else
  105. static inline void drm_legacy_master_rmmaps(struct drm_device *dev,
  106. struct drm_master *master) {}
  107. static inline void drm_legacy_rmmaps(struct drm_device *dev) {}
  108. #endif
  109. #if IS_ENABLED(CONFIG_DRM_VM) && IS_ENABLED(CONFIG_DRM_LEGACY)
  110. void drm_legacy_vma_flush(struct drm_device *d);
  111. #else
  112. static inline void drm_legacy_vma_flush(struct drm_device *d)
  113. {
  114. /* do nothing */
  115. }
  116. #endif
  117. /*
  118. * AGP Support
  119. */
  120. struct drm_agp_mem {
  121. unsigned long handle;
  122. struct agp_memory *memory;
  123. unsigned long bound;
  124. int pages;
  125. struct list_head head;
  126. };
  127. /* drm_lock.c */
  128. #if IS_ENABLED(CONFIG_DRM_LEGACY)
  129. int drm_legacy_lock(struct drm_device *d, void *v, struct drm_file *f);
  130. int drm_legacy_unlock(struct drm_device *d, void *v, struct drm_file *f);
  131. void drm_legacy_lock_release(struct drm_device *dev, struct file *filp);
  132. #else
  133. static inline void drm_legacy_lock_release(struct drm_device *dev, struct file *filp) {}
  134. #endif
  135. /* DMA support */
  136. #if IS_ENABLED(CONFIG_DRM_LEGACY)
  137. int drm_legacy_dma_setup(struct drm_device *dev);
  138. void drm_legacy_dma_takedown(struct drm_device *dev);
  139. #else
  140. static inline int drm_legacy_dma_setup(struct drm_device *dev)
  141. {
  142. return 0;
  143. }
  144. #endif
  145. void drm_legacy_free_buffer(struct drm_device *dev,
  146. struct drm_buf * buf);
  147. #if IS_ENABLED(CONFIG_DRM_LEGACY)
  148. void drm_legacy_reclaim_buffers(struct drm_device *dev,
  149. struct drm_file *filp);
  150. #else
  151. static inline void drm_legacy_reclaim_buffers(struct drm_device *dev,
  152. struct drm_file *filp) {}
  153. #endif
  154. /* Scatter Gather Support */
  155. #if IS_ENABLED(CONFIG_DRM_LEGACY)
  156. void drm_legacy_sg_cleanup(struct drm_device *dev);
  157. int drm_legacy_sg_alloc(struct drm_device *dev, void *data,
  158. struct drm_file *file_priv);
  159. int drm_legacy_sg_free(struct drm_device *dev, void *data,
  160. struct drm_file *file_priv);
  161. #endif
  162. #if IS_ENABLED(CONFIG_DRM_LEGACY)
  163. void drm_legacy_init_members(struct drm_device *dev);
  164. void drm_legacy_destroy_members(struct drm_device *dev);
  165. void drm_legacy_dev_reinit(struct drm_device *dev);
  166. int drm_legacy_setup(struct drm_device * dev);
  167. #else
  168. static inline void drm_legacy_init_members(struct drm_device *dev) {}
  169. static inline void drm_legacy_destroy_members(struct drm_device *dev) {}
  170. static inline void drm_legacy_dev_reinit(struct drm_device *dev) {}
  171. static inline int drm_legacy_setup(struct drm_device * dev) { return 0; }
  172. #endif
  173. #if IS_ENABLED(CONFIG_DRM_LEGACY)
  174. void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master);
  175. #else
  176. static inline void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master) {}
  177. #endif
  178. #if IS_ENABLED(CONFIG_DRM_LEGACY)
  179. void drm_master_legacy_init(struct drm_master *master);
  180. #else
  181. static inline void drm_master_legacy_init(struct drm_master *master) {}
  182. #endif
  183. #endif /* __DRM_LEGACY_H__ */