0001 #ifndef __DRM_LEGACY_H__
0002 #define __DRM_LEGACY_H__
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 #include <linux/list.h>
0032
0033 #include <drm/drm.h>
0034 #include <drm/drm_device.h>
0035 #include <drm/drm_legacy.h>
0036
0037 struct agp_memory;
0038 struct drm_buf_desc;
0039 struct drm_device;
0040 struct drm_file;
0041 struct drm_hash_item;
0042 struct drm_open_hash;
0043
0044
0045
0046
0047
0048 #define drm_hash_entry(_ptr, _type, _member) container_of(_ptr, _type, _member)
0049
0050
0051 #if IS_ENABLED(CONFIG_DRM_LEGACY)
0052 int drm_ht_create(struct drm_open_hash *ht, unsigned int order);
0053 int drm_ht_insert_item(struct drm_open_hash *ht, struct drm_hash_item *item);
0054 int drm_ht_just_insert_please(struct drm_open_hash *ht, struct drm_hash_item *item,
0055 unsigned long seed, int bits, int shift,
0056 unsigned long add);
0057 int drm_ht_find_item(struct drm_open_hash *ht, unsigned long key, struct drm_hash_item **item);
0058
0059 void drm_ht_verbose_list(struct drm_open_hash *ht, unsigned long key);
0060 int drm_ht_remove_key(struct drm_open_hash *ht, unsigned long key);
0061 int drm_ht_remove_item(struct drm_open_hash *ht, struct drm_hash_item *item);
0062 void drm_ht_remove(struct drm_open_hash *ht);
0063 #endif
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074 #define drm_ht_insert_item_rcu drm_ht_insert_item
0075 #define drm_ht_just_insert_please_rcu drm_ht_just_insert_please
0076 #define drm_ht_remove_key_rcu drm_ht_remove_key
0077 #define drm_ht_remove_item_rcu drm_ht_remove_item
0078 #define drm_ht_find_item_rcu drm_ht_find_item
0079
0080
0081
0082
0083
0084 #define DRM_KERNEL_CONTEXT 0
0085 #define DRM_RESERVED_CONTEXTS 1
0086
0087 #if IS_ENABLED(CONFIG_DRM_LEGACY)
0088 void drm_legacy_ctxbitmap_init(struct drm_device *dev);
0089 void drm_legacy_ctxbitmap_cleanup(struct drm_device *dev);
0090 void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file);
0091 #else
0092 static inline void drm_legacy_ctxbitmap_init(struct drm_device *dev) {}
0093 static inline void drm_legacy_ctxbitmap_cleanup(struct drm_device *dev) {}
0094 static inline void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file) {}
0095 #endif
0096
0097 void drm_legacy_ctxbitmap_free(struct drm_device *dev, int ctx_handle);
0098
0099 #if IS_ENABLED(CONFIG_DRM_LEGACY)
0100 int drm_legacy_resctx(struct drm_device *d, void *v, struct drm_file *f);
0101 int drm_legacy_addctx(struct drm_device *d, void *v, struct drm_file *f);
0102 int drm_legacy_getctx(struct drm_device *d, void *v, struct drm_file *f);
0103 int drm_legacy_switchctx(struct drm_device *d, void *v, struct drm_file *f);
0104 int drm_legacy_newctx(struct drm_device *d, void *v, struct drm_file *f);
0105 int drm_legacy_rmctx(struct drm_device *d, void *v, struct drm_file *f);
0106
0107 int drm_legacy_setsareactx(struct drm_device *d, void *v, struct drm_file *f);
0108 int drm_legacy_getsareactx(struct drm_device *d, void *v, struct drm_file *f);
0109 #endif
0110
0111
0112
0113
0114
0115 #define DRM_MAP_HASH_OFFSET 0x10000000
0116
0117 #if IS_ENABLED(CONFIG_DRM_LEGACY)
0118 static inline int drm_legacy_create_map_hash(struct drm_device *dev)
0119 {
0120 return drm_ht_create(&dev->map_hash, 12);
0121 }
0122
0123 static inline void drm_legacy_remove_map_hash(struct drm_device *dev)
0124 {
0125 drm_ht_remove(&dev->map_hash);
0126 }
0127 #else
0128 static inline int drm_legacy_create_map_hash(struct drm_device *dev)
0129 {
0130 return 0;
0131 }
0132
0133 static inline void drm_legacy_remove_map_hash(struct drm_device *dev) {}
0134 #endif
0135
0136
0137 #if IS_ENABLED(CONFIG_DRM_LEGACY)
0138 int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
0139 struct drm_file *file_priv);
0140 int drm_legacy_addmap_ioctl(struct drm_device *d, void *v, struct drm_file *f);
0141 int drm_legacy_rmmap_ioctl(struct drm_device *d, void *v, struct drm_file *f);
0142
0143 int drm_legacy_addbufs(struct drm_device *d, void *v, struct drm_file *f);
0144 int drm_legacy_infobufs(struct drm_device *d, void *v, struct drm_file *f);
0145 int drm_legacy_markbufs(struct drm_device *d, void *v, struct drm_file *f);
0146 int drm_legacy_freebufs(struct drm_device *d, void *v, struct drm_file *f);
0147 int drm_legacy_mapbufs(struct drm_device *d, void *v, struct drm_file *f);
0148 int drm_legacy_dma_ioctl(struct drm_device *d, void *v, struct drm_file *f);
0149 #endif
0150
0151 int __drm_legacy_infobufs(struct drm_device *, void *, int *,
0152 int (*)(void *, int, struct drm_buf_entry *));
0153 int __drm_legacy_mapbufs(struct drm_device *, void *, int *,
0154 void __user **,
0155 int (*)(void *, int, unsigned long, struct drm_buf *),
0156 struct drm_file *);
0157
0158 #if IS_ENABLED(CONFIG_DRM_LEGACY)
0159 void drm_legacy_master_rmmaps(struct drm_device *dev,
0160 struct drm_master *master);
0161 void drm_legacy_rmmaps(struct drm_device *dev);
0162 #else
0163 static inline void drm_legacy_master_rmmaps(struct drm_device *dev,
0164 struct drm_master *master) {}
0165 static inline void drm_legacy_rmmaps(struct drm_device *dev) {}
0166 #endif
0167
0168 #if IS_ENABLED(CONFIG_DRM_LEGACY)
0169 void drm_legacy_vma_flush(struct drm_device *d);
0170 #else
0171 static inline void drm_legacy_vma_flush(struct drm_device *d)
0172 {
0173
0174 }
0175 #endif
0176
0177
0178
0179
0180
0181 struct drm_agp_mem {
0182 unsigned long handle;
0183 struct agp_memory *memory;
0184 unsigned long bound;
0185 int pages;
0186 struct list_head head;
0187 };
0188
0189
0190 #if IS_ENABLED(CONFIG_DRM_LEGACY) && IS_ENABLED(CONFIG_AGP)
0191 void drm_legacy_agp_clear(struct drm_device *dev);
0192
0193 int drm_legacy_agp_acquire_ioctl(struct drm_device *dev, void *data,
0194 struct drm_file *file_priv);
0195 int drm_legacy_agp_release_ioctl(struct drm_device *dev, void *data,
0196 struct drm_file *file_priv);
0197 int drm_legacy_agp_enable_ioctl(struct drm_device *dev, void *data,
0198 struct drm_file *file_priv);
0199 int drm_legacy_agp_info_ioctl(struct drm_device *dev, void *data,
0200 struct drm_file *file_priv);
0201 int drm_legacy_agp_alloc_ioctl(struct drm_device *dev, void *data,
0202 struct drm_file *file_priv);
0203 int drm_legacy_agp_free_ioctl(struct drm_device *dev, void *data,
0204 struct drm_file *file_priv);
0205 int drm_legacy_agp_unbind_ioctl(struct drm_device *dev, void *data,
0206 struct drm_file *file_priv);
0207 int drm_legacy_agp_bind_ioctl(struct drm_device *dev, void *data,
0208 struct drm_file *file_priv);
0209 #else
0210 static inline void drm_legacy_agp_clear(struct drm_device *dev) {}
0211 #endif
0212
0213
0214 #if IS_ENABLED(CONFIG_DRM_LEGACY)
0215 int drm_legacy_lock(struct drm_device *d, void *v, struct drm_file *f);
0216 int drm_legacy_unlock(struct drm_device *d, void *v, struct drm_file *f);
0217 void drm_legacy_lock_release(struct drm_device *dev, struct file *filp);
0218 #else
0219 static inline void drm_legacy_lock_release(struct drm_device *dev, struct file *filp) {}
0220 #endif
0221
0222
0223 #if IS_ENABLED(CONFIG_DRM_LEGACY)
0224 int drm_legacy_dma_setup(struct drm_device *dev);
0225 void drm_legacy_dma_takedown(struct drm_device *dev);
0226 #else
0227 static inline int drm_legacy_dma_setup(struct drm_device *dev)
0228 {
0229 return 0;
0230 }
0231 #endif
0232
0233 void drm_legacy_free_buffer(struct drm_device *dev,
0234 struct drm_buf * buf);
0235 #if IS_ENABLED(CONFIG_DRM_LEGACY)
0236 void drm_legacy_reclaim_buffers(struct drm_device *dev,
0237 struct drm_file *filp);
0238 #else
0239 static inline void drm_legacy_reclaim_buffers(struct drm_device *dev,
0240 struct drm_file *filp) {}
0241 #endif
0242
0243
0244 #if IS_ENABLED(CONFIG_DRM_LEGACY)
0245 void drm_legacy_sg_cleanup(struct drm_device *dev);
0246 int drm_legacy_sg_alloc(struct drm_device *dev, void *data,
0247 struct drm_file *file_priv);
0248 int drm_legacy_sg_free(struct drm_device *dev, void *data,
0249 struct drm_file *file_priv);
0250 #endif
0251
0252 #if IS_ENABLED(CONFIG_DRM_LEGACY)
0253 void drm_legacy_init_members(struct drm_device *dev);
0254 void drm_legacy_destroy_members(struct drm_device *dev);
0255 void drm_legacy_dev_reinit(struct drm_device *dev);
0256 int drm_legacy_setup(struct drm_device * dev);
0257 #else
0258 static inline void drm_legacy_init_members(struct drm_device *dev) {}
0259 static inline void drm_legacy_destroy_members(struct drm_device *dev) {}
0260 static inline void drm_legacy_dev_reinit(struct drm_device *dev) {}
0261 static inline int drm_legacy_setup(struct drm_device * dev) { return 0; }
0262 #endif
0263
0264 #if IS_ENABLED(CONFIG_DRM_LEGACY)
0265 void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master);
0266 #else
0267 static inline void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master) {}
0268 #endif
0269
0270 #if IS_ENABLED(CONFIG_DRM_LEGACY)
0271 void drm_master_legacy_init(struct drm_master *master);
0272 #else
0273 static inline void drm_master_legacy_init(struct drm_master *master) {}
0274 #endif
0275
0276
0277 #if IS_ENABLED(CONFIG_DRM_LEGACY) && IS_ENABLED(CONFIG_PCI)
0278 int drm_legacy_irq_by_busid(struct drm_device *dev, void *data, struct drm_file *file_priv);
0279 void drm_legacy_pci_agp_destroy(struct drm_device *dev);
0280 #else
0281 static inline int drm_legacy_irq_by_busid(struct drm_device *dev, void *data,
0282 struct drm_file *file_priv)
0283 {
0284 return -EINVAL;
0285 }
0286
0287 static inline void drm_legacy_pci_agp_destroy(struct drm_device *dev) {}
0288 #endif
0289
0290 #endif