rockchip_drm_gem.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd
  3. * Author:Mark Yao <mark.yao@rock-chips.com>
  4. *
  5. * This software is licensed under the terms of the GNU General Public
  6. * License version 2, as published by the Free Software Foundation, and
  7. * may be copied, distributed, and modified under those terms.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. */
  14. #ifndef _ROCKCHIP_DRM_GEM_H
  15. #define _ROCKCHIP_DRM_GEM_H
  16. #define to_rockchip_obj(x) container_of(x, struct rockchip_gem_object, base)
  17. struct rockchip_gem_object {
  18. struct drm_gem_object base;
  19. unsigned int flags;
  20. void *kvaddr;
  21. dma_addr_t dma_addr;
  22. /* Used when IOMMU is disabled */
  23. unsigned long dma_attrs;
  24. /* Used when IOMMU is enabled */
  25. struct drm_mm_node mm;
  26. unsigned long num_pages;
  27. struct page **pages;
  28. struct sg_table *sgt;
  29. size_t size;
  30. };
  31. struct sg_table *rockchip_gem_prime_get_sg_table(struct drm_gem_object *obj);
  32. struct drm_gem_object *
  33. rockchip_gem_prime_import_sg_table(struct drm_device *dev,
  34. struct dma_buf_attachment *attach,
  35. struct sg_table *sg);
  36. void *rockchip_gem_prime_vmap(struct drm_gem_object *obj);
  37. void rockchip_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
  38. /* drm driver mmap file operations */
  39. int rockchip_gem_mmap(struct file *filp, struct vm_area_struct *vma);
  40. /* mmap a gem object to userspace. */
  41. int rockchip_gem_mmap_buf(struct drm_gem_object *obj,
  42. struct vm_area_struct *vma);
  43. struct rockchip_gem_object *
  44. rockchip_gem_create_object(struct drm_device *drm, unsigned int size,
  45. bool alloc_kmap);
  46. void rockchip_gem_free_object(struct drm_gem_object *obj);
  47. int rockchip_gem_dumb_create(struct drm_file *file_priv,
  48. struct drm_device *dev,
  49. struct drm_mode_create_dumb *args);
  50. #endif /* _ROCKCHIP_DRM_GEM_H */