gem.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. struct tegra_bo *tegra_bo_create(struct drm_device *drm, size_t size,
  45. unsigned long flags);
  46. struct tegra_bo *tegra_bo_create_with_handle(struct drm_file *file,
  47. struct drm_device *drm,
  48. size_t size,
  49. unsigned long flags,
  50. u32 *handle);
  51. void tegra_bo_free_object(struct drm_gem_object *gem);
  52. int tegra_bo_dumb_create(struct drm_file *file, struct drm_device *drm,
  53. struct drm_mode_create_dumb *args);
  54. int tegra_bo_dumb_map_offset(struct drm_file *file, struct drm_device *drm,
  55. u32 handle, u64 *offset);
  56. int tegra_drm_mmap(struct file *file, struct vm_area_struct *vma);
  57. extern const struct vm_operations_struct tegra_bo_vm_ops;
  58. struct dma_buf *tegra_gem_prime_export(struct drm_device *drm,
  59. struct drm_gem_object *gem,
  60. int flags);
  61. struct drm_gem_object *tegra_gem_prime_import(struct drm_device *drm,
  62. struct dma_buf *buf);
  63. #endif