drm_gem_cma_helper.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef __DRM_GEM_CMA_HELPER_H__
  2. #define __DRM_GEM_CMA_HELPER_H__
  3. #include <drm/drmP.h>
  4. #include <drm/drm_gem.h>
  5. /**
  6. * struct drm_gem_cma_object - GEM object backed by CMA memory allocations
  7. * @base: base GEM object
  8. * @paddr: physical address of the backing memory
  9. * @sgt: scatter/gather table for imported PRIME buffers
  10. * @vaddr: kernel virtual address of the backing memory
  11. */
  12. struct drm_gem_cma_object {
  13. struct drm_gem_object base;
  14. dma_addr_t paddr;
  15. struct sg_table *sgt;
  16. /* For objects with DMA memory allocated by GEM CMA */
  17. void *vaddr;
  18. };
  19. static inline struct drm_gem_cma_object *
  20. to_drm_gem_cma_obj(struct drm_gem_object *gem_obj)
  21. {
  22. return container_of(gem_obj, struct drm_gem_cma_object, base);
  23. }
  24. /* free GEM object */
  25. void drm_gem_cma_free_object(struct drm_gem_object *gem_obj);
  26. /* create memory region for DRM framebuffer */
  27. int drm_gem_cma_dumb_create_internal(struct drm_file *file_priv,
  28. struct drm_device *drm,
  29. struct drm_mode_create_dumb *args);
  30. /* create memory region for DRM framebuffer */
  31. int drm_gem_cma_dumb_create(struct drm_file *file_priv,
  32. struct drm_device *drm,
  33. struct drm_mode_create_dumb *args);
  34. /* map memory region for DRM framebuffer to user space */
  35. int drm_gem_cma_dumb_map_offset(struct drm_file *file_priv,
  36. struct drm_device *drm, u32 handle,
  37. u64 *offset);
  38. /* set vm_flags and we can change the VM attribute to other one at here */
  39. int drm_gem_cma_mmap(struct file *filp, struct vm_area_struct *vma);
  40. /* allocate physical memory */
  41. struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm,
  42. size_t size);
  43. extern const struct vm_operations_struct drm_gem_cma_vm_ops;
  44. #ifdef CONFIG_DEBUG_FS
  45. void drm_gem_cma_describe(struct drm_gem_cma_object *obj, struct seq_file *m);
  46. #endif
  47. struct sg_table *drm_gem_cma_prime_get_sg_table(struct drm_gem_object *obj);
  48. struct drm_gem_object *
  49. drm_gem_cma_prime_import_sg_table(struct drm_device *dev,
  50. struct dma_buf_attachment *attach,
  51. struct sg_table *sgt);
  52. int drm_gem_cma_prime_mmap(struct drm_gem_object *obj,
  53. struct vm_area_struct *vma);
  54. void *drm_gem_cma_prime_vmap(struct drm_gem_object *obj);
  55. void drm_gem_cma_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
  56. #endif /* __DRM_GEM_CMA_HELPER_H__ */