gem.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 tegra_bo_tiling tiling;
  34. };
  35. static inline struct tegra_bo *to_tegra_bo(struct drm_gem_object *gem)
  36. {
  37. return container_of(gem, struct tegra_bo, gem);
  38. }
  39. struct tegra_bo *tegra_bo_create(struct drm_device *drm, unsigned int size,
  40. unsigned long flags);
  41. struct tegra_bo *tegra_bo_create_with_handle(struct drm_file *file,
  42. struct drm_device *drm,
  43. unsigned int size,
  44. unsigned long flags,
  45. unsigned int *handle);
  46. void tegra_bo_free_object(struct drm_gem_object *gem);
  47. int tegra_bo_dumb_create(struct drm_file *file, struct drm_device *drm,
  48. struct drm_mode_create_dumb *args);
  49. int tegra_bo_dumb_map_offset(struct drm_file *file, struct drm_device *drm,
  50. uint32_t handle, uint64_t *offset);
  51. int tegra_drm_mmap(struct file *file, struct vm_area_struct *vma);
  52. extern const struct vm_operations_struct tegra_bo_vm_ops;
  53. struct dma_buf *tegra_gem_prime_export(struct drm_device *drm,
  54. struct drm_gem_object *gem,
  55. int flags);
  56. struct drm_gem_object *tegra_gem_prime_import(struct drm_device *drm,
  57. struct dma_buf *buf);
  58. #endif