gem.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Tegra host1x GEM implementation
  3. *
  4. * Copyright (c) 2012-2013, NVIDIA Corporation.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #ifndef __HOST1X_GEM_H
  11. #define __HOST1X_GEM_H
  12. #include <linux/host1x.h>
  13. #include <drm/drm.h>
  14. #include <drm/drmP.h>
  15. #include <drm/drm_gem.h>
  16. #define TEGRA_BO_BOTTOM_UP (1 << 0)
  17. enum tegra_bo_tiling_mode {
  18. TEGRA_BO_TILING_MODE_PITCH,
  19. TEGRA_BO_TILING_MODE_TILED,
  20. TEGRA_BO_TILING_MODE_BLOCK,
  21. };
  22. struct tegra_bo_tiling {
  23. enum tegra_bo_tiling_mode mode;
  24. unsigned long value;
  25. };
  26. struct tegra_bo {
  27. struct drm_gem_object gem;
  28. struct host1x_bo base;
  29. unsigned long flags;
  30. struct sg_table *sgt;
  31. dma_addr_t paddr;
  32. void *vaddr;
  33. struct drm_mm_node *mm;
  34. unsigned long num_pages;
  35. struct page **pages;
  36. /* size of IOMMU mapping */
  37. size_t size;
  38. struct tegra_bo_tiling tiling;
  39. };
  40. static inline struct tegra_bo *to_tegra_bo(struct drm_gem_object *gem)
  41. {
  42. return container_of(gem, struct tegra_bo, gem);
  43. }
  44. static inline struct tegra_bo *host1x_to_tegra_bo(struct host1x_bo *bo)
  45. {
  46. return container_of(bo, struct tegra_bo, base);
  47. }
  48. struct tegra_bo *tegra_bo_create(struct drm_device *drm, size_t size,
  49. unsigned long flags);
  50. struct tegra_bo *tegra_bo_create_with_handle(struct drm_file *file,
  51. struct drm_device *drm,
  52. size_t size,
  53. unsigned long flags,
  54. u32 *handle);
  55. void tegra_bo_free_object(struct drm_gem_object *gem);
  56. int tegra_bo_dumb_create(struct drm_file *file, struct drm_device *drm,
  57. struct drm_mode_create_dumb *args);
  58. extern const struct vm_operations_struct tegra_bo_vm_ops;
  59. int __tegra_gem_mmap(struct drm_gem_object *gem, struct vm_area_struct *vma);
  60. int tegra_drm_mmap(struct file *file, struct vm_area_struct *vma);
  61. struct dma_buf *tegra_gem_prime_export(struct drm_device *drm,
  62. struct drm_gem_object *gem,
  63. int flags);
  64. struct drm_gem_object *tegra_gem_prime_import(struct drm_device *drm,
  65. struct dma_buf *buf);
  66. #endif