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