dpu_hw_mdss.h 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #ifndef _DPU_HW_MDSS_H
  13. #define _DPU_HW_MDSS_H
  14. #include <linux/kernel.h>
  15. #include <linux/err.h>
  16. #include "msm_drv.h"
  17. #define DPU_DBG_NAME "dpu"
  18. #define DPU_NONE 0
  19. #ifndef DPU_CSC_MATRIX_COEFF_SIZE
  20. #define DPU_CSC_MATRIX_COEFF_SIZE 9
  21. #endif
  22. #ifndef DPU_CSC_CLAMP_SIZE
  23. #define DPU_CSC_CLAMP_SIZE 6
  24. #endif
  25. #ifndef DPU_CSC_BIAS_SIZE
  26. #define DPU_CSC_BIAS_SIZE 3
  27. #endif
  28. #ifndef DPU_MAX_PLANES
  29. #define DPU_MAX_PLANES 4
  30. #endif
  31. #define PIPES_PER_STAGE 2
  32. #ifndef DPU_MAX_DE_CURVES
  33. #define DPU_MAX_DE_CURVES 3
  34. #endif
  35. enum dpu_format_flags {
  36. DPU_FORMAT_FLAG_YUV_BIT,
  37. DPU_FORMAT_FLAG_DX_BIT,
  38. DPU_FORMAT_FLAG_COMPRESSED_BIT,
  39. DPU_FORMAT_FLAG_BIT_MAX,
  40. };
  41. #define DPU_FORMAT_FLAG_YUV BIT(DPU_FORMAT_FLAG_YUV_BIT)
  42. #define DPU_FORMAT_FLAG_DX BIT(DPU_FORMAT_FLAG_DX_BIT)
  43. #define DPU_FORMAT_FLAG_COMPRESSED BIT(DPU_FORMAT_FLAG_COMPRESSED_BIT)
  44. #define DPU_FORMAT_IS_YUV(X) \
  45. (test_bit(DPU_FORMAT_FLAG_YUV_BIT, (X)->flag))
  46. #define DPU_FORMAT_IS_DX(X) \
  47. (test_bit(DPU_FORMAT_FLAG_DX_BIT, (X)->flag))
  48. #define DPU_FORMAT_IS_LINEAR(X) ((X)->fetch_mode == DPU_FETCH_LINEAR)
  49. #define DPU_FORMAT_IS_TILE(X) \
  50. (((X)->fetch_mode == DPU_FETCH_UBWC) && \
  51. !test_bit(DPU_FORMAT_FLAG_COMPRESSED_BIT, (X)->flag))
  52. #define DPU_FORMAT_IS_UBWC(X) \
  53. (((X)->fetch_mode == DPU_FETCH_UBWC) && \
  54. test_bit(DPU_FORMAT_FLAG_COMPRESSED_BIT, (X)->flag))
  55. #define DPU_BLEND_FG_ALPHA_FG_CONST (0 << 0)
  56. #define DPU_BLEND_FG_ALPHA_BG_CONST (1 << 0)
  57. #define DPU_BLEND_FG_ALPHA_FG_PIXEL (2 << 0)
  58. #define DPU_BLEND_FG_ALPHA_BG_PIXEL (3 << 0)
  59. #define DPU_BLEND_FG_INV_ALPHA (1 << 2)
  60. #define DPU_BLEND_FG_MOD_ALPHA (1 << 3)
  61. #define DPU_BLEND_FG_INV_MOD_ALPHA (1 << 4)
  62. #define DPU_BLEND_FG_TRANSP_EN (1 << 5)
  63. #define DPU_BLEND_BG_ALPHA_FG_CONST (0 << 8)
  64. #define DPU_BLEND_BG_ALPHA_BG_CONST (1 << 8)
  65. #define DPU_BLEND_BG_ALPHA_FG_PIXEL (2 << 8)
  66. #define DPU_BLEND_BG_ALPHA_BG_PIXEL (3 << 8)
  67. #define DPU_BLEND_BG_INV_ALPHA (1 << 10)
  68. #define DPU_BLEND_BG_MOD_ALPHA (1 << 11)
  69. #define DPU_BLEND_BG_INV_MOD_ALPHA (1 << 12)
  70. #define DPU_BLEND_BG_TRANSP_EN (1 << 13)
  71. #define DPU_VSYNC0_SOURCE_GPIO 0
  72. #define DPU_VSYNC1_SOURCE_GPIO 1
  73. #define DPU_VSYNC2_SOURCE_GPIO 2
  74. #define DPU_VSYNC_SOURCE_INTF_0 3
  75. #define DPU_VSYNC_SOURCE_INTF_1 4
  76. #define DPU_VSYNC_SOURCE_INTF_2 5
  77. #define DPU_VSYNC_SOURCE_INTF_3 6
  78. #define DPU_VSYNC_SOURCE_WD_TIMER_4 11
  79. #define DPU_VSYNC_SOURCE_WD_TIMER_3 12
  80. #define DPU_VSYNC_SOURCE_WD_TIMER_2 13
  81. #define DPU_VSYNC_SOURCE_WD_TIMER_1 14
  82. #define DPU_VSYNC_SOURCE_WD_TIMER_0 15
  83. enum dpu_hw_blk_type {
  84. DPU_HW_BLK_TOP = 0,
  85. DPU_HW_BLK_SSPP,
  86. DPU_HW_BLK_LM,
  87. DPU_HW_BLK_CTL,
  88. DPU_HW_BLK_PINGPONG,
  89. DPU_HW_BLK_INTF,
  90. DPU_HW_BLK_WB,
  91. DPU_HW_BLK_MAX,
  92. };
  93. enum dpu_mdp {
  94. MDP_TOP = 0x1,
  95. MDP_MAX,
  96. };
  97. enum dpu_sspp {
  98. SSPP_NONE,
  99. SSPP_VIG0,
  100. SSPP_VIG1,
  101. SSPP_VIG2,
  102. SSPP_VIG3,
  103. SSPP_RGB0,
  104. SSPP_RGB1,
  105. SSPP_RGB2,
  106. SSPP_RGB3,
  107. SSPP_DMA0,
  108. SSPP_DMA1,
  109. SSPP_DMA2,
  110. SSPP_DMA3,
  111. SSPP_CURSOR0,
  112. SSPP_CURSOR1,
  113. SSPP_MAX
  114. };
  115. enum dpu_sspp_type {
  116. SSPP_TYPE_VIG,
  117. SSPP_TYPE_RGB,
  118. SSPP_TYPE_DMA,
  119. SSPP_TYPE_CURSOR,
  120. SSPP_TYPE_MAX
  121. };
  122. enum dpu_lm {
  123. LM_0 = 1,
  124. LM_1,
  125. LM_2,
  126. LM_3,
  127. LM_4,
  128. LM_5,
  129. LM_6,
  130. LM_MAX
  131. };
  132. enum dpu_stage {
  133. DPU_STAGE_BASE = 0,
  134. DPU_STAGE_0,
  135. DPU_STAGE_1,
  136. DPU_STAGE_2,
  137. DPU_STAGE_3,
  138. DPU_STAGE_4,
  139. DPU_STAGE_5,
  140. DPU_STAGE_6,
  141. DPU_STAGE_7,
  142. DPU_STAGE_8,
  143. DPU_STAGE_9,
  144. DPU_STAGE_10,
  145. DPU_STAGE_MAX
  146. };
  147. enum dpu_dspp {
  148. DSPP_0 = 1,
  149. DSPP_1,
  150. DSPP_2,
  151. DSPP_3,
  152. DSPP_MAX
  153. };
  154. enum dpu_ctl {
  155. CTL_0 = 1,
  156. CTL_1,
  157. CTL_2,
  158. CTL_3,
  159. CTL_4,
  160. CTL_MAX
  161. };
  162. enum dpu_pingpong {
  163. PINGPONG_0 = 1,
  164. PINGPONG_1,
  165. PINGPONG_2,
  166. PINGPONG_3,
  167. PINGPONG_4,
  168. PINGPONG_S0,
  169. PINGPONG_MAX
  170. };
  171. enum dpu_intf {
  172. INTF_0 = 1,
  173. INTF_1,
  174. INTF_2,
  175. INTF_3,
  176. INTF_4,
  177. INTF_5,
  178. INTF_6,
  179. INTF_MAX
  180. };
  181. enum dpu_intf_type {
  182. INTF_NONE = 0x0,
  183. INTF_DSI = 0x1,
  184. INTF_HDMI = 0x3,
  185. INTF_LCDC = 0x5,
  186. INTF_EDP = 0x9,
  187. INTF_DP = 0xa,
  188. INTF_TYPE_MAX,
  189. /* virtual interfaces */
  190. INTF_WB = 0x100,
  191. };
  192. enum dpu_intf_mode {
  193. INTF_MODE_NONE = 0,
  194. INTF_MODE_CMD,
  195. INTF_MODE_VIDEO,
  196. INTF_MODE_WB_BLOCK,
  197. INTF_MODE_WB_LINE,
  198. INTF_MODE_MAX
  199. };
  200. enum dpu_wb {
  201. WB_0 = 1,
  202. WB_1,
  203. WB_2,
  204. WB_3,
  205. WB_MAX
  206. };
  207. enum dpu_cwb {
  208. CWB_0 = 0x1,
  209. CWB_1,
  210. CWB_2,
  211. CWB_3,
  212. CWB_MAX
  213. };
  214. enum dpu_wd_timer {
  215. WD_TIMER_0 = 0x1,
  216. WD_TIMER_1,
  217. WD_TIMER_2,
  218. WD_TIMER_3,
  219. WD_TIMER_4,
  220. WD_TIMER_5,
  221. WD_TIMER_MAX
  222. };
  223. enum dpu_vbif {
  224. VBIF_0,
  225. VBIF_1,
  226. VBIF_MAX,
  227. VBIF_RT = VBIF_0,
  228. VBIF_NRT = VBIF_1
  229. };
  230. enum dpu_iommu_domain {
  231. DPU_IOMMU_DOMAIN_UNSECURE,
  232. DPU_IOMMU_DOMAIN_SECURE,
  233. DPU_IOMMU_DOMAIN_MAX
  234. };
  235. /**
  236. * DPU HW,Component order color map
  237. */
  238. enum {
  239. C0_G_Y = 0,
  240. C1_B_Cb = 1,
  241. C2_R_Cr = 2,
  242. C3_ALPHA = 3
  243. };
  244. /**
  245. * enum dpu_plane_type - defines how the color component pixel packing
  246. * @DPU_PLANE_INTERLEAVED : Color components in single plane
  247. * @DPU_PLANE_PLANAR : Color component in separate planes
  248. * @DPU_PLANE_PSEUDO_PLANAR : Chroma components interleaved in separate plane
  249. */
  250. enum dpu_plane_type {
  251. DPU_PLANE_INTERLEAVED,
  252. DPU_PLANE_PLANAR,
  253. DPU_PLANE_PSEUDO_PLANAR,
  254. };
  255. /**
  256. * enum dpu_chroma_samp_type - chroma sub-samplng type
  257. * @DPU_CHROMA_RGB : No chroma subsampling
  258. * @DPU_CHROMA_H2V1 : Chroma pixels are horizontally subsampled
  259. * @DPU_CHROMA_H1V2 : Chroma pixels are vertically subsampled
  260. * @DPU_CHROMA_420 : 420 subsampling
  261. */
  262. enum dpu_chroma_samp_type {
  263. DPU_CHROMA_RGB,
  264. DPU_CHROMA_H2V1,
  265. DPU_CHROMA_H1V2,
  266. DPU_CHROMA_420
  267. };
  268. /**
  269. * dpu_fetch_type - Defines How DPU HW fetches data
  270. * @DPU_FETCH_LINEAR : fetch is line by line
  271. * @DPU_FETCH_TILE : fetches data in Z order from a tile
  272. * @DPU_FETCH_UBWC : fetch and decompress data
  273. */
  274. enum dpu_fetch_type {
  275. DPU_FETCH_LINEAR,
  276. DPU_FETCH_TILE,
  277. DPU_FETCH_UBWC
  278. };
  279. /**
  280. * Value of enum chosen to fit the number of bits
  281. * expected by the HW programming.
  282. */
  283. enum {
  284. COLOR_ALPHA_1BIT = 0,
  285. COLOR_ALPHA_4BIT = 1,
  286. COLOR_4BIT = 0,
  287. COLOR_5BIT = 1, /* No 5-bit Alpha */
  288. COLOR_6BIT = 2, /* 6-Bit Alpha also = 2 */
  289. COLOR_8BIT = 3, /* 8-Bit Alpha also = 3 */
  290. };
  291. /**
  292. * enum dpu_3d_blend_mode
  293. * Desribes how the 3d data is blended
  294. * @BLEND_3D_NONE : 3d blending not enabled
  295. * @BLEND_3D_FRAME_INT : Frame interleaving
  296. * @BLEND_3D_H_ROW_INT : Horizontal row interleaving
  297. * @BLEND_3D_V_ROW_INT : vertical row interleaving
  298. * @BLEND_3D_COL_INT : column interleaving
  299. * @BLEND_3D_MAX :
  300. */
  301. enum dpu_3d_blend_mode {
  302. BLEND_3D_NONE = 0,
  303. BLEND_3D_FRAME_INT,
  304. BLEND_3D_H_ROW_INT,
  305. BLEND_3D_V_ROW_INT,
  306. BLEND_3D_COL_INT,
  307. BLEND_3D_MAX
  308. };
  309. /** struct dpu_format - defines the format configuration which
  310. * allows DPU HW to correctly fetch and decode the format
  311. * @base: base msm_format struture containing fourcc code
  312. * @fetch_planes: how the color components are packed in pixel format
  313. * @element: element color ordering
  314. * @bits: element bit widths
  315. * @chroma_sample: chroma sub-samplng type
  316. * @unpack_align_msb: unpack aligned, 0 to LSB, 1 to MSB
  317. * @unpack_tight: 0 for loose, 1 for tight
  318. * @unpack_count: 0 = 1 component, 1 = 2 component
  319. * @bpp: bytes per pixel
  320. * @alpha_enable: whether the format has an alpha channel
  321. * @num_planes: number of planes (including meta data planes)
  322. * @fetch_mode: linear, tiled, or ubwc hw fetch behavior
  323. * @is_yuv: is format a yuv variant
  324. * @flag: usage bit flags
  325. * @tile_width: format tile width
  326. * @tile_height: format tile height
  327. */
  328. struct dpu_format {
  329. struct msm_format base;
  330. enum dpu_plane_type fetch_planes;
  331. u8 element[DPU_MAX_PLANES];
  332. u8 bits[DPU_MAX_PLANES];
  333. enum dpu_chroma_samp_type chroma_sample;
  334. u8 unpack_align_msb;
  335. u8 unpack_tight;
  336. u8 unpack_count;
  337. u8 bpp;
  338. u8 alpha_enable;
  339. u8 num_planes;
  340. enum dpu_fetch_type fetch_mode;
  341. DECLARE_BITMAP(flag, DPU_FORMAT_FLAG_BIT_MAX);
  342. u16 tile_width;
  343. u16 tile_height;
  344. };
  345. #define to_dpu_format(x) container_of(x, struct dpu_format, base)
  346. /**
  347. * struct dpu_hw_fmt_layout - format information of the source pixel data
  348. * @format: pixel format parameters
  349. * @num_planes: number of planes (including meta data planes)
  350. * @width: image width
  351. * @height: image height
  352. * @total_size: total size in bytes
  353. * @plane_addr: address of each plane
  354. * @plane_size: length of each plane
  355. * @plane_pitch: pitch of each plane
  356. */
  357. struct dpu_hw_fmt_layout {
  358. const struct dpu_format *format;
  359. uint32_t num_planes;
  360. uint32_t width;
  361. uint32_t height;
  362. uint32_t total_size;
  363. uint32_t plane_addr[DPU_MAX_PLANES];
  364. uint32_t plane_size[DPU_MAX_PLANES];
  365. uint32_t plane_pitch[DPU_MAX_PLANES];
  366. };
  367. struct dpu_csc_cfg {
  368. /* matrix coefficients in S15.16 format */
  369. uint32_t csc_mv[DPU_CSC_MATRIX_COEFF_SIZE];
  370. uint32_t csc_pre_bv[DPU_CSC_BIAS_SIZE];
  371. uint32_t csc_post_bv[DPU_CSC_BIAS_SIZE];
  372. uint32_t csc_pre_lv[DPU_CSC_CLAMP_SIZE];
  373. uint32_t csc_post_lv[DPU_CSC_CLAMP_SIZE];
  374. };
  375. /**
  376. * struct dpu_mdss_color - mdss color description
  377. * color 0 : green
  378. * color 1 : blue
  379. * color 2 : red
  380. * color 3 : alpha
  381. */
  382. struct dpu_mdss_color {
  383. u32 color_0;
  384. u32 color_1;
  385. u32 color_2;
  386. u32 color_3;
  387. };
  388. /*
  389. * Define bit masks for h/w logging.
  390. */
  391. #define DPU_DBG_MASK_NONE (1 << 0)
  392. #define DPU_DBG_MASK_INTF (1 << 1)
  393. #define DPU_DBG_MASK_LM (1 << 2)
  394. #define DPU_DBG_MASK_CTL (1 << 3)
  395. #define DPU_DBG_MASK_PINGPONG (1 << 4)
  396. #define DPU_DBG_MASK_SSPP (1 << 5)
  397. #define DPU_DBG_MASK_WB (1 << 6)
  398. #define DPU_DBG_MASK_TOP (1 << 7)
  399. #define DPU_DBG_MASK_VBIF (1 << 8)
  400. #define DPU_DBG_MASK_ROT (1 << 9)
  401. #endif /* _DPU_HW_MDSS_H */