private.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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_PRIVATE_H__
  25. #define __DRM_TEGRA_PRIVATE_H__ 1
  26. #include <stdbool.h>
  27. #include <stddef.h>
  28. #include <stdint.h>
  29. #include <libdrm_macros.h>
  30. #include <xf86atomic.h>
  31. #include "tegra_drm.h"
  32. #include "tegra.h"
  33. #define container_of(ptr, type, member) ({ \
  34. const __typeof__(((type *)0)->member) *__mptr = (ptr); \
  35. (type *)((char *)__mptr - offsetof(type, member)); \
  36. })
  37. enum host1x_class {
  38. HOST1X_CLASS_HOST1X = 0x01,
  39. HOST1X_CLASS_GR2D = 0x51,
  40. HOST1X_CLASS_GR2D_SB = 0x52,
  41. HOST1X_CLASS_VIC = 0x5d,
  42. HOST1X_CLASS_GR3D = 0x60,
  43. };
  44. struct drm_tegra {
  45. bool close;
  46. int fd;
  47. };
  48. struct drm_tegra_bo {
  49. struct drm_tegra *drm;
  50. uint32_t handle;
  51. uint64_t offset;
  52. uint32_t flags;
  53. uint32_t size;
  54. atomic_t ref;
  55. void *map;
  56. };
  57. struct drm_tegra_channel {
  58. struct drm_tegra *drm;
  59. enum host1x_class class;
  60. uint32_t capabilities;
  61. unsigned int version;
  62. uint64_t context;
  63. unsigned int cond_shift;
  64. };
  65. struct drm_tegra_mapping {
  66. struct drm_tegra_channel *channel;
  67. uint32_t id;
  68. };
  69. struct drm_tegra_pushbuf {
  70. struct drm_tegra_job *job;
  71. uint32_t *start;
  72. uint32_t *end;
  73. uint32_t *ptr;
  74. };
  75. void drm_tegra_pushbuf_free(struct drm_tegra_pushbuf *pushbuf);
  76. struct drm_tegra_job {
  77. struct drm_tegra_channel *channel;
  78. struct drm_tegra_pushbuf *pushbuf;
  79. size_t page_size;
  80. struct drm_tegra_submit_cmd *commands;
  81. unsigned int num_commands;
  82. struct drm_tegra_submit_buf *buffers;
  83. unsigned int num_buffers;
  84. struct {
  85. uint32_t id;
  86. uint32_t increments;
  87. uint32_t fence;
  88. } syncpt;
  89. };
  90. struct drm_tegra_submit_cmd *
  91. drm_tegra_job_add_command(struct drm_tegra_job *job, uint32_t type,
  92. uint32_t flags);
  93. struct drm_tegra_syncpoint {
  94. struct drm_tegra *drm;
  95. uint32_t id;
  96. };
  97. #endif /* __DRM_TEGRA_PRIVATE_H__ */