mtk_drm_gem.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright (c) 2015 MediaTek Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #ifndef _MTK_DRM_GEM_H_
  14. #define _MTK_DRM_GEM_H_
  15. #include <drm/drm_gem.h>
  16. /*
  17. * mtk drm buffer structure.
  18. *
  19. * @base: a gem object.
  20. * - a new handle to this gem object would be created
  21. * by drm_gem_handle_create().
  22. * @cookie: the return value of dma_alloc_attrs(), keep it for dma_free_attrs()
  23. * @kvaddr: kernel virtual address of gem buffer.
  24. * @dma_addr: dma address of gem buffer.
  25. * @dma_attrs: dma attributes of gem buffer.
  26. *
  27. * P.S. this object would be transferred to user as kms_bo.handle so
  28. * user can access the buffer through kms_bo.handle.
  29. */
  30. struct mtk_drm_gem_obj {
  31. struct drm_gem_object base;
  32. void *cookie;
  33. void *kvaddr;
  34. dma_addr_t dma_addr;
  35. unsigned long dma_attrs;
  36. struct sg_table *sg;
  37. };
  38. #define to_mtk_gem_obj(x) container_of(x, struct mtk_drm_gem_obj, base)
  39. void mtk_drm_gem_free_object(struct drm_gem_object *gem);
  40. struct mtk_drm_gem_obj *mtk_drm_gem_create(struct drm_device *dev, size_t size,
  41. bool alloc_kmap);
  42. int mtk_drm_gem_dumb_create(struct drm_file *file_priv, struct drm_device *dev,
  43. struct drm_mode_create_dumb *args);
  44. int mtk_drm_gem_dumb_map_offset(struct drm_file *file_priv,
  45. struct drm_device *dev, uint32_t handle,
  46. uint64_t *offset);
  47. int mtk_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
  48. int mtk_drm_gem_mmap_buf(struct drm_gem_object *obj,
  49. struct vm_area_struct *vma);
  50. struct sg_table *mtk_gem_prime_get_sg_table(struct drm_gem_object *obj);
  51. struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev,
  52. struct dma_buf_attachment *attach, struct sg_table *sg);
  53. #endif