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; |
| 7 | void *vaddr; |
| 8 | }; |
| 9 | |
| 10 | static inline struct drm_gem_cma_object * |
| 11 | to_drm_gem_cma_obj(struct drm_gem_object *gem_obj) |
| 12 | { |
| 13 | return container_of(gem_obj, struct drm_gem_cma_object, base); |
| 14 | } |
| 15 | |
| 16 | /* free gem object. */ |
| 17 | void drm_gem_cma_free_object(struct drm_gem_object *gem_obj); |
| 18 | |
| 19 | /* create memory region for drm framebuffer. */ |
| 20 | int drm_gem_cma_dumb_create(struct drm_file *file_priv, |
| 21 | struct drm_device *drm, struct drm_mode_create_dumb *args); |
| 22 | |
| 23 | /* map memory region for drm framebuffer to user space. */ |
| 24 | int drm_gem_cma_dumb_map_offset(struct drm_file *file_priv, |
| 25 | struct drm_device *drm, uint32_t handle, uint64_t *offset); |
| 26 | |
| 27 | /* set vm_flags and we can change the vm attribute to other one at here. */ |
| 28 | int drm_gem_cma_mmap(struct file *filp, struct vm_area_struct *vma); |
| 29 | |
| 30 | /* |
| 31 | * destroy memory region allocated. |
| 32 | * - a gem handle and physical memory region pointed by a gem object |
| 33 | * would be released by drm_gem_handle_delete(). |
| 34 | */ |
| 35 | int drm_gem_cma_dumb_destroy(struct drm_file *file_priv, |
| 36 | struct drm_device *drm, unsigned int handle); |
| 37 | |
| 38 | /* allocate physical memory. */ |
| 39 | struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm, |
| 40 | unsigned int size); |
| 41 | |
| 42 | extern const struct vm_operations_struct drm_gem_cma_vm_ops; |
| 43 | |
| 44 | #endif /* __DRM_GEM_CMA_HELPER_H__ */ |