sde_hw_mdss.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
  4. * Copyright (c) 2015-2021, The Linux Foundation. All rights reserved.
  5. */
  6. #ifndef _SDE_HW_MDSS_H
  7. #define _SDE_HW_MDSS_H
  8. #include <linux/kernel.h>
  9. #include <linux/err.h>
  10. #include <drm/sde_drm.h>
  11. #include <drm/msm_drm_pp.h>
  12. #include <drm/drm_fourcc.h>
  13. #include "msm_drv.h"
  14. #define SDE_DBG_NAME "sde"
  15. #define SDE_NONE 0
  16. #ifndef SDE_CSC_MATRIX_COEFF_SIZE
  17. #define SDE_CSC_MATRIX_COEFF_SIZE 9
  18. #endif
  19. #ifndef SDE_CSC_CLAMP_SIZE
  20. #define SDE_CSC_CLAMP_SIZE 6
  21. #endif
  22. #ifndef SDE_CSC_BIAS_SIZE
  23. #define SDE_CSC_BIAS_SIZE 3
  24. #endif
  25. #ifndef SDE_MAX_PLANES
  26. #define SDE_MAX_PLANES 4
  27. #endif
  28. #define PIPES_PER_STAGE 2
  29. #ifndef SDE_MAX_DE_CURVES
  30. #define SDE_MAX_DE_CURVES 3
  31. #endif
  32. #define MAX_DSI_DISPLAYS 2
  33. #define MAX_DATA_PATH_PER_DSIPLAY 4
  34. enum sde_format_flags {
  35. SDE_FORMAT_FLAG_YUV_BIT,
  36. SDE_FORMAT_FLAG_DX_BIT,
  37. SDE_FORMAT_FLAG_COMPRESSED_BIT,
  38. SDE_FORMAT_FLAG_ALPHA_SWAP_BIT,
  39. SDE_FORMAT_FLAG_FP16_BIT,
  40. SDE_FORMAT_FLAG_BIT_MAX,
  41. };
  42. #define SDE_FORMAT_FLAG_YUV BIT(SDE_FORMAT_FLAG_YUV_BIT)
  43. #define SDE_FORMAT_FLAG_DX BIT(SDE_FORMAT_FLAG_DX_BIT)
  44. #define SDE_FORMAT_FLAG_COMPRESSED BIT(SDE_FORMAT_FLAG_COMPRESSED_BIT)
  45. #define SDE_FORMAT_FLAG_ALPHA_SWAP BIT(SDE_FORMAT_FLAG_ALPHA_SWAP_BIT)
  46. #define SDE_FORMAT_FLAG_FP16 BIT(SDE_FORMAT_FLAG_FP16_BIT)
  47. #define SDE_FORMAT_IS_YUV(X) \
  48. (test_bit(SDE_FORMAT_FLAG_YUV_BIT, (X)->flag))
  49. #define SDE_FORMAT_IS_DX(X) \
  50. (test_bit(SDE_FORMAT_FLAG_DX_BIT, (X)->flag))
  51. #define SDE_FORMAT_IS_LINEAR(X) ((X)->fetch_mode == SDE_FETCH_LINEAR)
  52. #define SDE_FORMAT_IS_TILE(X) \
  53. (((X)->fetch_mode == SDE_FETCH_UBWC) && \
  54. !test_bit(SDE_FORMAT_FLAG_COMPRESSED_BIT, (X)->flag))
  55. #define SDE_FORMAT_IS_UBWC(X) \
  56. (((X)->fetch_mode == SDE_FETCH_UBWC) && \
  57. test_bit(SDE_FORMAT_FLAG_COMPRESSED_BIT, (X)->flag))
  58. #define SDE_FORMAT_IS_ALPHA_SWAPPED(X) \
  59. (test_bit(SDE_FORMAT_FLAG_ALPHA_SWAP_BIT, (X)->flag))
  60. #define SDE_FORMAT_IS_FP16(X) \
  61. (test_bit(SDE_FORMAT_FLAG_FP16_BIT, (X)->flag))
  62. #define MDP_TICK_COUNT 16
  63. #define XO_CLK_RATE 19200
  64. #define MS_TICKS_IN_SEC 1000
  65. #define CALCULATE_WD_LOAD_VALUE(fps) \
  66. ((uint32_t)((MS_TICKS_IN_SEC * XO_CLK_RATE)/(MDP_TICK_COUNT * fps)))
  67. #define SDE_BLEND_FG_ALPHA_FG_CONST (0 << 0)
  68. #define SDE_BLEND_FG_ALPHA_BG_CONST (1 << 0)
  69. #define SDE_BLEND_FG_ALPHA_FG_PIXEL (2 << 0)
  70. #define SDE_BLEND_FG_ALPHA_BG_PIXEL (3 << 0)
  71. #define SDE_BLEND_FG_INV_ALPHA (1 << 2)
  72. #define SDE_BLEND_FG_MOD_ALPHA (1 << 3)
  73. #define SDE_BLEND_FG_INV_MOD_ALPHA (1 << 4)
  74. #define SDE_BLEND_FG_TRANSP_EN (1 << 5)
  75. #define SDE_BLEND_BG_ALPHA_FG_CONST (0 << 8)
  76. #define SDE_BLEND_BG_ALPHA_BG_CONST (1 << 8)
  77. #define SDE_BLEND_BG_ALPHA_FG_PIXEL (2 << 8)
  78. #define SDE_BLEND_BG_ALPHA_BG_PIXEL (3 << 8)
  79. #define SDE_BLEND_BG_INV_ALPHA (1 << 10)
  80. #define SDE_BLEND_BG_MOD_ALPHA (1 << 11)
  81. #define SDE_BLEND_BG_INV_MOD_ALPHA (1 << 12)
  82. #define SDE_BLEND_BG_TRANSP_EN (1 << 13)
  83. #define SDE_VSYNC0_SOURCE_GPIO 0
  84. #define SDE_VSYNC1_SOURCE_GPIO 1
  85. #define SDE_VSYNC2_SOURCE_GPIO 2
  86. #define SDE_VSYNC_SOURCE_INTF_0 3
  87. #define SDE_VSYNC_SOURCE_INTF_1 4
  88. #define SDE_VSYNC_SOURCE_INTF_2 5
  89. #define SDE_VSYNC_SOURCE_INTF_3 6
  90. #define SDE_VSYNC_SOURCE_WD_TIMER_4 11
  91. #define SDE_VSYNC_SOURCE_WD_TIMER_3 12
  92. #define SDE_VSYNC_SOURCE_WD_TIMER_2 13
  93. #define SDE_VSYNC_SOURCE_WD_TIMER_1 14
  94. #define SDE_VSYNC_SOURCE_WD_TIMER_0 15
  95. enum sde_hw_blk_type {
  96. SDE_HW_BLK_TOP = 0,
  97. SDE_HW_BLK_SSPP,
  98. SDE_HW_BLK_LM,
  99. SDE_HW_BLK_DSPP,
  100. SDE_HW_BLK_DS,
  101. SDE_HW_BLK_CTL,
  102. SDE_HW_BLK_CDM,
  103. SDE_HW_BLK_PINGPONG,
  104. SDE_HW_BLK_INTF,
  105. SDE_HW_BLK_WB,
  106. SDE_HW_BLK_DSC,
  107. SDE_HW_BLK_VDC,
  108. SDE_HW_BLK_MERGE_3D,
  109. SDE_HW_BLK_QDSS,
  110. SDE_HW_BLK_DNSC_BLUR,
  111. SDE_HW_BLK_MAX,
  112. };
  113. enum sde_uidle {
  114. UIDLE = 0x1,
  115. UIDLE_MAX,
  116. };
  117. enum sde_mdp {
  118. MDP_TOP = 0x1,
  119. MDP_MAX,
  120. };
  121. enum sde_sspp {
  122. SSPP_NONE,
  123. SSPP_VIG0,
  124. SSPP_VIG1,
  125. SSPP_VIG2,
  126. SSPP_VIG3,
  127. SSPP_VIG_MAX = SSPP_VIG3,
  128. SSPP_DMA0,
  129. SSPP_DMA1,
  130. SSPP_DMA2,
  131. SSPP_DMA3,
  132. SSPP_DMA4,
  133. SSPP_DMA5,
  134. SSPP_DMA_MAX = SSPP_DMA5,
  135. SSPP_MAX
  136. };
  137. #define SDE_SSPP_VALID(x) ((x) > SSPP_NONE && (x) < SSPP_MAX)
  138. #define SDE_SSPP_VALID_VIG(x) ((x) >= SSPP_VIG0 && (x) <= SSPP_VIG_MAX)
  139. #define SDE_SSPP_VALID_DMA(x) ((x) >= SSPP_DMA0 && (x) <= SSPP_DMA_MAX)
  140. enum sde_sspp_type {
  141. SSPP_TYPE_VIG,
  142. SSPP_TYPE_DMA,
  143. SSPP_TYPE_MAX
  144. };
  145. enum sde_sspp_rect {
  146. R0,
  147. R1,
  148. R_MAX
  149. };
  150. enum sde_lm {
  151. LM_0 = 1,
  152. LM_1,
  153. LM_2,
  154. LM_3,
  155. LM_4,
  156. LM_5,
  157. LM_DCWB_DUMMY_0,
  158. LM_DCWB_DUMMY_1,
  159. LM_DCWB_DUMMY_2,
  160. LM_DCWB_DUMMY_3,
  161. LM_6,
  162. LM_MAX
  163. };
  164. enum sde_stage {
  165. SDE_STAGE_BASE = 0,
  166. SDE_STAGE_0,
  167. SDE_STAGE_1,
  168. SDE_STAGE_2,
  169. SDE_STAGE_3,
  170. SDE_STAGE_4,
  171. SDE_STAGE_5,
  172. SDE_STAGE_6,
  173. SDE_STAGE_7,
  174. SDE_STAGE_8,
  175. SDE_STAGE_9,
  176. SDE_STAGE_10,
  177. SDE_STAGE_MAX
  178. };
  179. enum sde_dspp {
  180. DSPP_0 = 1,
  181. DSPP_1,
  182. DSPP_2,
  183. DSPP_3,
  184. DSPP_MAX
  185. };
  186. enum sde_ltm {
  187. LTM_0 = DSPP_0,
  188. LTM_1,
  189. LTM_2,
  190. LTM_3,
  191. LTM_MAX
  192. };
  193. enum sde_rc {
  194. RC_0 = DSPP_0,
  195. RC_1,
  196. RC_2,
  197. RC_3,
  198. RC_MAX
  199. };
  200. enum sde_demura {
  201. DEMURA_0,
  202. DEMURA_1,
  203. DEMURA_2,
  204. DEMURA_3,
  205. DEMURA_MAX
  206. };
  207. enum sde_ds {
  208. DS_TOP,
  209. DS_0,
  210. DS_1,
  211. DS_2,
  212. DS_3,
  213. DS_MAX
  214. };
  215. enum sde_ctl {
  216. CTL_0 = 1,
  217. CTL_1,
  218. CTL_2,
  219. CTL_3,
  220. CTL_4,
  221. CTL_5,
  222. CTL_MAX
  223. };
  224. enum sde_cdm {
  225. CDM_0 = 1,
  226. CDM_1,
  227. CDM_MAX
  228. };
  229. enum sde_dnsc_blur {
  230. DNSC_BLUR_0 = 1,
  231. DNSC_BLUR__MAX
  232. };
  233. enum sde_pingpong {
  234. PINGPONG_0 = 1,
  235. PINGPONG_1,
  236. PINGPONG_2,
  237. PINGPONG_3,
  238. PINGPONG_4,
  239. PINGPONG_5,
  240. PINGPONG_CWB_0,
  241. PINGPONG_CWB_1,
  242. PINGPONG_CWB_2,
  243. PINGPONG_CWB_3,
  244. PINGPONG_S0,
  245. PINGPONG_MAX
  246. };
  247. enum sde_dsc {
  248. DSC_NONE = 0,
  249. DSC_0,
  250. DSC_1,
  251. DSC_2,
  252. DSC_3,
  253. DSC_4,
  254. DSC_5,
  255. DSC_MAX
  256. };
  257. enum sde_vdc {
  258. VDC_NONE = 0,
  259. VDC_0,
  260. VDC_1,
  261. VDC_MAX
  262. };
  263. enum sde_intf {
  264. INTF_0 = 1,
  265. INTF_1,
  266. INTF_2,
  267. INTF_3,
  268. INTF_4,
  269. INTF_5,
  270. INTF_6,
  271. INTF_MAX
  272. };
  273. enum sde_intf_type {
  274. INTF_NONE = 0x0,
  275. INTF_DSI = 0x1,
  276. INTF_HDMI = 0x3,
  277. INTF_LCDC = 0x5,
  278. INTF_EDP = 0x9,
  279. INTF_DP = 0xa,
  280. INTF_TYPE_MAX,
  281. /* virtual interfaces */
  282. INTF_WB = 0x100,
  283. };
  284. enum sde_intf_mode {
  285. INTF_MODE_NONE = 0,
  286. INTF_MODE_CMD,
  287. INTF_MODE_VIDEO,
  288. INTF_MODE_WB_BLOCK,
  289. INTF_MODE_WB_LINE,
  290. INTF_MODE_MAX
  291. };
  292. enum sde_wb {
  293. WB_0 = 1,
  294. WB_1,
  295. WB_2,
  296. WB_3,
  297. WB_MAX
  298. };
  299. enum sde_ad {
  300. AD_0 = 0x1,
  301. AD_1,
  302. AD_MAX
  303. };
  304. enum sde_cwb {
  305. CWB_0 = 0x1,
  306. CWB_1,
  307. CWB_2,
  308. CWB_3,
  309. CWB_4,
  310. CWB_5,
  311. CWB_MAX
  312. };
  313. enum sde_dcwb {
  314. DCWB_0 = 0x1,
  315. DCWB_1,
  316. DCWB_2,
  317. DCWB_3,
  318. DCWB_MAX
  319. };
  320. enum sde_wd_timer {
  321. WD_TIMER_0 = 0x1,
  322. WD_TIMER_1,
  323. WD_TIMER_2,
  324. WD_TIMER_3,
  325. WD_TIMER_4,
  326. WD_TIMER_5,
  327. WD_TIMER_MAX
  328. };
  329. enum sde_vbif {
  330. VBIF_0,
  331. VBIF_1,
  332. VBIF_MAX,
  333. VBIF_RT = VBIF_0,
  334. VBIF_NRT = VBIF_1
  335. };
  336. enum sde_iommu_domain {
  337. SDE_IOMMU_DOMAIN_UNSECURE,
  338. SDE_IOMMU_DOMAIN_SECURE,
  339. SDE_IOMMU_DOMAIN_MAX
  340. };
  341. enum sde_rot {
  342. ROT_0 = 1,
  343. ROT_MAX
  344. };
  345. enum sde_merge_3d {
  346. MERGE_3D_0 = 1,
  347. MERGE_3D_1,
  348. MERGE_3D_2,
  349. MERGE_3D_CWB_0,
  350. MERGE_3D_CWB_1,
  351. MERGE_3D_MAX
  352. };
  353. enum sde_qdss {
  354. QDSS_0,
  355. QDSS_MAX
  356. };
  357. /**
  358. * SDE HW,Component order color map
  359. */
  360. enum {
  361. C0_G_Y = 0,
  362. C1_B_Cb = 1,
  363. C2_R_Cr = 2,
  364. C3_ALPHA = 3
  365. };
  366. /**
  367. * enum sde_plane_type - defines how the color component pixel packing
  368. * @SDE_PLANE_INTERLEAVED : Color components in single plane
  369. * @SDE_PLANE_PLANAR : Color component in separate planes
  370. * @SDE_PLANE_PSEUDO_PLANAR : Chroma components interleaved in separate plane
  371. */
  372. enum sde_plane_type {
  373. SDE_PLANE_INTERLEAVED,
  374. SDE_PLANE_PLANAR,
  375. SDE_PLANE_PSEUDO_PLANAR,
  376. };
  377. /**
  378. * enum sde_chroma_samp_type - chroma sub-samplng type
  379. * @SDE_CHROMA_RGB : No chroma subsampling
  380. * @SDE_CHROMA_H2V1 : Chroma pixels are horizontally subsampled
  381. * @SDE_CHROMA_H1V2 : Chroma pixels are vertically subsampled
  382. * @SDE_CHROMA_420 : 420 subsampling
  383. */
  384. enum sde_chroma_samp_type {
  385. SDE_CHROMA_RGB,
  386. SDE_CHROMA_H2V1,
  387. SDE_CHROMA_H1V2,
  388. SDE_CHROMA_420
  389. };
  390. /**
  391. * sde_fetch_type - Defines How SDE HW fetches data
  392. * @SDE_FETCH_LINEAR : fetch is line by line
  393. * @SDE_FETCH_TILE : fetches data in Z order from a tile
  394. * @SDE_FETCH_UBWC : fetch and decompress data
  395. */
  396. enum sde_fetch_type {
  397. SDE_FETCH_LINEAR,
  398. SDE_FETCH_TILE,
  399. SDE_FETCH_UBWC
  400. };
  401. /**
  402. * Value of enum chosen to fit the number of bits
  403. * expected by the HW programming.
  404. */
  405. enum {
  406. COLOR_ALPHA_1BIT = 0,
  407. COLOR_ALPHA_4BIT = 1,
  408. COLOR_4BIT = 0,
  409. COLOR_5BIT = 1, /* No 5-bit Alpha */
  410. COLOR_6BIT = 2, /* 6-Bit Alpha also = 2 */
  411. COLOR_8BIT = 3, /* 8-Bit Alpha also = 3 */
  412. COLOR_16BIT = 3,
  413. };
  414. /**
  415. * enum sde_3d_blend_mode
  416. * Desribes how the 3d data is blended
  417. * @BLEND_3D_NONE : 3d blending not enabled
  418. * @BLEND_3D_FRAME_INT : Frame interleaving
  419. * @BLEND_3D_H_ROW_INT : Horizontal row interleaving
  420. * @BLEND_3D_V_ROW_INT : vertical row interleaving
  421. * @BLEND_3D_COL_INT : column interleaving
  422. * @BLEND_3D_MAX :
  423. */
  424. enum sde_3d_blend_mode {
  425. BLEND_3D_NONE = 0,
  426. BLEND_3D_FRAME_INT,
  427. BLEND_3D_H_ROW_INT,
  428. BLEND_3D_V_ROW_INT,
  429. BLEND_3D_COL_INT,
  430. BLEND_3D_MAX
  431. };
  432. /**
  433. * enum sde_sys_cache_state: states of disp system cache
  434. * CACHE_STATE_DISABLED: sys cache has been disabled
  435. * CACHE_STATE_ENABLED: sys cache has been enabled
  436. * CACHE_STATE_NORMAL: sys cache is normal state
  437. * CACHE_STATE_PRE_CACHE: frame cache is being prepared
  438. * CACHE_STATE_FRAME_WRITE: sys cache is being written to
  439. * CACHE_STATE_FRAME_READ: sys cache is being read
  440. */
  441. enum sde_sys_cache_state {
  442. CACHE_STATE_DISABLED,
  443. CACHE_STATE_ENABLED,
  444. CACHE_STATE_NORMAL,
  445. CACHE_STATE_PRE_CACHE,
  446. CACHE_STATE_FRAME_WRITE,
  447. CACHE_STATE_FRAME_READ
  448. };
  449. /**
  450. * enum sde_wb_usage_type: Type of usage of the WB connector
  451. * WB_USAGE_WFD: WB connector used for WFD
  452. * WB_USAGE_CWB: WB connector used for concurrent writeback
  453. * WB_USAGE_OFFLINE_WB: WB connector used for 2-pass composition
  454. * WB_USAGE_ROT: WB connector used for image rotation for 2 pass composition
  455. */
  456. enum sde_wb_usage_type {
  457. WB_USAGE_WFD,
  458. WB_USAGE_CWB,
  459. WB_USAGE_OFFLINE_WB,
  460. WB_USAGE_ROT,
  461. };
  462. /**
  463. * enum sde_wb_rot_type: Type of rotation use case of the WB connector
  464. * WB_ROT_NONE : WB Rotation not in use
  465. * WB_ROT_SINGLE: WB Rotation used in single job mode for full image rotation
  466. * WB_ROT_JOB1: WB Rotation used for rotating half image as first-job
  467. * WB_ROT_JOB2: WB Rotation used for rotating half image as second-job
  468. */
  469. enum sde_wb_rot_type {
  470. WB_ROT_NONE,
  471. WB_ROT_SINGLE,
  472. WB_ROT_JOB1,
  473. WB_ROT_JOB2,
  474. };
  475. /** struct sde_format - defines the format configuration which
  476. * allows SDE HW to correctly fetch and decode the format
  477. * @base: base msm_format struture containing fourcc code
  478. * @fetch_planes: how the color components are packed in pixel format
  479. * @element: element color ordering
  480. * @bits: element bit widths
  481. * @chroma_sample: chroma sub-samplng type
  482. * @unpack_align_msb: unpack aligned, 0 to LSB, 1 to MSB
  483. * @unpack_tight: 0 for loose, 1 for tight
  484. * @unpack_count: 0 = 1 component, 1 = 2 component
  485. * @bpp: bytes per pixel
  486. * @alpha_enable: whether the format has an alpha channel
  487. * @num_planes: number of planes (including meta data planes)
  488. * @fetch_mode: linear, tiled, or ubwc hw fetch behavior
  489. * @is_yuv: is format a yuv variant
  490. * @flag: usage bit flags
  491. * @tile_width: format tile width
  492. * @tile_height: format tile height
  493. */
  494. struct sde_format {
  495. struct msm_format base;
  496. enum sde_plane_type fetch_planes;
  497. u8 element[SDE_MAX_PLANES];
  498. u8 bits[SDE_MAX_PLANES];
  499. enum sde_chroma_samp_type chroma_sample;
  500. u8 unpack_align_msb;
  501. u8 unpack_tight;
  502. u8 unpack_count;
  503. u8 bpp;
  504. u8 alpha_enable;
  505. u8 num_planes;
  506. enum sde_fetch_type fetch_mode;
  507. DECLARE_BITMAP(flag, SDE_FORMAT_FLAG_BIT_MAX);
  508. u16 tile_width;
  509. u16 tile_height;
  510. };
  511. #define to_sde_format(x) container_of(x, struct sde_format, base)
  512. /**
  513. * struct sde_hw_fmt_layout - format information of the source pixel data
  514. * @format: pixel format parameters
  515. * @num_planes: number of planes (including meta data planes)
  516. * @width: image width
  517. * @height: image height
  518. * @total_size: total size in bytes
  519. * @plane_addr: address of each plane
  520. * @plane_size: length of each plane
  521. * @plane_pitch: pitch of each plane
  522. */
  523. struct sde_hw_fmt_layout {
  524. const struct sde_format *format;
  525. uint32_t num_planes;
  526. uint32_t width;
  527. uint32_t height;
  528. uint32_t total_size;
  529. uint32_t plane_addr[SDE_MAX_PLANES];
  530. uint32_t plane_size[SDE_MAX_PLANES];
  531. uint32_t plane_pitch[SDE_MAX_PLANES];
  532. };
  533. struct sde_rect {
  534. u16 x;
  535. u16 y;
  536. u16 w;
  537. u16 h;
  538. };
  539. struct sde_io_res {
  540. bool enabled;
  541. u32 src_w;
  542. u32 src_h;
  543. u32 dst_w;
  544. u32 dst_h;
  545. };
  546. struct sde_csc_cfg {
  547. /* matrix coefficients in S15.16 format */
  548. uint32_t csc_mv[SDE_CSC_MATRIX_COEFF_SIZE];
  549. uint32_t csc_pre_bv[SDE_CSC_BIAS_SIZE];
  550. uint32_t csc_post_bv[SDE_CSC_BIAS_SIZE];
  551. uint32_t csc_pre_lv[SDE_CSC_CLAMP_SIZE];
  552. uint32_t csc_post_lv[SDE_CSC_CLAMP_SIZE];
  553. };
  554. /**
  555. * struct sde_mdss_color - mdss color description
  556. * color 0 : green
  557. * color 1 : blue
  558. * color 2 : red
  559. * color 3 : alpha
  560. */
  561. struct sde_mdss_color {
  562. u32 color_0;
  563. u32 color_1;
  564. u32 color_2;
  565. u32 color_3;
  566. };
  567. /*
  568. * Define bit masks for h/w logging.
  569. */
  570. #define SDE_DBG_MASK_NONE (1 << 0)
  571. #define SDE_DBG_MASK_CDM (1 << 1)
  572. #define SDE_DBG_MASK_DSPP (1 << 2)
  573. #define SDE_DBG_MASK_INTF (1 << 3)
  574. #define SDE_DBG_MASK_LM (1 << 4)
  575. #define SDE_DBG_MASK_CTL (1 << 5)
  576. #define SDE_DBG_MASK_PINGPONG (1 << 6)
  577. #define SDE_DBG_MASK_SSPP (1 << 7)
  578. #define SDE_DBG_MASK_WB (1 << 8)
  579. #define SDE_DBG_MASK_TOP (1 << 9)
  580. #define SDE_DBG_MASK_VBIF (1 << 10)
  581. #define SDE_DBG_MASK_DSC (1 << 11)
  582. #define SDE_DBG_MASK_ROT (1 << 12)
  583. #define SDE_DBG_MASK_DS (1 << 13)
  584. #define SDE_DBG_MASK_REGDMA (1 << 14)
  585. #define SDE_DBG_MASK_UIDLE (1 << 15)
  586. #define SDE_DBG_MASK_SID (1 << 15)
  587. #define SDE_DBG_MASK_QDSS (1 << 16)
  588. #define SDE_DBG_MASK_VDC (1 << 17)
  589. #define SDE_DBG_MASK_DNSC_BLUR (1 << 18)
  590. /**
  591. * struct sde_hw_cp_cfg: hardware dspp/lm feature payload.
  592. * @payload: Feature specific payload.
  593. * @len: Length of the payload.
  594. * @ctl: control pointer associated with dspp/lm.
  595. * @last_feature: last feature that will be set.
  596. * @num_of_mixers: number of layer mixers for the display.
  597. * @mixer_info: mixer info pointer associated with lm.
  598. * @displayv: height of the display.
  599. * @displayh: width of the display.
  600. * @dspp[DSPP_MAX]: array of hw_dspp pointers associated with crtc.
  601. * @broadcast_disabled: flag indicating if broadcast should be avoided when
  602. * using LUTDMA
  603. * @panel_height: height of display panel in pixels.
  604. * @panel_width: width of display panel in pixels.
  605. * @valid_skip_blend_plane: true if skip plane params are valid
  606. * @skip_blend_plane: plane which has been skipped staging into layer mixer
  607. * @skip_blend_plane_w: skip plane width
  608. * @skip_blend_plane_h: skip plane height
  609. * @num_ds_enabled: Number of destination scalers enabled
  610. */
  611. struct sde_hw_cp_cfg {
  612. void *payload;
  613. u32 len;
  614. void *ctl;
  615. u32 last_feature;
  616. u32 num_of_mixers;
  617. void *mixer_info;
  618. u32 displayv;
  619. u32 displayh;
  620. struct sde_hw_dspp *dspp[DSPP_MAX];
  621. bool broadcast_disabled;
  622. u32 panel_height;
  623. u32 panel_width;
  624. bool valid_skip_blend_plane;
  625. enum sde_sspp skip_blend_plane;
  626. u32 skip_blend_plane_w;
  627. u32 skip_blend_plane_h;
  628. u32 num_ds_enabled;
  629. };
  630. /**
  631. * struct sde_hw_dim_layer: dim layer configs
  632. * @flags: Flag to represent INCLUSIVE/EXCLUSIVE
  633. * @stage: Blending stage of dim layer
  634. * @color_fill: Color fill to be used for the layer
  635. * @rect: Dim layer coordinates
  636. */
  637. struct sde_hw_dim_layer {
  638. uint32_t flags;
  639. uint32_t stage;
  640. struct sde_mdss_color color_fill;
  641. struct sde_rect rect;
  642. };
  643. /**
  644. * struct sde_splash_mem - Struct contains splah memory info
  645. * @splash_buf_size: Indicates the size of the memory region
  646. * @splash_buf_base: Address of specific splash memory region
  647. * @ramdump_size: Size of ramdump buffer region
  648. * @ramdump_base: Address of ramdump region reserved by bootloader
  649. * @ref_cnt: Tracks the map count to help in sharing splash memory
  650. */
  651. struct sde_splash_mem {
  652. u32 splash_buf_size;
  653. unsigned long splash_buf_base;
  654. u32 ramdump_size;
  655. unsigned long ramdump_base;
  656. u32 ref_cnt;
  657. };
  658. /**
  659. * struct sde_sspp_index_info - Struct informing which pipes are staged on
  660. * particular display
  661. * @pipes: bitmap, bit index is true if rect_0 of that pipe is staged,
  662. * else is false
  663. * @virt_pipes: bitmap, bit index is true if rect_1 of that pipe is staged,
  664. * else set to false
  665. * @bordercolor: True if border color is enabled
  666. */
  667. struct sde_sspp_index_info {
  668. DECLARE_BITMAP(pipes, SSPP_MAX);
  669. DECLARE_BITMAP(virt_pipes, SSPP_MAX);
  670. bool bordercolor;
  671. };
  672. /**
  673. * struct sde_splash_data - Struct contains details of resources and hw blocks
  674. * used in continuous splash on a specific display.
  675. * @cont_splash_enabled: Stores the cont_splash status (enabled/disabled)
  676. * @encoder: Pointer to the drm encoder object used for this display
  677. * @splash: Pointer to struct sde_splash_mem used for this display
  678. * @demura: Pointer to struct sde_splash_mem used for demura cont splash
  679. * @ctl_ids: Stores the valid MDSS ctl block ids for the current mode
  680. * @lm_ids: Stores the valid MDSS layer mixer block ids for the current mode
  681. * @dsc_ids: Stores the valid MDSS DSC block ids for the current mode
  682. * @vdc_ids: Stores the valid MDSS VDC block ids for the current mode
  683. * @pipes: Array of sspp info detected on this display
  684. * @ctl_cnt: Stores the active number of MDSS "top" blks of the current mode
  685. * @lm_cnt: Stores the active number of MDSS "LM" blks for the current mode
  686. * @dsc_cnt: Stores the active number of MDSS "dsc" blks for the current mode
  687. * @vdc_cnt: Stores the valid MDSS VDC block ids for the current mode
  688. */
  689. struct sde_splash_display {
  690. bool cont_splash_enabled;
  691. struct drm_encoder *encoder;
  692. struct sde_splash_mem *splash;
  693. struct sde_splash_mem *demura;
  694. u8 ctl_ids[MAX_DATA_PATH_PER_DSIPLAY];
  695. u8 lm_ids[MAX_DATA_PATH_PER_DSIPLAY];
  696. u8 dsc_ids[MAX_DATA_PATH_PER_DSIPLAY];
  697. u8 vdc_ids[MAX_DATA_PATH_PER_DSIPLAY];
  698. struct sde_sspp_index_info pipe_info;
  699. u8 ctl_cnt;
  700. u8 lm_cnt;
  701. u8 dsc_cnt;
  702. u8 vdc_cnt;
  703. };
  704. enum sde_handoff_type {
  705. SDE_SPLASH_HANDOFF,
  706. SDE_VM_HANDOFF,
  707. };
  708. /**
  709. * struct sde_splash_data - Struct contains details of continuous splash
  710. * for all the displays connected by probe time
  711. * @type: Indicates the type of handoff
  712. * @num_splash_regions: Indicates number of splash memory regions from dtsi
  713. * @num_splash_displays: Indicates count of active displays in continuous splash
  714. * @splash_mem: Array of all struct sde_splash_mem listed from dtsi
  715. * @demura_mem: Array of all demura memory regions listed from dtsi
  716. * @splash_display: Array of all struct sde_splash_display
  717. */
  718. struct sde_splash_data {
  719. enum sde_handoff_type type;
  720. u32 num_splash_regions;
  721. u32 num_splash_displays;
  722. struct sde_splash_mem splash_mem[MAX_DSI_DISPLAYS];
  723. struct sde_splash_mem demura_mem[MAX_DSI_DISPLAYS];
  724. struct sde_splash_display splash_display[MAX_DSI_DISPLAYS];
  725. };
  726. /**
  727. * struct sde_hw_tear_check - Struct contains parameters to configure
  728. * tear-effect module. This structure is used to configure tear-check
  729. * logic present either in ping-pong or in interface module.
  730. * @vsync_count: Ratio of MDP VSYNC clk freq(Hz) to refresh rate divided
  731. * by no of lines
  732. * @sync_cfg_height: Total vertical lines (display height - 1)
  733. * @vsync_init_val: Init value to which the read pointer gets loaded at
  734. * vsync edge
  735. * @sync_threshold_start: Read pointer threshold start ROI for write operation
  736. * @sync_threshold_continue: The minimum number of lines the write pointer
  737. * needs to be above the read pointer
  738. * @start_pos: The position from which the start_threshold value is added
  739. * @rd_ptr_irq: The read pointer line at which interrupt has to be generated
  740. * @wr_ptr_irq: The write pointer line at which interrupt has to be generated
  741. * @hw_vsync_mode: Sync with external frame sync input
  742. */
  743. struct sde_hw_tear_check {
  744. u32 vsync_count;
  745. u32 sync_cfg_height;
  746. u32 vsync_init_val;
  747. u32 sync_threshold_start;
  748. u32 sync_threshold_continue;
  749. u32 start_pos;
  750. u32 rd_ptr_irq;
  751. u32 wr_ptr_irq;
  752. u8 hw_vsync_mode;
  753. };
  754. /**
  755. * struct sde_hw_autorefresh - Struct contains parameters to configure
  756. * auto-refresh mode for command mode panels
  757. * @enable: Enalbe or disable the auto-refresh mode
  758. * @frame_count: Auto-refresh frame counter at which update occurs
  759. */
  760. struct sde_hw_autorefresh {
  761. bool enable;
  762. u32 frame_count;
  763. };
  764. /**
  765. * struct sde_hw_pp_vsync_info - Struct contains parameters to configure
  766. * read and write pointers for command mode panels
  767. * @pp_idx: Ping-pong block index
  768. * @intf_idx: Interface block index
  769. * @rd_ptr_init_val: Value of rd pointer at vsync edge
  770. * @rd_ptr_frame_count: num frames sent since enabling interface
  771. * @rd_ptr_line_count: current line on panel (rd ptr)
  772. * @wr_ptr_line_count: current line within pp fifo (wr ptr)
  773. * @intf_frame_count: num frames read from intf
  774. */
  775. struct sde_hw_pp_vsync_info {
  776. u32 pp_idx;
  777. u32 intf_idx;
  778. u32 rd_ptr_init_val;
  779. u32 rd_ptr_frame_count;
  780. u32 rd_ptr_line_count;
  781. u32 wr_ptr_line_count;
  782. u32 intf_frame_count;
  783. };
  784. /**
  785. * struct sde_hw_noise_layer_cfg: Payload to enable/disable noise blend
  786. * @flags: operation control flags, for future use
  787. * @noise_blend_stage: blend stage required for noise layer
  788. * @attn_blend_stage: blend stage required for attn layer
  789. * @attn_factor: factor in range of 1 to 255
  790. * @stength: strength in range of 0 to 6
  791. * @alpha_noise: factor in range of 1 to 255
  792. */
  793. struct sde_hw_noise_layer_cfg {
  794. u64 flags;
  795. u32 noise_blend_stage;
  796. u32 attn_blend_stage;
  797. u32 attn_factor;
  798. u32 strength;
  799. u32 alpha_noise;
  800. };
  801. #endif /* _SDE_HW_MDSS_H */