tegra.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * Copyright © 2012, 2013 Thierry Reding
  3. * Copyright © 2013 Erik Faye-Lund
  4. * Copyright © 2014 NVIDIA Corporation
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the "Software"),
  8. * to deal in the Software without restriction, including without limitation
  9. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. * and/or sell copies of the Software, and to permit persons to whom the
  11. * Software is furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  20. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  21. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  22. * OTHER DEALINGS IN THE SOFTWARE.
  23. */
  24. #ifndef __DRM_TEGRA_H__
  25. #define __DRM_TEGRA_H__ 1
  26. #include <stdint.h>
  27. #include <stdlib.h>
  28. #include <tegra_drm.h>
  29. enum drm_tegra_class {
  30. DRM_TEGRA_HOST1X,
  31. DRM_TEGRA_GR2D,
  32. DRM_TEGRA_GR3D,
  33. DRM_TEGRA_VIC,
  34. };
  35. struct drm_tegra_bo;
  36. struct drm_tegra;
  37. int drm_tegra_new(int fd, struct drm_tegra **drmp);
  38. void drm_tegra_close(struct drm_tegra *drm);
  39. int drm_tegra_bo_new(struct drm_tegra *drm, uint32_t flags, uint32_t size,
  40. struct drm_tegra_bo **bop);
  41. int drm_tegra_bo_wrap(struct drm_tegra *drm, uint32_t handle, uint32_t flags,
  42. uint32_t size, struct drm_tegra_bo **bop);
  43. struct drm_tegra_bo *drm_tegra_bo_ref(struct drm_tegra_bo *bo);
  44. void drm_tegra_bo_unref(struct drm_tegra_bo *bo);
  45. int drm_tegra_bo_get_handle(struct drm_tegra_bo *bo, uint32_t *handle);
  46. int drm_tegra_bo_map(struct drm_tegra_bo *bo, void **ptr);
  47. int drm_tegra_bo_unmap(struct drm_tegra_bo *bo);
  48. int drm_tegra_bo_get_name(struct drm_tegra_bo *bo, uint32_t *name);
  49. int drm_tegra_bo_open(struct drm_tegra *drm, uint32_t name, uint32_t flags,
  50. struct drm_tegra_bo **bop);
  51. int drm_tegra_bo_export(struct drm_tegra_bo *bo, uint32_t flags);
  52. int drm_tegra_bo_import(struct drm_tegra *drm, int fd,
  53. struct drm_tegra_bo **bop);
  54. struct drm_tegra_channel;
  55. struct drm_tegra_mapping;
  56. struct drm_tegra_pushbuf;
  57. struct drm_tegra_job;
  58. struct drm_tegra_syncpoint;
  59. enum drm_tegra_sync_cond {
  60. DRM_TEGRA_SYNC_COND_IMMEDIATE,
  61. DRM_TEGRA_SYNC_COND_OP_DONE,
  62. DRM_TEGRA_SYNC_COND_RD_DONE,
  63. DRM_TEGRA_SYNC_COND_WR_SAFE,
  64. DRM_TEGRA_SYNC_COND_MAX,
  65. };
  66. struct drm_tegra_fence {
  67. struct drm_tegra *drm;
  68. uint32_t syncpt;
  69. uint32_t value;
  70. };
  71. int drm_tegra_channel_open(struct drm_tegra *drm,
  72. enum drm_tegra_class client,
  73. struct drm_tegra_channel **channelp);
  74. int drm_tegra_channel_close(struct drm_tegra_channel *channel);
  75. unsigned int drm_tegra_channel_get_version(struct drm_tegra_channel *channel);
  76. int drm_tegra_channel_map(struct drm_tegra_channel *channel,
  77. struct drm_tegra_bo *bo, uint32_t flags,
  78. struct drm_tegra_mapping **mapp);
  79. int drm_tegra_channel_unmap(struct drm_tegra_mapping *map);
  80. int drm_tegra_job_new(struct drm_tegra_channel *channel,
  81. struct drm_tegra_job **jobp);
  82. int drm_tegra_job_free(struct drm_tegra_job *job);
  83. int drm_tegra_job_get_pushbuf(struct drm_tegra_job *job,
  84. struct drm_tegra_pushbuf **pushbufp);
  85. int drm_tegra_job_submit(struct drm_tegra_job *job,
  86. struct drm_tegra_fence *fence);
  87. int drm_tegra_job_wait(struct drm_tegra_job *job, unsigned long timeout);
  88. int drm_tegra_pushbuf_begin(struct drm_tegra_pushbuf *pushbuf,
  89. unsigned int words, uint32_t **ptrp);
  90. int drm_tegra_pushbuf_end(struct drm_tegra_pushbuf *pushbuf, uint32_t *ptr);
  91. int drm_tegra_pushbuf_wait(struct drm_tegra_pushbuf *pushbuf,
  92. struct drm_tegra_syncpoint *syncpt,
  93. uint32_t value);
  94. int drm_tegra_pushbuf_relocate(struct drm_tegra_pushbuf *pushbuf,
  95. uint32_t **ptrp,
  96. struct drm_tegra_mapping *target,
  97. unsigned long offset, unsigned int shift,
  98. uint32_t flags);
  99. int drm_tegra_pushbuf_sync(struct drm_tegra_pushbuf *pushbuf,
  100. struct drm_tegra_syncpoint *syncpt,
  101. unsigned int count);
  102. int drm_tegra_pushbuf_sync_cond(struct drm_tegra_pushbuf *pushbuf,
  103. uint32_t **ptrp,
  104. struct drm_tegra_syncpoint *syncpt,
  105. enum drm_tegra_sync_cond cond);
  106. int drm_tegra_syncpoint_new(struct drm_tegra *drm,
  107. struct drm_tegra_syncpoint **syncptp);
  108. int drm_tegra_syncpoint_free(struct drm_tegra_syncpoint *syncpt);
  109. int drm_tegra_fence_wait(struct drm_tegra_fence *fence, unsigned long timeout);
  110. #endif /* __DRM_TEGRA_H__ */