1
0

vic.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*
  2. * Copyright © 2018 NVIDIA Corporation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. */
  22. #ifndef VIC_H
  23. #define VIC_H
  24. #include <stdio.h>
  25. #include "host1x.h"
  26. #define DXVAHD_FRAME_FORMAT_PROGRESSIVE 0
  27. #define DXVAHD_FRAME_FORMAT_INTERLACED_TOP_FIELD_FIRST 1
  28. #define DXVAHD_FRAME_FORMAT_INTERLACED_BOTTOM_FIELD_FIRST 2
  29. #define DXVAHD_FRAME_FORMAT_TOP_FIELD 3
  30. #define DXVAHD_FRAME_FORMAT_BOTTOM_FIELD 4
  31. #define DXVAHD_FRAME_FORMAT_SUBPIC_PROGRESSIVE 5
  32. #define DXVAHD_FRAME_FORMAT_SUBPIC_INTERLACED_TOP_FIELD_FIRST 6
  33. #define DXVAHD_FRAME_FORMAT_SUBPIC_INTERLACED_BOTTOM_FIELD_FIRST 7
  34. #define DXVAHD_FRAME_FORMAT_SUBPIC_TOP_FIELD 8
  35. #define DXVAHD_FRAME_FORMAT_SUBPIC_BOTTOM_FIELD 9
  36. #define DXVAHD_FRAME_FORMAT_TOP_FIELD_CHROMA_BOTTOM 10
  37. #define DXVAHD_FRAME_FORMAT_BOTTOM_FIELD_CHROMA_TOP 11
  38. #define DXVAHD_FRAME_FORMAT_SUBPIC_TOP_FIELD_CHROMA_BOTTOM 12
  39. #define DXVAHD_FRAME_FORMAT_SUBPIC_BOTTOM_FIELD_CHROMA_TOP 13
  40. #define DXVAHD_ALPHA_FILL_MODE_OPAQUE 0
  41. #define DXVAHD_ALPHA_FILL_MODE_BACKGROUND 1
  42. #define DXVAHD_ALPHA_FILL_MODE_DESTINATION 2
  43. #define DXVAHD_ALPHA_FILL_MODE_SOURCE_STREAM 3
  44. #define DXVAHD_ALPHA_FILL_MODE_COMPOSITED 4
  45. #define DXVAHD_ALPHA_FILL_MODE_SOURCE_ALPHA 5
  46. #define VIC_BLEND_SRCFACTC_K1 0
  47. #define VIC_BLEND_SRCFACTC_K1_TIMES_DST 1
  48. #define VIC_BLEND_SRCFACTC_NEG_K1_TIMES_DST 2
  49. #define VIC_BLEND_SRCFACTC_K1_TIMES_SRC 3
  50. #define VIC_BLEND_SRCFACTC_ZERO 4
  51. #define VIC_BLEND_DSTFACTC_K1 0
  52. #define VIC_BLEND_DSTFACTC_K2 1
  53. #define VIC_BLEND_DSTFACTC_K1_TIMES_DST 2
  54. #define VIC_BLEND_DSTFACTC_NEG_K1_TIMES_DST 3
  55. #define VIC_BLEND_DSTFACTC_NEG_K1_TIMES_SRC 4
  56. #define VIC_BLEND_DSTFACTC_ZERO 5
  57. #define VIC_BLEND_DSTFACTC_ONE 6
  58. #define VIC_BLEND_SRCFACTA_K1 0
  59. #define VIC_BLEND_SRCFACTA_K2 1
  60. #define VIC_BLEND_SRCFACTA_NEG_K1_TIMES_DST 2
  61. #define VIC_BLEND_SRCFACTA_ZERO 3
  62. #define VIC_BLEND_DSTFACTA_K2 0
  63. #define VIC_BLEND_DSTFACTA_NEG_K1_TIMES_SRC 1
  64. #define VIC_BLEND_DSTFACTA_ZERO 2
  65. #define VIC_BLEND_DSTFACTA_ONE 3
  66. #define VIC_BLK_KIND_PITCH 0
  67. #define VIC_BLK_KIND_GENERIC_16Bx2 1
  68. #define VIC_PIXEL_FORMAT_L8 1
  69. #define VIC_PIXEL_FORMAT_R8 4
  70. #define VIC_PIXEL_FORMAT_A8R8G8B8 32
  71. #define VIC_PIXEL_FORMAT_R8G8B8A8 34
  72. #define VIC_PIXEL_FORMAT_Y8_U8V8_N420 67
  73. #define VIC_PIXEL_FORMAT_Y8_V8U8_N420 68
  74. #define VIC_CACHE_WIDTH_16Bx16 0 /* BL16Bx2 */
  75. #define VIC_CACHE_WIDTH_32Bx8 1 /* BL16Bx2 */
  76. #define VIC_CACHE_WIDTH_64Bx4 2 /* BL16Bx2, PL */
  77. #define VIC_CACHE_WIDTH_128Bx2 3 /* BL16Bx2, PL */
  78. #define VIC_CACHE_WIDTH_256Bx1 4 /* PL */
  79. struct vic_format_info {
  80. unsigned int format;
  81. unsigned int cpp;
  82. };
  83. #define VIC_UCLASS_INCR_SYNCPT 0x00
  84. #define VIC_UCLASS_METHOD_OFFSET 0x10
  85. #define VIC_UCLASS_METHOD_DATA 0x11
  86. static inline void VIC_PUSH_METHOD(struct drm_tegra_pushbuf *pushbuf,
  87. uint32_t **ptrp, uint32_t method,
  88. uint32_t value)
  89. {
  90. *(*ptrp)++ = HOST1X_OPCODE_INCR(VIC_UCLASS_METHOD_OFFSET, 2);
  91. *(*ptrp)++ = method >> 2;
  92. *(*ptrp)++ = value;
  93. }
  94. static inline void VIC_PUSH_BUFFER(struct drm_tegra_pushbuf *pushbuf,
  95. uint32_t **ptrp, uint32_t method,
  96. struct drm_tegra_mapping *map,
  97. unsigned long offset, unsigned long flags)
  98. {
  99. *(*ptrp)++ = HOST1X_OPCODE_INCR(VIC_UCLASS_METHOD_OFFSET, 2);
  100. *(*ptrp)++ = method >> 2;
  101. drm_tegra_pushbuf_relocate(pushbuf, ptrp, map, offset, 8, flags);
  102. }
  103. struct vic_image;
  104. struct vic;
  105. struct vic_ops {
  106. int (*fill)(struct vic *vic, struct vic_image *output,
  107. unsigned int left, unsigned int top,
  108. unsigned int right, unsigned int bottom,
  109. unsigned int alpha, unsigned red,
  110. unsigned int green, unsigned int blue);
  111. int (*blit)(struct vic *vic, struct vic_image *output,
  112. struct vic_image *input);
  113. int (*flip)(struct vic *vic, struct vic_image *output,
  114. struct vic_image *input);
  115. int (*execute)(struct vic *vic,
  116. struct drm_tegra_pushbuf *pushbuf,
  117. uint32_t **ptrp,
  118. struct vic_image *output,
  119. struct vic_image **inputs,
  120. unsigned int num_inputs);
  121. void (*free)(struct vic *vic);
  122. };
  123. struct vic {
  124. struct drm_tegra *drm;
  125. struct drm_tegra_channel *channel;
  126. struct drm_tegra_syncpoint *syncpt;
  127. const struct vic_ops *ops;
  128. unsigned int version;
  129. };
  130. int vic_new(struct drm_tegra *drm, struct drm_tegra_channel *channel,
  131. struct vic **vicp);
  132. void vic_free(struct vic *vic);
  133. int vic_clear(struct vic *vic, struct vic_image *output, unsigned int alpha,
  134. unsigned int red, unsigned int green, unsigned int blue);
  135. struct vic_image {
  136. struct drm_tegra_bo *bo;
  137. struct drm_tegra_mapping *map;
  138. unsigned int width;
  139. unsigned int stride;
  140. unsigned int pitch;
  141. unsigned int height;
  142. unsigned int format;
  143. unsigned int kind;
  144. size_t align;
  145. size_t size;
  146. };
  147. const struct vic_format_info *vic_format_get_info(unsigned int format);
  148. int vic_image_new(struct vic *vic, unsigned int width, unsigned int height,
  149. unsigned int format, unsigned int kind, uint32_t flags,
  150. struct vic_image **imagep);
  151. void vic_image_free(struct vic_image *image);
  152. void vic_image_dump(struct vic_image *image, FILE *fp);
  153. #endif