0001 #ifndef __DRM_DRM_LEGACY_H__
0002 #define __DRM_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
0032
0033
0034
0035
0036 #include <linux/agp_backend.h>
0037
0038 #include <drm/drm.h>
0039 #include <drm/drm_auth.h>
0040
0041 struct drm_device;
0042 struct drm_driver;
0043 struct file;
0044 struct pci_driver;
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057 struct drm_hash_item {
0058 struct hlist_node head;
0059 unsigned long key;
0060 };
0061
0062 struct drm_open_hash {
0063 struct hlist_head *table;
0064 u8 order;
0065 };
0066
0067
0068
0069
0070 struct drm_buf {
0071 int idx;
0072 int total;
0073 int order;
0074 int used;
0075 unsigned long offset;
0076 void *address;
0077 unsigned long bus_address;
0078 struct drm_buf *next;
0079 __volatile__ int waiting;
0080 __volatile__ int pending;
0081 struct drm_file *file_priv;
0082 int context;
0083 int while_locked;
0084 enum {
0085 DRM_LIST_NONE = 0,
0086 DRM_LIST_FREE = 1,
0087 DRM_LIST_WAIT = 2,
0088 DRM_LIST_PEND = 3,
0089 DRM_LIST_PRIO = 4,
0090 DRM_LIST_RECLAIM = 5
0091 } list;
0092
0093 int dev_priv_size;
0094 void *dev_private;
0095 };
0096
0097 typedef struct drm_dma_handle {
0098 dma_addr_t busaddr;
0099 void *vaddr;
0100 size_t size;
0101 } drm_dma_handle_t;
0102
0103
0104
0105
0106 struct drm_buf_entry {
0107 int buf_size;
0108 int buf_count;
0109 struct drm_buf *buflist;
0110 int seg_count;
0111 int page_order;
0112 struct drm_dma_handle **seglist;
0113
0114 int low_mark;
0115 int high_mark;
0116 };
0117
0118
0119
0120
0121 struct drm_device_dma {
0122
0123 struct drm_buf_entry bufs[DRM_MAX_ORDER + 1];
0124 int buf_count;
0125 struct drm_buf **buflist;
0126 int seg_count;
0127 int page_count;
0128 unsigned long *pagelist;
0129 unsigned long byte_count;
0130 enum {
0131 _DRM_DMA_USE_AGP = 0x01,
0132 _DRM_DMA_USE_SG = 0x02,
0133 _DRM_DMA_USE_FB = 0x04,
0134 _DRM_DMA_USE_PCI_RO = 0x08
0135 } flags;
0136
0137 };
0138
0139
0140
0141
0142 struct drm_sg_mem {
0143 unsigned long handle;
0144 void *virtual;
0145 int pages;
0146 struct page **pagelist;
0147 dma_addr_t *busaddr;
0148 };
0149
0150
0151
0152
0153 struct drm_local_map {
0154 dma_addr_t offset;
0155 unsigned long size;
0156 enum drm_map_type type;
0157 enum drm_map_flags flags;
0158 void *handle;
0159
0160 int mtrr;
0161 };
0162
0163 typedef struct drm_local_map drm_local_map_t;
0164
0165
0166
0167
0168 struct drm_map_list {
0169 struct list_head head;
0170 struct drm_hash_item hash;
0171 struct drm_local_map *map;
0172 uint64_t user_token;
0173 struct drm_master *master;
0174 };
0175
0176 int drm_legacy_addmap(struct drm_device *d, resource_size_t offset,
0177 unsigned int size, enum drm_map_type type,
0178 enum drm_map_flags flags, struct drm_local_map **map_p);
0179 struct drm_local_map *drm_legacy_findmap(struct drm_device *dev, unsigned int token);
0180 void drm_legacy_rmmap(struct drm_device *d, struct drm_local_map *map);
0181 int drm_legacy_rmmap_locked(struct drm_device *d, struct drm_local_map *map);
0182 struct drm_local_map *drm_legacy_getsarea(struct drm_device *dev);
0183 int drm_legacy_mmap(struct file *filp, struct vm_area_struct *vma);
0184
0185 int drm_legacy_addbufs_agp(struct drm_device *d, struct drm_buf_desc *req);
0186 int drm_legacy_addbufs_pci(struct drm_device *d, struct drm_buf_desc *req);
0187
0188
0189
0190
0191
0192
0193
0194 #define LOCK_TEST_WITH_RETURN( dev, _file_priv ) \
0195 do { \
0196 if (!_DRM_LOCK_IS_HELD(_file_priv->master->lock.hw_lock->lock) || \
0197 _file_priv->master->lock.file_priv != _file_priv) { \
0198 DRM_ERROR( "%s called without lock held, held %d owner %p %p\n",\
0199 __func__, _DRM_LOCK_IS_HELD(_file_priv->master->lock.hw_lock->lock),\
0200 _file_priv->master->lock.file_priv, _file_priv); \
0201 return -EINVAL; \
0202 } \
0203 } while (0)
0204
0205 void drm_legacy_idlelock_take(struct drm_lock_data *lock);
0206 void drm_legacy_idlelock_release(struct drm_lock_data *lock);
0207
0208
0209 int drm_legacy_irq_uninstall(struct drm_device *dev);
0210
0211
0212
0213 #ifdef CONFIG_PCI
0214
0215 int drm_legacy_pci_init(const struct drm_driver *driver,
0216 struct pci_driver *pdriver);
0217 void drm_legacy_pci_exit(const struct drm_driver *driver,
0218 struct pci_driver *pdriver);
0219
0220 #else
0221
0222 static inline struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev,
0223 size_t size, size_t align)
0224 {
0225 return NULL;
0226 }
0227
0228 static inline void drm_pci_free(struct drm_device *dev,
0229 struct drm_dma_handle *dmah)
0230 {
0231 }
0232
0233 static inline int drm_legacy_pci_init(const struct drm_driver *driver,
0234 struct pci_driver *pdriver)
0235 {
0236 return -EINVAL;
0237 }
0238
0239 static inline void drm_legacy_pci_exit(const struct drm_driver *driver,
0240 struct pci_driver *pdriver)
0241 {
0242 }
0243
0244 #endif
0245
0246
0247
0248
0249
0250 struct drm_agp_head {
0251 struct agp_kern_info agp_info;
0252 struct list_head memory;
0253 unsigned long mode;
0254 struct agp_bridge_data *bridge;
0255 int enabled;
0256 int acquired;
0257 unsigned long base;
0258 int agp_mtrr;
0259 int cant_use_aperture;
0260 unsigned long page_mask;
0261 };
0262
0263 #if IS_ENABLED(CONFIG_DRM_LEGACY) && IS_ENABLED(CONFIG_AGP)
0264 struct drm_agp_head *drm_legacy_agp_init(struct drm_device *dev);
0265 int drm_legacy_agp_acquire(struct drm_device *dev);
0266 int drm_legacy_agp_release(struct drm_device *dev);
0267 int drm_legacy_agp_enable(struct drm_device *dev, struct drm_agp_mode mode);
0268 int drm_legacy_agp_info(struct drm_device *dev, struct drm_agp_info *info);
0269 int drm_legacy_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request);
0270 int drm_legacy_agp_free(struct drm_device *dev, struct drm_agp_buffer *request);
0271 int drm_legacy_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request);
0272 int drm_legacy_agp_bind(struct drm_device *dev, struct drm_agp_binding *request);
0273 #else
0274 static inline struct drm_agp_head *drm_legacy_agp_init(struct drm_device *dev)
0275 {
0276 return NULL;
0277 }
0278
0279 static inline int drm_legacy_agp_acquire(struct drm_device *dev)
0280 {
0281 return -ENODEV;
0282 }
0283
0284 static inline int drm_legacy_agp_release(struct drm_device *dev)
0285 {
0286 return -ENODEV;
0287 }
0288
0289 static inline int drm_legacy_agp_enable(struct drm_device *dev,
0290 struct drm_agp_mode mode)
0291 {
0292 return -ENODEV;
0293 }
0294
0295 static inline int drm_legacy_agp_info(struct drm_device *dev,
0296 struct drm_agp_info *info)
0297 {
0298 return -ENODEV;
0299 }
0300
0301 static inline int drm_legacy_agp_alloc(struct drm_device *dev,
0302 struct drm_agp_buffer *request)
0303 {
0304 return -ENODEV;
0305 }
0306
0307 static inline int drm_legacy_agp_free(struct drm_device *dev,
0308 struct drm_agp_buffer *request)
0309 {
0310 return -ENODEV;
0311 }
0312
0313 static inline int drm_legacy_agp_unbind(struct drm_device *dev,
0314 struct drm_agp_binding *request)
0315 {
0316 return -ENODEV;
0317 }
0318
0319 static inline int drm_legacy_agp_bind(struct drm_device *dev,
0320 struct drm_agp_binding *request)
0321 {
0322 return -ENODEV;
0323 }
0324 #endif
0325
0326
0327 void drm_legacy_ioremap(struct drm_local_map *map, struct drm_device *dev);
0328 void drm_legacy_ioremap_wc(struct drm_local_map *map, struct drm_device *dev);
0329 void drm_legacy_ioremapfree(struct drm_local_map *map, struct drm_device *dev);
0330
0331 #endif