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