blob: 2a3cea91606da6f568f249b85f89130f8f7e89d8 [file] [log] [blame]
Sascha Hauerb9d47452012-06-27 15:30:18 +02001#ifndef __DRM_GEM_CMA_HELPER_H__
2#define __DRM_GEM_CMA_HELPER_H__
3
Shawn Guo740c22a2014-03-24 20:14:48 +08004#include <drm/drmP.h>
5
Sascha Hauerb9d47452012-06-27 15:30:18 +02006struct drm_gem_cma_object {
7 struct drm_gem_object base;
8 dma_addr_t paddr;
Laurent Pinchart71d72822013-02-17 01:57:30 +01009 struct sg_table *sgt;
10
11 /* For objects with DMA memory allocated by GEM CMA */
Sascha Hauerb9d47452012-06-27 15:30:18 +020012 void *vaddr;
13};
14
15static inline struct drm_gem_cma_object *
16to_drm_gem_cma_obj(struct drm_gem_object *gem_obj)
17{
18 return container_of(gem_obj, struct drm_gem_cma_object, base);
19}
20
21/* free gem object. */
22void drm_gem_cma_free_object(struct drm_gem_object *gem_obj);
23
24/* create memory region for drm framebuffer. */
25int drm_gem_cma_dumb_create(struct drm_file *file_priv,
26 struct drm_device *drm, struct drm_mode_create_dumb *args);
27
28/* map memory region for drm framebuffer to user space. */
29int drm_gem_cma_dumb_map_offset(struct drm_file *file_priv,
30 struct drm_device *drm, uint32_t handle, uint64_t *offset);
31
32/* set vm_flags and we can change the vm attribute to other one at here. */
33int drm_gem_cma_mmap(struct file *filp, struct vm_area_struct *vma);
34
Sascha Hauerb9d47452012-06-27 15:30:18 +020035/* allocate physical memory. */
36struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm,
37 unsigned int size);
38
39extern const struct vm_operations_struct drm_gem_cma_vm_ops;
40
Rob Clark6f646092012-12-10 10:46:43 -060041#ifdef CONFIG_DEBUG_FS
42void drm_gem_cma_describe(struct drm_gem_cma_object *obj, struct seq_file *m);
43#endif
44
Joonyoung Shim78467dc2013-06-28 14:24:54 +090045struct sg_table *drm_gem_cma_prime_get_sg_table(struct drm_gem_object *obj);
46struct drm_gem_object *
47drm_gem_cma_prime_import_sg_table(struct drm_device *dev, size_t size,
48 struct sg_table *sgt);
49int drm_gem_cma_prime_mmap(struct drm_gem_object *obj,
50 struct vm_area_struct *vma);
51void *drm_gem_cma_prime_vmap(struct drm_gem_object *obj);
52void drm_gem_cma_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
53
Sascha Hauerb9d47452012-06-27 15:30:18 +020054#endif /* __DRM_GEM_CMA_HELPER_H__ */