gem.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. #define TEGRA_BO_BOTTOM_UP (1 << 0)
  16. enum tegra_bo_tiling_mode {
  17. TEGRA_BO_TILING_MODE_PITCH,
  18. TEGRA_BO_TILING_MODE_TILED,
  19. TEGRA_BO_TILING_MODE_BLOCK,
  20. };
  21. struct tegra_bo_tiling {
  22. enum tegra_bo_tiling_mode mode;
  23. unsigned long value;
  24. };
  25. struct tegra_bo {
  26. struct drm_gem_object gem;
  27. struct host1x_bo base;
  28. unsigned long flags;
  29. struct sg_table *sgt;
  30. dma_addr_t paddr;
  31. void *vaddr;
  32. struct tegra_bo_tiling tiling;
  33. };
  34. static inline struct tegra_bo *to_tegra_bo(struct drm_gem_object *gem)
  35. {
  36. return container_of(gem, struct tegra_bo, gem);
  37. }
  38. struct tegra_bo *tegra_bo_create(struct drm_device *drm, unsigned int size,
  39. unsigned long flags);
  40. struct tegra_bo *tegra_bo_create_with_handle(struct drm_file *file,
  41. struct drm_device *drm,
  42. unsigned int size,
  43. unsigned long flags,
  44. unsigned int *handle);
  45. void tegra_bo_free_object(struct drm_gem_object *gem);
  46. int tegra_bo_dumb_create(struct drm_file *file, struct drm_device *drm,
  47. struct drm_mode_create_dumb *args);
  48. int tegra_bo_dumb_map_offset(struct drm_file *file, struct drm_device *drm,
  49. uint32_t handle, uint64_t *offset);
  50. int tegra_drm_mmap(struct file *file, struct vm_area_struct *vma);
  51. extern const struct vm_operations_struct tegra_bo_vm_ops;
  52. struct dma_buf *tegra_gem_prime_export(struct drm_device *drm,
  53. struct drm_gem_object *gem,
  54. int flags);
  55. struct drm_gem_object *tegra_gem_prime_import(struct drm_device *drm,
  56. struct dma_buf *buf);
  57. #endif