drm_gem.h (c13aca79ff3c4af5fd31a5b2743a90eba6e36a26) drm_gem.h (b39b5394fabc79acbaafb26b777fd348c868bf7e)
1#ifndef __DRM_GEM_H__
2#define __DRM_GEM_H__
3
4/*
5 * GEM Graphics Execution Manager Driver Interfaces
6 *
7 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
8 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.

--- 24 unchanged lines hidden (view full) ---

33 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
34 * OTHER DEALINGS IN THE SOFTWARE.
35 */
36
37#include <linux/kref.h>
38
39#include <drm/drm_vma_manager.h>
40
1#ifndef __DRM_GEM_H__
2#define __DRM_GEM_H__
3
4/*
5 * GEM Graphics Execution Manager Driver Interfaces
6 *
7 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
8 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.

--- 24 unchanged lines hidden (view full) ---

33 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
34 * OTHER DEALINGS IN THE SOFTWARE.
35 */
36
37#include <linux/kref.h>
38
39#include <drm/drm_vma_manager.h>
40
41struct drm_gem_object;
42
41/**
43/**
44 * struct drm_gem_object_funcs - GEM object functions
45 */
46struct drm_gem_object_funcs {
47 /**
48 * @free:
49 *
50 * Deconstructor for drm_gem_objects.
51 *
52 * This callback is mandatory.
53 */
54 void (*free)(struct drm_gem_object *obj);
55
56 /**
57 * @open:
58 *
59 * Called upon GEM handle creation.
60 *
61 * This callback is optional.
62 */
63 int (*open)(struct drm_gem_object *obj, struct drm_file *file);
64
65 /**
66 * @close:
67 *
68 * Called upon GEM handle release.
69 *
70 * This callback is optional.
71 */
72 void (*close)(struct drm_gem_object *obj, struct drm_file *file);
73
74 /**
75 * @print_info:
76 *
77 * If driver subclasses struct &drm_gem_object, it can implement this
78 * optional hook for printing additional driver specific info.
79 *
80 * drm_printf_indent() should be used in the callback passing it the
81 * indent argument.
82 *
83 * This callback is called from drm_gem_print_info().
84 *
85 * This callback is optional.
86 */
87 void (*print_info)(struct drm_printer *p, unsigned int indent,
88 const struct drm_gem_object *obj);
89
90 /**
91 * @export:
92 *
93 * Export backing buffer as a &dma_buf.
94 * If this is not set drm_gem_prime_export() is used.
95 *
96 * This callback is optional.
97 */
98 struct dma_buf *(*export)(struct drm_gem_object *obj, int flags);
99
100 /**
101 * @pin:
102 *
103 * Pin backing buffer in memory.
104 *
105 * This callback is optional.
106 */
107 int (*pin)(struct drm_gem_object *obj);
108
109 /**
110 * @unpin:
111 *
112 * Unpin backing buffer.
113 *
114 * This callback is optional.
115 */
116 void (*unpin)(struct drm_gem_object *obj);
117
118 /**
119 * @get_sg_table:
120 *
121 * Returns a Scatter-Gather table representation of the buffer.
122 * Used when exporting a buffer.
123 *
124 * This callback is mandatory if buffer export is supported.
125 */
126 struct sg_table *(*get_sg_table)(struct drm_gem_object *obj);
127
128 /**
129 * @vmap:
130 *
131 * Returns a virtual address for the buffer.
132 *
133 * This callback is optional.
134 */
135 void *(*vmap)(struct drm_gem_object *obj);
136
137 /**
138 * @vunmap:
139 *
140 * Releases the the address previously returned by @vmap.
141 *
142 * This callback is optional.
143 */
144 void (*vunmap)(struct drm_gem_object *obj, void *vaddr);
145
146 /**
147 * @vm_ops:
148 *
149 * Virtual memory operations used with mmap.
150 *
151 * This is optional but necessary for mmap support.
152 */
153 const struct vm_operations_struct *vm_ops;
154};
155
156/**
42 * struct drm_gem_object - GEM buffer object
43 *
44 * This structure defines the generic parts for GEM buffer objects, which are
45 * mostly around handling mmap and userspace handles.
46 *
47 * Buffer objects are often abbreviated to BO.
48 */
49struct drm_gem_object {

--- 91 unchanged lines hidden (view full) ---

141 * up the dma_buf attachment and references acquired at import time.
142 *
143 * Note that the drm gem/prime core does not depend upon drivers setting
144 * this field any more. So for drivers where this doesn't make sense
145 * (e.g. virtual devices or a displaylink behind an usb bus) they can
146 * simply leave it as NULL.
147 */
148 struct dma_buf_attachment *import_attach;
157 * struct drm_gem_object - GEM buffer object
158 *
159 * This structure defines the generic parts for GEM buffer objects, which are
160 * mostly around handling mmap and userspace handles.
161 *
162 * Buffer objects are often abbreviated to BO.
163 */
164struct drm_gem_object {

--- 91 unchanged lines hidden (view full) ---

256 * up the dma_buf attachment and references acquired at import time.
257 *
258 * Note that the drm gem/prime core does not depend upon drivers setting
259 * this field any more. So for drivers where this doesn't make sense
260 * (e.g. virtual devices or a displaylink behind an usb bus) they can
261 * simply leave it as NULL.
262 */
263 struct dma_buf_attachment *import_attach;
264
265 /**
266 * @funcs:
267 *
268 * Optional GEM object functions. If this is set, it will be used instead of the
269 * corresponding &drm_driver GEM callbacks.
270 *
271 * New drivers should use this.
272 *
273 */
274 const struct drm_gem_object_funcs *funcs;
149};
150
151/**
152 * DEFINE_DRM_GEM_FOPS() - macro to generate file operations for GEM drivers
153 * @name: name for the generated structure
154 *
155 * This macro autogenerates a suitable &struct file_operations for GEM based
156 * drivers, which can be assigned to &drm_driver.fops. Note that this structure

--- 131 unchanged lines hidden (view full) ---

288
289struct drm_gem_object *drm_gem_object_lookup(struct drm_file *filp, u32 handle);
290int drm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
291 u32 handle, u64 *offset);
292int drm_gem_dumb_destroy(struct drm_file *file,
293 struct drm_device *dev,
294 uint32_t handle);
295
275};
276
277/**
278 * DEFINE_DRM_GEM_FOPS() - macro to generate file operations for GEM drivers
279 * @name: name for the generated structure
280 *
281 * This macro autogenerates a suitable &struct file_operations for GEM based
282 * drivers, which can be assigned to &drm_driver.fops. Note that this structure

--- 131 unchanged lines hidden (view full) ---

414
415struct drm_gem_object *drm_gem_object_lookup(struct drm_file *filp, u32 handle);
416int drm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
417 u32 handle, u64 *offset);
418int drm_gem_dumb_destroy(struct drm_file *file,
419 struct drm_device *dev,
420 uint32_t handle);
421
422int drm_gem_pin(struct drm_gem_object *obj);
423void drm_gem_unpin(struct drm_gem_object *obj);
424void *drm_gem_vmap(struct drm_gem_object *obj);
425void drm_gem_vunmap(struct drm_gem_object *obj, void *vaddr);
426
296#endif /* __DRM_GEM_H__ */
427#endif /* __DRM_GEM_H__ */