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 | |
| 4 | struct drm_gem_cma_object { |
| 5 | struct drm_gem_object base; |
| 6 | dma_addr_t paddr; |
Laurent Pinchart | 71d7282 | 2013-02-17 01:57:30 +0100 | [diff] [blame] | 7 | struct sg_table *sgt; |
| 8 | |
| 9 | /* For objects with DMA memory allocated by GEM CMA */ |
Sascha Hauer | b9d4745 | 2012-06-27 15:30:18 +0200 | [diff] [blame] | 10 | void *vaddr; |
| 11 | }; |
| 12 | |
| 13 | static inline struct drm_gem_cma_object * |
| 14 | to_drm_gem_cma_obj(struct drm_gem_object *gem_obj) |
| 15 | { |
| 16 | return container_of(gem_obj, struct drm_gem_cma_object, base); |
| 17 | } |
| 18 | |
| 19 | /* free gem object. */ |
| 20 | void drm_gem_cma_free_object(struct drm_gem_object *gem_obj); |
| 21 | |
| 22 | /* create memory region for drm framebuffer. */ |
| 23 | int drm_gem_cma_dumb_create(struct drm_file *file_priv, |
| 24 | struct drm_device *drm, struct drm_mode_create_dumb *args); |
| 25 | |
| 26 | /* map memory region for drm framebuffer to user space. */ |
| 27 | int drm_gem_cma_dumb_map_offset(struct drm_file *file_priv, |
| 28 | struct drm_device *drm, uint32_t handle, uint64_t *offset); |
| 29 | |
| 30 | /* set vm_flags and we can change the vm attribute to other one at here. */ |
| 31 | int drm_gem_cma_mmap(struct file *filp, struct vm_area_struct *vma); |
| 32 | |
Sascha Hauer | b9d4745 | 2012-06-27 15:30:18 +0200 | [diff] [blame] | 33 | /* allocate physical memory. */ |
| 34 | struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm, |
| 35 | unsigned int size); |
| 36 | |
| 37 | extern const struct vm_operations_struct drm_gem_cma_vm_ops; |
| 38 | |
Rob Clark | 6f64609 | 2012-12-10 10:46:43 -0600 | [diff] [blame] | 39 | #ifdef CONFIG_DEBUG_FS |
| 40 | void drm_gem_cma_describe(struct drm_gem_cma_object *obj, struct seq_file *m); |
| 41 | #endif |
| 42 | |
Joonyoung Shim | 78467dc | 2013-06-28 14:24:54 +0900 | [diff] [blame] | 43 | struct sg_table *drm_gem_cma_prime_get_sg_table(struct drm_gem_object *obj); |
| 44 | struct drm_gem_object * |
| 45 | drm_gem_cma_prime_import_sg_table(struct drm_device *dev, size_t size, |
| 46 | struct sg_table *sgt); |
| 47 | int drm_gem_cma_prime_mmap(struct drm_gem_object *obj, |
| 48 | struct vm_area_struct *vma); |
| 49 | void *drm_gem_cma_prime_vmap(struct drm_gem_object *obj); |
| 50 | void drm_gem_cma_prime_vunmap(struct drm_gem_object *obj, void *vaddr); |
| 51 | |
Sascha Hauer | b9d4745 | 2012-06-27 15:30:18 +0200 | [diff] [blame] | 52 | #endif /* __DRM_GEM_CMA_HELPER_H__ */ |