Sascha Hauer | b9d4745 | 2012-06-27 15:30:18 +0200 | [diff] [blame] | 1 | #ifndef __DRM_GEM_CMA_HELPER_H__ |
| 2 | #define __DRM_GEM_CMA_HELPER_H__ |
| 3 | |
Shawn Guo | 740c22a | 2014-03-24 20:14:48 +0800 | [diff] [blame] | 4 | #include <drm/drmP.h> |
| 5 | |
Sascha Hauer | b9d4745 | 2012-06-27 15:30:18 +0200 | [diff] [blame] | 6 | struct drm_gem_cma_object { |
| 7 | struct drm_gem_object base; |
| 8 | dma_addr_t paddr; |
Laurent Pinchart | 71d7282 | 2013-02-17 01:57:30 +0100 | [diff] [blame] | 9 | struct sg_table *sgt; |
| 10 | |
| 11 | /* For objects with DMA memory allocated by GEM CMA */ |
Sascha Hauer | b9d4745 | 2012-06-27 15:30:18 +0200 | [diff] [blame] | 12 | void *vaddr; |
| 13 | }; |
| 14 | |
| 15 | static inline struct drm_gem_cma_object * |
| 16 | to_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. */ |
| 22 | void drm_gem_cma_free_object(struct drm_gem_object *gem_obj); |
| 23 | |
| 24 | /* create memory region for drm framebuffer. */ |
| 25 | int 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. */ |
| 29 | int 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. */ |
| 33 | int drm_gem_cma_mmap(struct file *filp, struct vm_area_struct *vma); |
| 34 | |
Sascha Hauer | b9d4745 | 2012-06-27 15:30:18 +0200 | [diff] [blame] | 35 | /* allocate physical memory. */ |
| 36 | struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm, |
| 37 | unsigned int size); |
| 38 | |
| 39 | extern const struct vm_operations_struct drm_gem_cma_vm_ops; |
| 40 | |
Rob Clark | 6f64609 | 2012-12-10 10:46:43 -0600 | [diff] [blame] | 41 | #ifdef CONFIG_DEBUG_FS |
| 42 | void drm_gem_cma_describe(struct drm_gem_cma_object *obj, struct seq_file *m); |
| 43 | #endif |
| 44 | |
Joonyoung Shim | 78467dc | 2013-06-28 14:24:54 +0900 | [diff] [blame] | 45 | struct sg_table *drm_gem_cma_prime_get_sg_table(struct drm_gem_object *obj); |
| 46 | struct drm_gem_object * |
| 47 | drm_gem_cma_prime_import_sg_table(struct drm_device *dev, size_t size, |
| 48 | struct sg_table *sgt); |
| 49 | int drm_gem_cma_prime_mmap(struct drm_gem_object *obj, |
| 50 | struct vm_area_struct *vma); |
| 51 | void *drm_gem_cma_prime_vmap(struct drm_gem_object *obj); |
| 52 | void drm_gem_cma_prime_vunmap(struct drm_gem_object *obj, void *vaddr); |
| 53 | |
Sascha Hauer | b9d4745 | 2012-06-27 15:30:18 +0200 | [diff] [blame] | 54 | #endif /* __DRM_GEM_CMA_HELPER_H__ */ |