msm_vidc_bus.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2020, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef __H_MSM_VIDC_BUS_DEFS_H__
  6. #define __H_MSM_VIDC_BUS_DEFS_H__
  7. #include "fixedpoint.h"
  8. #include "msm_vidc_debug.h"
  9. #include "msm_vidc_internal.h"
  10. #define COMPRESSION_RATIO_MAX 5
  11. enum vidc_bus_type {
  12. PERF,
  13. DDR,
  14. LLCC,
  15. };
  16. /*
  17. * Minimum dimensions for which to calculate bandwidth.
  18. * This means that anything bandwidth(0, 0) ==
  19. * bandwidth(BASELINE_DIMENSIONS.width, BASELINE_DIMENSIONS.height)
  20. */
  21. static const struct {
  22. int height, width;
  23. } BASELINE_DIMENSIONS = {
  24. .width = 1280,
  25. .height = 720,
  26. };
  27. /* converts Mbps to bps (the "b" part can be bits or bytes based on context) */
  28. #define kbps(__mbps) ((__mbps) * 1000)
  29. #define bps(__mbps) (kbps(__mbps) * 1000)
  30. #define GENERATE_COMPRESSION_PROFILE(__bpp, __worst) { \
  31. .bpp = __bpp, \
  32. .ratio = __worst, \
  33. }
  34. /*
  35. * The below table is a structural representation of the following table:
  36. * Resolution | Bitrate | Compression Ratio |
  37. * ............|............|.........................................|
  38. * Width Height|Average High|Avg_8bpc Worst_8bpc Avg_10bpc Worst_10bpc|
  39. * 1280 720| 7 14| 1.69 1.28 1.49 1.23|
  40. * 1920 1080| 20 40| 1.69 1.28 1.49 1.23|
  41. * 2560 1440| 32 64| 2.2 1.26 1.97 1.22|
  42. * 3840 2160| 42 84| 2.2 1.26 1.97 1.22|
  43. * 4096 2160| 44 88| 2.2 1.26 1.97 1.22|
  44. * 4096 2304| 48 96| 2.2 1.26 1.97 1.22|
  45. */
  46. static struct lut {
  47. int frame_size; /* width x height */
  48. int frame_rate;
  49. unsigned long bitrate;
  50. struct {
  51. int bpp;
  52. fp_t ratio;
  53. } compression_ratio[COMPRESSION_RATIO_MAX];
  54. } const LUT[] = {
  55. {
  56. .frame_size = 1280 * 720,
  57. .frame_rate = 30,
  58. .bitrate = 14,
  59. .compression_ratio = {
  60. GENERATE_COMPRESSION_PROFILE(8,
  61. FP(1, 28, 100)),
  62. GENERATE_COMPRESSION_PROFILE(10,
  63. FP(1, 23, 100)),
  64. }
  65. },
  66. {
  67. .frame_size = 1280 * 720,
  68. .frame_rate = 60,
  69. .bitrate = 22,
  70. .compression_ratio = {
  71. GENERATE_COMPRESSION_PROFILE(8,
  72. FP(1, 28, 100)),
  73. GENERATE_COMPRESSION_PROFILE(10,
  74. FP(1, 23, 100)),
  75. }
  76. },
  77. {
  78. .frame_size = 1920 * 1088,
  79. .frame_rate = 30,
  80. .bitrate = 40,
  81. .compression_ratio = {
  82. GENERATE_COMPRESSION_PROFILE(8,
  83. FP(1, 28, 100)),
  84. GENERATE_COMPRESSION_PROFILE(10,
  85. FP(1, 23, 100)),
  86. }
  87. },
  88. {
  89. .frame_size = 1920 * 1088,
  90. .frame_rate = 60,
  91. .bitrate = 64,
  92. .compression_ratio = {
  93. GENERATE_COMPRESSION_PROFILE(8,
  94. FP(1, 28, 100)),
  95. GENERATE_COMPRESSION_PROFILE(10,
  96. FP(1, 23, 100)),
  97. }
  98. },
  99. {
  100. .frame_size = 2560 * 1440,
  101. .frame_rate = 30,
  102. .bitrate = 64,
  103. .compression_ratio = {
  104. GENERATE_COMPRESSION_PROFILE(8,
  105. FP(1, 26, 100)),
  106. GENERATE_COMPRESSION_PROFILE(10,
  107. FP(1, 22, 100)),
  108. }
  109. },
  110. {
  111. .frame_size = 2560 * 1440,
  112. .frame_rate = 60,
  113. .bitrate = 102,
  114. .compression_ratio = {
  115. GENERATE_COMPRESSION_PROFILE(8,
  116. FP(1, 26, 100)),
  117. GENERATE_COMPRESSION_PROFILE(10,
  118. FP(1, 22, 100)),
  119. }
  120. },
  121. {
  122. .frame_size = 3840 * 2160,
  123. .frame_rate = 30,
  124. .bitrate = 84,
  125. .compression_ratio = {
  126. GENERATE_COMPRESSION_PROFILE(8,
  127. FP(1, 26, 100)),
  128. GENERATE_COMPRESSION_PROFILE(10,
  129. FP(1, 22, 100)),
  130. }
  131. },
  132. {
  133. .frame_size = 3840 * 2160,
  134. .frame_rate = 60,
  135. .bitrate = 134,
  136. .compression_ratio = {
  137. GENERATE_COMPRESSION_PROFILE(8,
  138. FP(1, 26, 100)),
  139. GENERATE_COMPRESSION_PROFILE(10,
  140. FP(1, 22, 100)),
  141. }
  142. },
  143. {
  144. .frame_size = 4096 * 2160,
  145. .frame_rate = 30,
  146. .bitrate = 88,
  147. .compression_ratio = {
  148. GENERATE_COMPRESSION_PROFILE(8,
  149. FP(1, 26, 100)),
  150. GENERATE_COMPRESSION_PROFILE(10,
  151. FP(1, 22, 100)),
  152. }
  153. },
  154. {
  155. .frame_size = 4096 * 2160,
  156. .frame_rate = 60,
  157. .bitrate = 141,
  158. .compression_ratio = {
  159. GENERATE_COMPRESSION_PROFILE(8,
  160. FP(1, 26, 100)),
  161. GENERATE_COMPRESSION_PROFILE(10,
  162. FP(1, 22, 100)),
  163. }
  164. },
  165. {
  166. .frame_size = 4096 * 2304,
  167. .frame_rate = 30,
  168. .bitrate = 96,
  169. .compression_ratio = {
  170. GENERATE_COMPRESSION_PROFILE(8,
  171. FP(1, 26, 100)),
  172. GENERATE_COMPRESSION_PROFILE(10,
  173. FP(1, 22, 100)),
  174. }
  175. },
  176. {
  177. .frame_size = 4096 * 2304,
  178. .frame_rate = 60,
  179. .bitrate = 154,
  180. .compression_ratio = {
  181. GENERATE_COMPRESSION_PROFILE(8,
  182. FP(1, 26, 100)),
  183. GENERATE_COMPRESSION_PROFILE(10,
  184. FP(1, 22, 100)),
  185. }
  186. },
  187. };
  188. static inline u32 get_type_frm_name(const char *name)
  189. {
  190. if (!strcmp(name, "venus-llcc"))
  191. return LLCC;
  192. else if (!strcmp(name, "venus-ddr"))
  193. return DDR;
  194. else
  195. return PERF;
  196. }
  197. #define DUMP_HEADER_MAGIC 0xdeadbeef
  198. #define DUMP_FP_FMT "%FP" /* special format for fp_t */
  199. struct dump {
  200. char *key;
  201. char *format;
  202. size_t val;
  203. };
  204. struct lut const *__lut(int width, int height, int fps);
  205. fp_t __compression_ratio(struct lut const *entry, int bpp);
  206. void __dump(struct dump dump[], int len);
  207. static inline bool __ubwc(enum msm_vidc_colorformat_type f)
  208. {
  209. switch (f) {
  210. case MSM_VIDC_FMT_NV12C:
  211. case MSM_VIDC_FMT_TP10C:
  212. return true;
  213. default:
  214. return false;
  215. }
  216. }
  217. static inline int __bpp(enum msm_vidc_colorformat_type f)
  218. {
  219. switch (f) {
  220. case MSM_VIDC_FMT_NV12:
  221. case MSM_VIDC_FMT_NV21:
  222. case MSM_VIDC_FMT_NV12C:
  223. case MSM_VIDC_FMT_RGBA8888C:
  224. return 8;
  225. case MSM_VIDC_FMT_P010:
  226. case MSM_VIDC_FMT_TP10C:
  227. return 10;
  228. default:
  229. d_vpr_e("Unsupported colorformat (%x)", f);
  230. return INT_MAX;
  231. }
  232. }
  233. #endif // __H_MSM_VIDC_BUS_DEFS_H__