hc
2024-05-10 748e4f3d702def1a4bff191e0cf93b6a05340f01
kernel/include/drm/drm_gem_cma_helper.h
....@@ -2,8 +2,11 @@
22 #ifndef __DRM_GEM_CMA_HELPER_H__
33 #define __DRM_GEM_CMA_HELPER_H__
44
5
-#include <drm/drmP.h>
5
+#include <drm/drm_file.h>
6
+#include <drm/drm_ioctl.h>
67 #include <drm/drm_gem.h>
8
+
9
+struct drm_mode_create_dumb;
710
811 /**
912 * struct drm_gem_cma_object - GEM object backed by CMA memory allocations
....@@ -103,4 +106,90 @@
103106 void *drm_gem_cma_prime_vmap(struct drm_gem_object *obj);
104107 void drm_gem_cma_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
105108
109
+struct drm_gem_object *
110
+drm_gem_cma_create_object_default_funcs(struct drm_device *dev, size_t size);
111
+
112
+/**
113
+ * DRM_GEM_CMA_DRIVER_OPS_WITH_DUMB_CREATE - CMA GEM driver operations
114
+ * @dumb_create_func: callback function for .dumb_create
115
+ *
116
+ * This macro provides a shortcut for setting the default GEM operations in the
117
+ * &drm_driver structure.
118
+ *
119
+ * This macro is a variant of DRM_GEM_CMA_DRIVER_OPS for drivers that
120
+ * override the default implementation of &struct rm_driver.dumb_create. Use
121
+ * DRM_GEM_CMA_DRIVER_OPS if possible. Drivers that require a virtual address
122
+ * on imported buffers should use
123
+ * DRM_GEM_CMA_DRIVER_OPS_VMAP_WITH_DUMB_CREATE() instead.
124
+ */
125
+#define DRM_GEM_CMA_DRIVER_OPS_WITH_DUMB_CREATE(dumb_create_func) \
126
+ .gem_create_object = drm_gem_cma_create_object_default_funcs, \
127
+ .dumb_create = (dumb_create_func), \
128
+ .prime_handle_to_fd = drm_gem_prime_handle_to_fd, \
129
+ .prime_fd_to_handle = drm_gem_prime_fd_to_handle, \
130
+ .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table, \
131
+ .gem_prime_mmap = drm_gem_cma_prime_mmap
132
+
133
+/**
134
+ * DRM_GEM_CMA_DRIVER_OPS - CMA GEM driver operations
135
+ *
136
+ * This macro provides a shortcut for setting the default GEM operations in the
137
+ * &drm_driver structure.
138
+ *
139
+ * Drivers that come with their own implementation of
140
+ * &struct drm_driver.dumb_create should use
141
+ * DRM_GEM_CMA_DRIVER_OPS_WITH_DUMB_CREATE() instead. Use
142
+ * DRM_GEM_CMA_DRIVER_OPS if possible. Drivers that require a virtual address
143
+ * on imported buffers should use DRM_GEM_CMA_DRIVER_OPS_VMAP instead.
144
+ */
145
+#define DRM_GEM_CMA_DRIVER_OPS \
146
+ DRM_GEM_CMA_DRIVER_OPS_WITH_DUMB_CREATE(drm_gem_cma_dumb_create)
147
+
148
+/**
149
+ * DRM_GEM_CMA_DRIVER_OPS_VMAP_WITH_DUMB_CREATE - CMA GEM driver operations
150
+ * ensuring a virtual address
151
+ * on the buffer
152
+ * @dumb_create_func: callback function for .dumb_create
153
+ *
154
+ * This macro provides a shortcut for setting the default GEM operations in the
155
+ * &drm_driver structure for drivers that need the virtual address also on
156
+ * imported buffers.
157
+ *
158
+ * This macro is a variant of DRM_GEM_CMA_DRIVER_OPS_VMAP for drivers that
159
+ * override the default implementation of &struct drm_driver.dumb_create. Use
160
+ * DRM_GEM_CMA_DRIVER_OPS_VMAP if possible. Drivers that do not require a
161
+ * virtual address on imported buffers should use
162
+ * DRM_GEM_CMA_DRIVER_OPS_WITH_DUMB_CREATE() instead.
163
+ */
164
+#define DRM_GEM_CMA_DRIVER_OPS_VMAP_WITH_DUMB_CREATE(dumb_create_func) \
165
+ .gem_create_object = drm_gem_cma_create_object_default_funcs, \
166
+ .dumb_create = dumb_create_func, \
167
+ .prime_handle_to_fd = drm_gem_prime_handle_to_fd, \
168
+ .prime_fd_to_handle = drm_gem_prime_fd_to_handle, \
169
+ .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table_vmap, \
170
+ .gem_prime_mmap = drm_gem_prime_mmap
171
+
172
+/**
173
+ * DRM_GEM_CMA_DRIVER_OPS_VMAP - CMA GEM driver operations ensuring a virtual
174
+ * address on the buffer
175
+ *
176
+ * This macro provides a shortcut for setting the default GEM operations in the
177
+ * &drm_driver structure for drivers that need the virtual address also on
178
+ * imported buffers.
179
+ *
180
+ * Drivers that come with their own implementation of
181
+ * &struct drm_driver.dumb_create should use
182
+ * DRM_GEM_CMA_DRIVER_OPS_VMAP_WITH_DUMB_CREATE() instead. Use
183
+ * DRM_GEM_CMA_DRIVER_OPS_VMAP if possible. Drivers that do not require a
184
+ * virtual address on imported buffers should use DRM_GEM_CMA_DRIVER_OPS
185
+ * instead.
186
+ */
187
+#define DRM_GEM_CMA_DRIVER_OPS_VMAP \
188
+ DRM_GEM_CMA_DRIVER_OPS_VMAP_WITH_DUMB_CREATE(drm_gem_cma_dumb_create)
189
+
190
+struct drm_gem_object *
191
+drm_gem_cma_prime_import_sg_table_vmap(struct drm_device *drm,
192
+ struct dma_buf_attachment *attach,
193
+ struct sg_table *sgt);
194
+
106195 #endif /* __DRM_GEM_CMA_HELPER_H__ */