Back to home page

OSCL-LXR

 
 

    


0001 #ifndef __DRM_LEGACY_H__
0002 #define __DRM_LEGACY_H__
0003 
0004 /*
0005  * Copyright (c) 2014 David Herrmann <dh.herrmann@gmail.com>
0006  *
0007  * Permission is hereby granted, free of charge, to any person obtaining a
0008  * copy of this software and associated documentation files (the "Software"),
0009  * to deal in the Software without restriction, including without limitation
0010  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0011  * and/or sell copies of the Software, and to permit persons to whom the
0012  * Software is furnished to do so, subject to the following conditions:
0013  *
0014  * The above copyright notice and this permission notice shall be included in
0015  * all copies or substantial portions of the Software.
0016  *
0017  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0018  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0019  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0020  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
0021  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0022  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0023  * OTHER DEALINGS IN THE SOFTWARE.
0024  */
0025 
0026 /*
0027  * This file contains legacy interfaces that modern drm drivers
0028  * should no longer be using. They cannot be removed as legacy
0029  * drivers use them, and removing them are API breaks.
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  * Hash-table Support
0046  */
0047 
0048 #define drm_hash_entry(_ptr, _type, _member) container_of(_ptr, _type, _member)
0049 
0050 /* drm_hashtab.c */
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  * RCU-safe interface
0067  *
0068  * The user of this API needs to make sure that two or more instances of the
0069  * hash table manipulation functions are never run simultaneously.
0070  * The lookup function drm_ht_find_item_rcu may, however, run simultaneously
0071  * with any of the manipulation functions as long as it's called from within
0072  * an RCU read-locked section.
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  * Generic DRM Contexts
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  * Generic Buffer Management
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     /* do nothing */
0174 }
0175 #endif
0176 
0177 /*
0178  * AGP Support
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 /* drm_agpsupport.c */
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 /* drm_lock.c */
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 /* DMA support */
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 /* Scatter Gather Support */
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 /* drm_pci.c */
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 /* __DRM_LEGACY_H__ */