1 #ifndef _DRM_AGPSUPPORT_H_
2 #define _DRM_AGPSUPPORT_H_
3 
4 #include <linux/agp_backend.h>
5 #include <linux/kernel.h>
6 #include <linux/list.h>
7 #include <linux/mm.h>
8 #include <linux/mutex.h>
9 #include <linux/types.h>
10 #include <uapi/drm/drm.h>
11 
12 #include <linux/kconfig.h>
13 
14 #include <sys/agpio.h>
15 #include <dev/agp/agpvar.h>
16 
17 struct drm_device;
18 struct drm_file;
19 
20 #define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && \
21 					      defined(MODULE)))
22 
23 struct drm_agp_head {
24 	device_t	agpdev;
25 	struct agp_info	agp_info;
26 	struct drm_agp_mem *memory;
27 	unsigned long mode;
28 	int enabled;
29 	int acquired;
30 	unsigned long base;
31 	int agp_mtrr;
32 	int cant_use_aperture;
33 	unsigned long page_mask;
34 };
35 
36 #if __OS_HAS_AGP
37 
38 void drm_free_agp(struct agp_memory * handle, int pages);
39 int drm_bind_agp(struct agp_memory * handle, unsigned int start);
40 int drm_unbind_agp(struct agp_memory * handle);
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_legacy_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 static inline void drm_free_agp(struct agp_memory * handle, int pages)
77 {
78 }
79 
80 static inline int drm_bind_agp(struct agp_memory * handle, unsigned int start)
81 {
82 	return -ENODEV;
83 }
84 
85 static inline int drm_unbind_agp(struct agp_memory * handle)
86 {
87 	return -ENODEV;
88 }
89 
90 static inline struct agp_memory *drm_agp_bind_pages(struct drm_device *dev,
91 					      struct page **pages,
92 					      unsigned long num_pages,
93 					      uint32_t gtt_offset,
94 					      uint32_t type)
95 {
96 	return NULL;
97 }
98 
99 static inline struct drm_agp_head *drm_agp_init(struct drm_device *dev)
100 {
101 	return NULL;
102 }
103 
104 static inline void drm_legacy_agp_clear(struct drm_device *dev)
105 {
106 }
107 
108 static inline int drm_agp_acquire(struct drm_device *dev)
109 {
110 	return -ENODEV;
111 }
112 
113 static inline int drm_agp_release(struct drm_device *dev)
114 {
115 	return -ENODEV;
116 }
117 
118 static inline int drm_agp_enable(struct drm_device *dev,
119 				 struct drm_agp_mode mode)
120 {
121 	return -ENODEV;
122 }
123 
124 static inline int drm_agp_info(struct drm_device *dev,
125 			       struct drm_agp_info *info)
126 {
127 	return -ENODEV;
128 }
129 
130 static inline int drm_agp_alloc(struct drm_device *dev,
131 				struct drm_agp_buffer *request)
132 {
133 	return -ENODEV;
134 }
135 
136 static inline int drm_agp_free(struct drm_device *dev,
137 			       struct drm_agp_buffer *request)
138 {
139 	return -ENODEV;
140 }
141 
142 static inline int drm_agp_unbind(struct drm_device *dev,
143 				 struct drm_agp_binding *request)
144 {
145 	return -ENODEV;
146 }
147 
148 static inline int drm_agp_bind(struct drm_device *dev,
149 			       struct drm_agp_binding *request)
150 {
151 	return -ENODEV;
152 }
153 
154 #endif /* CONFIG_AGP */
155 
156 #endif /* _DRM_AGPSUPPORT_H_ */
157