Home | History | Annotate | Line # | Download | only in drm
drm_agpsupport.h revision 1.6
      1 /*	$NetBSD: drm_agpsupport.h,v 1.6 2018/08/27 04:58:37 riastradh Exp $	*/
      2 
      3 #ifndef _DRM_AGPSUPPORT_H_
      4 #define _DRM_AGPSUPPORT_H_
      5 
      6 #include <linux/agp_backend.h>
      7 #include <linux/kernel.h>
      8 #include <linux/list.h>
      9 #include <linux/mm.h>
     10 #include <linux/mutex.h>
     11 #include <linux/types.h>
     12 #include <uapi/drm/drm.h>
     13 
     14 struct drm_device;
     15 struct drm_file;
     16 
     17 struct drm_agp_head {
     18 	struct agp_kern_info agp_info;
     19 	struct list_head memory;
     20 	unsigned long mode;
     21 	struct agp_bridge_data *bridge;
     22 	int enabled;
     23 	int acquired;
     24 	unsigned long base;
     25 	int agp_mtrr;
     26 	int cant_use_aperture;
     27 	unsigned long page_mask;
     28 };
     29 
     30 #if IS_ENABLED(CONFIG_AGP)
     31 
     32 #ifdef __NetBSD__
     33 static inline void drm_free_agp(struct agp_bridge_data *, struct agp_memory *, int);
     34 static inline int drm_bind_agp(struct agp_bridge_data *, struct agp_memory *, unsigned);
     35 static inline int drm_unbind_agp(struct agp_bridge_data *, struct agp_memory *);
     36 #else
     37 void drm_free_agp(struct agp_memory * handle, int pages);
     38 int drm_bind_agp(struct agp_memory * handle, unsigned int start);
     39 int drm_unbind_agp(struct agp_memory * handle);
     40 #endif
     41 struct agp_memory *drm_agp_bind_pages(struct drm_device *dev,
     42 				struct page **pages,
     43 				unsigned long num_pages,
     44 				uint32_t gtt_offset,
     45 				uint32_t type);
     46 
     47 struct drm_agp_head *drm_agp_init(struct drm_device *dev);
     48 void drm_agp_clear(struct drm_device *dev);
     49 int drm_agp_acquire(struct drm_device *dev);
     50 int drm_agp_acquire_ioctl(struct drm_device *dev, void *data,
     51 			  struct drm_file *file_priv);
     52 int drm_agp_release(struct drm_device *dev);
     53 int drm_agp_release_ioctl(struct drm_device *dev, void *data,
     54 			  struct drm_file *file_priv);
     55 int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode);
     56 int drm_agp_enable_ioctl(struct drm_device *dev, void *data,
     57 			 struct drm_file *file_priv);
     58 int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info);
     59 int drm_agp_info_ioctl(struct drm_device *dev, void *data,
     60 		       struct drm_file *file_priv);
     61 int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request);
     62 int drm_agp_alloc_ioctl(struct drm_device *dev, void *data,
     63 			struct drm_file *file_priv);
     64 int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request);
     65 int drm_agp_free_ioctl(struct drm_device *dev, void *data,
     66 		       struct drm_file *file_priv);
     67 int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request);
     68 int drm_agp_unbind_ioctl(struct drm_device *dev, void *data,
     69 			 struct drm_file *file_priv);
     70 int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request);
     71 int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
     72 		       struct drm_file *file_priv);
     73 
     74 #else /* CONFIG_AGP */
     75 
     76 #if !defined(__NetBSD__)
     77 
     78 static inline void drm_free_agp(struct agp_memory * handle, int pages)
     79 {
     80 }
     81 
     82 static inline int drm_bind_agp(struct agp_memory * handle, unsigned int start)
     83 {
     84 	return -ENODEV;
     85 }
     86 
     87 static inline int drm_unbind_agp(struct agp_memory * handle)
     88 {
     89 	return -ENODEV;
     90 }
     91 
     92 #endif
     93 
     94 static inline struct agp_memory *drm_agp_bind_pages(struct drm_device *dev,
     95 					      struct page **pages,
     96 					      unsigned long num_pages,
     97 					      uint32_t gtt_offset,
     98 					      uint32_t type)
     99 {
    100 	return NULL;
    101 }
    102 
    103 static inline struct drm_agp_head *drm_agp_init(struct drm_device *dev)
    104 {
    105 	return NULL;
    106 }
    107 
    108 static inline void drm_agp_clear(struct drm_device *dev)
    109 {
    110 }
    111 
    112 static inline int drm_agp_acquire(struct drm_device *dev)
    113 {
    114 	return -ENODEV;
    115 }
    116 
    117 static inline int drm_agp_release(struct drm_device *dev)
    118 {
    119 	return -ENODEV;
    120 }
    121 
    122 static inline int drm_agp_enable(struct drm_device *dev,
    123 				 struct drm_agp_mode mode)
    124 {
    125 	return -ENODEV;
    126 }
    127 
    128 static inline int drm_agp_info(struct drm_device *dev,
    129 			       struct drm_agp_info *info)
    130 {
    131 	return -ENODEV;
    132 }
    133 
    134 static inline int drm_agp_alloc(struct drm_device *dev,
    135 				struct drm_agp_buffer *request)
    136 {
    137 	return -ENODEV;
    138 }
    139 
    140 static inline int drm_agp_free(struct drm_device *dev,
    141 			       struct drm_agp_buffer *request)
    142 {
    143 	return -ENODEV;
    144 }
    145 
    146 static inline int drm_agp_unbind(struct drm_device *dev,
    147 				 struct drm_agp_binding *request)
    148 {
    149 	return -ENODEV;
    150 }
    151 
    152 static inline int drm_agp_bind(struct drm_device *dev,
    153 			       struct drm_agp_binding *request)
    154 {
    155 	return -ENODEV;
    156 }
    157 
    158 #endif /* CONFIG_AGP */
    159 
    160 #endif /* _DRM_AGPSUPPORT_H_ */
    161