1 #ifndef _DRM_AGPSUPPORT_H_
2 #define _DRM_AGPSUPPORT_H_
3 
4 #include <linux/kernel.h>
5 #include <linux/list.h>
6 #include <linux/mm.h>
7 #include <linux/mutex.h>
8 #include <linux/types.h>
9 #include <linux/kconfig.h>
10 #include <sys/agpio.h>
11 #include <dev/agp/agpvar.h>
12 #include <uapi_drm/drm.h>
13 
14 struct drm_device;
15 struct drm_file;
16 
17 struct drm_agp_head {
18 	device_t	agpdev;
19 	struct agp_info	agp_info;
20 	struct drm_agp_mem *memory;
21 	unsigned long mode;
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 #define CONFIG_AGP 1
31 #if IS_ENABLED(CONFIG_AGP)
32 
33 #ifdef __linux__
34 void drm_free_agp(struct agp_memory * handle, int pages);
35 int drm_bind_agp(struct agp_memory * handle, unsigned int start);
36 int drm_unbind_agp(struct agp_memory * handle);
37 struct agp_memory *drm_agp_bind_pages(struct drm_device *dev,
38 				struct page **pages,
39 				unsigned long num_pages,
40 				uint32_t gtt_offset,
41 				uint32_t type);
42 #endif
43 
44 struct drm_agp_head *drm_agp_init(struct drm_device *dev);
45 void drm_legacy_agp_clear(struct drm_device *dev);
46 int drm_agp_acquire(struct drm_device *dev);
47 int drm_agp_acquire_ioctl(struct drm_device *dev, void *data,
48 			  struct drm_file *file_priv);
49 int drm_agp_release(struct drm_device *dev);
50 int drm_agp_release_ioctl(struct drm_device *dev, void *data,
51 			  struct drm_file *file_priv);
52 int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode);
53 int drm_agp_enable_ioctl(struct drm_device *dev, void *data,
54 			 struct drm_file *file_priv);
55 int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info);
56 int drm_agp_info_ioctl(struct drm_device *dev, void *data,
57 		       struct drm_file *file_priv);
58 int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request);
59 int drm_agp_alloc_ioctl(struct drm_device *dev, void *data,
60 			struct drm_file *file_priv);
61 int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request);
62 int drm_agp_free_ioctl(struct drm_device *dev, void *data,
63 		       struct drm_file *file_priv);
64 int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request);
65 int drm_agp_unbind_ioctl(struct drm_device *dev, void *data,
66 			 struct drm_file *file_priv);
67 int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request);
68 int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
69 		       struct drm_file *file_priv);
70 
71 #else /* CONFIG_AGP */
72 
73 static inline void drm_free_agp(struct agp_memory * handle, int pages)
74 {
75 }
76 
77 static inline int drm_bind_agp(struct agp_memory * handle, unsigned int start)
78 {
79 	return -ENODEV;
80 }
81 
82 static inline int drm_unbind_agp(struct agp_memory * handle)
83 {
84 	return -ENODEV;
85 }
86 
87 static inline struct agp_memory *drm_agp_bind_pages(struct drm_device *dev,
88 					      struct page **pages,
89 					      unsigned long num_pages,
90 					      uint32_t gtt_offset,
91 					      uint32_t type)
92 {
93 	return NULL;
94 }
95 
96 static inline struct drm_agp_head *drm_agp_init(struct drm_device *dev)
97 {
98 	return NULL;
99 }
100 
101 static inline void drm_agp_clear(struct drm_device *dev)
102 {
103 }
104 
105 static inline int drm_agp_acquire(struct drm_device *dev)
106 {
107 	return -ENODEV;
108 }
109 
110 static inline int drm_agp_release(struct drm_device *dev)
111 {
112 	return -ENODEV;
113 }
114 
115 static inline int drm_agp_enable(struct drm_device *dev,
116 				 struct drm_agp_mode mode)
117 {
118 	return -ENODEV;
119 }
120 
121 static inline int drm_agp_info(struct drm_device *dev,
122 			       struct drm_agp_info *info)
123 {
124 	return -ENODEV;
125 }
126 
127 static inline int drm_agp_alloc(struct drm_device *dev,
128 				struct drm_agp_buffer *request)
129 {
130 	return -ENODEV;
131 }
132 
133 static inline int drm_agp_free(struct drm_device *dev,
134 			       struct drm_agp_buffer *request)
135 {
136 	return -ENODEV;
137 }
138 
139 static inline int drm_agp_unbind(struct drm_device *dev,
140 				 struct drm_agp_binding *request)
141 {
142 	return -ENODEV;
143 }
144 
145 static inline int drm_agp_bind(struct drm_device *dev,
146 			       struct drm_agp_binding *request)
147 {
148 	return -ENODEV;
149 }
150 
151 #endif /* CONFIG_AGP */
152 
153 #endif /* _DRM_AGPSUPPORT_H_ */
154