sde_hw_sspp.c 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2015-2021, The Linux Foundation. All rights reserved.
  4. */
  5. #include "sde_hwio.h"
  6. #include "sde_hw_catalog.h"
  7. #include "sde_hw_lm.h"
  8. #include "sde_hw_sspp.h"
  9. #include "sde_hw_color_processing.h"
  10. #include "sde_dbg.h"
  11. #include "sde_kms.h"
  12. #include "sde_hw_reg_dma_v1_color_proc.h"
  13. #define SDE_FETCH_CONFIG_RESET_VALUE 0x00000087
  14. /* SDE_SSPP_SRC */
  15. #define SSPP_SRC_SIZE 0x00
  16. #define SSPP_SRC_XY 0x08
  17. #define SSPP_OUT_SIZE 0x0c
  18. #define SSPP_OUT_XY 0x10
  19. #define SSPP_SRC0_ADDR 0x14
  20. #define SSPP_SRC1_ADDR 0x18
  21. #define SSPP_SRC2_ADDR 0x1C
  22. #define SSPP_SRC3_ADDR 0x20
  23. #define SSPP_SRC_YSTRIDE0 0x24
  24. #define SSPP_SRC_YSTRIDE1 0x28
  25. #define SSPP_SRC_FORMAT 0x30
  26. #define SSPP_SRC_UNPACK_PATTERN 0x34
  27. #define SSPP_SRC_OP_MODE 0x38
  28. /* SSPP_MULTIRECT*/
  29. #define SSPP_SRC_SIZE_REC1 0x16C
  30. #define SSPP_SRC_XY_REC1 0x168
  31. #define SSPP_OUT_SIZE_REC1 0x160
  32. #define SSPP_OUT_XY_REC1 0x164
  33. #define SSPP_SRC_FORMAT_REC1 0x174
  34. #define SSPP_SRC_UNPACK_PATTERN_REC1 0x178
  35. #define SSPP_SRC_OP_MODE_REC1 0x17C
  36. #define SSPP_MULTIRECT_OPMODE 0x170
  37. #define SSPP_SRC_CONSTANT_COLOR_REC1 0x180
  38. #define SSPP_EXCL_REC_SIZE_REC1 0x184
  39. #define SSPP_EXCL_REC_XY_REC1 0x188
  40. #define SSPP_UIDLE_CTRL_VALUE 0x1f0
  41. #define SSPP_UIDLE_CTRL_VALUE_REC1 0x1f4
  42. /* SSPP_DGM */
  43. #define SSPP_DGM_0 0x9F0
  44. #define SSPP_DGM_1 0x19F0
  45. #define SSPP_DGM_SIZE 0x420
  46. #define SSPP_DGM_CSC_0 0x800
  47. #define SSPP_DGM_CSC_1 0x1800
  48. #define SSPP_DGM_CSC_SIZE 0xFC
  49. #define VIG_GAMUT_SIZE 0x1CC
  50. #define MDSS_MDP_OP_DEINTERLACE BIT(22)
  51. #define MDSS_MDP_OP_DEINTERLACE_ODD BIT(23)
  52. #define MDSS_MDP_OP_IGC_ROM_1 BIT(18)
  53. #define MDSS_MDP_OP_IGC_ROM_0 BIT(17)
  54. #define MDSS_MDP_OP_IGC_EN BIT(16)
  55. #define MDSS_MDP_OP_FLIP_UD BIT(14)
  56. #define MDSS_MDP_OP_FLIP_LR BIT(13)
  57. #define MDSS_MDP_OP_SPLIT_ORDER BIT(4)
  58. #define MDSS_MDP_OP_BWC_EN BIT(0)
  59. #define MDSS_MDP_OP_PE_OVERRIDE BIT(31)
  60. #define MDSS_MDP_OP_BWC_LOSSLESS (0 << 1)
  61. #define MDSS_MDP_OP_BWC_Q_HIGH (1 << 1)
  62. #define MDSS_MDP_OP_BWC_Q_MED (2 << 1)
  63. #define SSPP_SRC_CONSTANT_COLOR 0x3c
  64. #define SSPP_EXCL_REC_CTL 0x40
  65. #define SSPP_UBWC_STATIC_CTRL 0x44
  66. #define SSPP_FETCH_CONFIG 0x48
  67. #define SSPP_PRE_DOWN_SCALE 0x50
  68. #define SSPP_DANGER_LUT 0x60
  69. #define SSPP_SAFE_LUT 0x64
  70. #define SSPP_CREQ_LUT 0x68
  71. #define SSPP_QOS_CTRL 0x6C
  72. #define SSPP_DECIMATION_CONFIG 0xB4
  73. #define SSPP_SRC_ADDR_SW_STATUS 0x70
  74. #define SSPP_CREQ_LUT_0 0x74
  75. #define SSPP_CREQ_LUT_1 0x78
  76. #define SSPP_UBWC_STATS_ROI 0x7C
  77. #define SSPP_UBWC_STATS_DATA 0x80
  78. #define SSPP_UBWC_STATS_ROI_REC1 0xB4
  79. #define SSPP_UBWC_STATS_DATA_REC1 0xB8
  80. #define SSPP_SW_PIX_EXT_C0_LR 0x100
  81. #define SSPP_SW_PIX_EXT_C0_TB 0x104
  82. #define SSPP_SW_PIX_EXT_C0_REQ_PIXELS 0x108
  83. #define SSPP_SW_PIX_EXT_C1C2_LR 0x110
  84. #define SSPP_SW_PIX_EXT_C1C2_TB 0x114
  85. #define SSPP_SW_PIX_EXT_C1C2_REQ_PIXELS 0x118
  86. #define SSPP_SW_PIX_EXT_C3_LR 0x120
  87. #define SSPP_SW_PIX_EXT_C3_TB 0x124
  88. #define SSPP_SW_PIX_EXT_C3_REQ_PIXELS 0x128
  89. #define SSPP_META_ERROR_STATUS 0X12C
  90. #define SSPP_TRAFFIC_SHAPER 0x130
  91. #define SSPP_CDP_CNTL 0x134
  92. #define SSPP_UBWC_ERROR_STATUS 0x138
  93. #define SSPP_CDP_CNTL_REC1 0x13c
  94. #define SSPP_TRAFFIC_SHAPER_PREFILL 0x150
  95. #define SSPP_TRAFFIC_SHAPER_REC1_PREFILL 0x154
  96. #define SSPP_TRAFFIC_SHAPER_REC1 0x158
  97. #define SSPP_EXCL_REC_SIZE 0x1B4
  98. #define SSPP_EXCL_REC_XY 0x1B8
  99. #define SSPP_UBWC_STATIC_CTRL_REC1 0x1C0
  100. #define SSPP_UBWC_ERROR_STATUS_REC1 0x1C8
  101. #define SSPP_META_ERROR_STATUS_REC1 0x1C4
  102. #define SSPP_VIG_OP_MODE 0x0
  103. #define SSPP_VIG_CSC_10_OP_MODE 0x0
  104. #define SSPP_TRAFFIC_SHAPER_BPC_MAX 0xFF
  105. /* SSPP_QOS_CTRL */
  106. #define SSPP_QOS_CTRL_VBLANK_EN BIT(16)
  107. #define SSPP_QOS_CTRL_DANGER_SAFE_EN BIT(0)
  108. #define SSPP_QOS_CTRL_DANGER_VBLANK_MASK 0x3
  109. #define SSPP_QOS_CTRL_DANGER_VBLANK_OFF 4
  110. #define SSPP_QOS_CTRL_CREQ_VBLANK_MASK 0x3
  111. #define SSPP_QOS_CTRL_CREQ_VBLANK_OFF 20
  112. #define SSPP_SYS_CACHE_MODE 0x1BC
  113. #define SSPP_SBUF_STATUS_PLANE0 0x1C0
  114. #define SSPP_SBUF_STATUS_PLANE1 0x1C4
  115. #define SSPP_SBUF_STATUS_PLANE_EMPTY BIT(16)
  116. /* SDE_SSPP_SCALER_QSEED2 */
  117. #define SCALE_CONFIG 0x04
  118. #define COMP0_3_PHASE_STEP_X 0x10
  119. #define COMP0_3_PHASE_STEP_Y 0x14
  120. #define COMP1_2_PHASE_STEP_X 0x18
  121. #define COMP1_2_PHASE_STEP_Y 0x1c
  122. #define COMP0_3_INIT_PHASE_X 0x20
  123. #define COMP0_3_INIT_PHASE_Y 0x24
  124. #define COMP1_2_INIT_PHASE_X 0x28
  125. #define COMP1_2_INIT_PHASE_Y 0x2C
  126. #define VIG_0_QSEED2_SHARP 0x30
  127. /*
  128. * Definitions for ViG op modes
  129. */
  130. #define VIG_OP_CSC_DST_DATAFMT BIT(19)
  131. #define VIG_OP_CSC_SRC_DATAFMT BIT(18)
  132. #define VIG_OP_CSC_EN BIT(17)
  133. #define VIG_OP_MEM_PROT_CONT BIT(15)
  134. #define VIG_OP_MEM_PROT_VAL BIT(14)
  135. #define VIG_OP_MEM_PROT_SAT BIT(13)
  136. #define VIG_OP_MEM_PROT_HUE BIT(12)
  137. #define VIG_OP_HIST BIT(8)
  138. #define VIG_OP_SKY_COL BIT(7)
  139. #define VIG_OP_FOIL BIT(6)
  140. #define VIG_OP_SKIN_COL BIT(5)
  141. #define VIG_OP_PA_EN BIT(4)
  142. #define VIG_OP_PA_SAT_ZERO_EXP BIT(2)
  143. #define VIG_OP_MEM_PROT_BLEND BIT(1)
  144. /*
  145. * Definitions for CSC 10 op modes
  146. */
  147. #define VIG_CSC_10_SRC_DATAFMT BIT(1)
  148. #define VIG_CSC_10_EN BIT(0)
  149. #define CSC_10BIT_OFFSET 4
  150. #define DGM_CSC_MATRIX_SHIFT 0
  151. /* traffic shaper clock in Hz */
  152. #define TS_CLK 19200000
  153. static inline int _sspp_subblk_offset(struct sde_hw_pipe *ctx,
  154. int s_id,
  155. u32 *idx)
  156. {
  157. int rc = 0;
  158. const struct sde_sspp_sub_blks *sblk;
  159. if (!ctx)
  160. return -EINVAL;
  161. sblk = ctx->cap->sblk;
  162. switch (s_id) {
  163. case SDE_SSPP_SRC:
  164. *idx = sblk->src_blk.base;
  165. break;
  166. case SDE_SSPP_SCALER_QSEED2:
  167. case SDE_SSPP_SCALER_QSEED3:
  168. case SDE_SSPP_SCALER_RGB:
  169. *idx = sblk->scaler_blk.base;
  170. break;
  171. case SDE_SSPP_CSC:
  172. case SDE_SSPP_CSC_10BIT:
  173. *idx = sblk->csc_blk.base;
  174. break;
  175. case SDE_SSPP_HSIC:
  176. *idx = sblk->hsic_blk.base;
  177. break;
  178. case SDE_SSPP_PCC:
  179. *idx = sblk->pcc_blk.base;
  180. break;
  181. case SDE_SSPP_MEMCOLOR:
  182. *idx = sblk->memcolor_blk.base;
  183. break;
  184. default:
  185. rc = -EINVAL;
  186. }
  187. return rc;
  188. }
  189. static void sde_hw_sspp_update_multirect(struct sde_hw_pipe *ctx,
  190. bool enable,
  191. enum sde_sspp_multirect_index index,
  192. enum sde_sspp_multirect_mode mode)
  193. {
  194. u32 mode_mask;
  195. u32 idx;
  196. if (_sspp_subblk_offset(ctx, SDE_SSPP_SRC, &idx))
  197. return;
  198. if (index == SDE_SSPP_RECT_SOLO) {
  199. /**
  200. * if rect index is RECT_SOLO, we cannot expect a
  201. * virtual plane sharing the same SSPP id. So we go
  202. * and disable multirect
  203. */
  204. mode_mask = 0;
  205. } else {
  206. mode_mask = SDE_REG_READ(&ctx->hw, SSPP_MULTIRECT_OPMODE + idx);
  207. if (enable)
  208. mode_mask |= index;
  209. else
  210. mode_mask &= ~index;
  211. if (enable && (mode == SDE_SSPP_MULTIRECT_TIME_MX))
  212. mode_mask |= BIT(2);
  213. else
  214. mode_mask &= ~BIT(2);
  215. }
  216. SDE_REG_WRITE(&ctx->hw, SSPP_MULTIRECT_OPMODE + idx, mode_mask);
  217. }
  218. static void _sspp_setup_opmode(struct sde_hw_pipe *ctx,
  219. u32 mask, u8 en)
  220. {
  221. u32 idx;
  222. u32 opmode;
  223. if (!test_bit(SDE_SSPP_SCALER_QSEED2, &ctx->cap->features) ||
  224. _sspp_subblk_offset(ctx, SDE_SSPP_SCALER_QSEED2, &idx) ||
  225. !test_bit(SDE_SSPP_CSC, &ctx->cap->features))
  226. return;
  227. opmode = SDE_REG_READ(&ctx->hw, SSPP_VIG_OP_MODE + idx);
  228. if (en)
  229. opmode |= mask;
  230. else
  231. opmode &= ~mask;
  232. SDE_REG_WRITE(&ctx->hw, SSPP_VIG_OP_MODE + idx, opmode);
  233. }
  234. static void _sspp_setup_csc10_opmode(struct sde_hw_pipe *ctx,
  235. u32 mask, u8 en)
  236. {
  237. u32 idx;
  238. u32 opmode;
  239. if (_sspp_subblk_offset(ctx, SDE_SSPP_CSC_10BIT, &idx))
  240. return;
  241. opmode = SDE_REG_READ(&ctx->hw, SSPP_VIG_CSC_10_OP_MODE + idx);
  242. if (en)
  243. opmode |= mask;
  244. else
  245. opmode &= ~mask;
  246. SDE_REG_WRITE(&ctx->hw, SSPP_VIG_CSC_10_OP_MODE + idx, opmode);
  247. }
  248. static void sde_hw_sspp_set_src_split_order(struct sde_hw_pipe *ctx,
  249. enum sde_sspp_multirect_index rect_mode, bool enable)
  250. {
  251. struct sde_hw_blk_reg_map *c;
  252. u32 opmode, idx, op_mode_off;
  253. if (_sspp_subblk_offset(ctx, SDE_SSPP_SRC, &idx))
  254. return;
  255. if (rect_mode == SDE_SSPP_RECT_SOLO || rect_mode == SDE_SSPP_RECT_0)
  256. op_mode_off = SSPP_SRC_OP_MODE;
  257. else
  258. op_mode_off = SSPP_SRC_OP_MODE_REC1;
  259. c = &ctx->hw;
  260. opmode = SDE_REG_READ(c, op_mode_off + idx);
  261. if (enable)
  262. opmode |= MDSS_MDP_OP_SPLIT_ORDER;
  263. else
  264. opmode &= ~MDSS_MDP_OP_SPLIT_ORDER;
  265. SDE_REG_WRITE(c, op_mode_off + idx, opmode);
  266. }
  267. static void sde_hw_sspp_setup_ubwc(struct sde_hw_pipe *ctx, struct sde_hw_blk_reg_map *c,
  268. const struct sde_format *fmt, bool const_alpha_en, bool const_color_en,
  269. enum sde_sspp_multirect_index rect_mode)
  270. {
  271. u32 alpha_en_mask = 0, color_en_mask = 0, ubwc_ctrl_off;
  272. SDE_REG_WRITE(c, SSPP_FETCH_CONFIG,
  273. SDE_FETCH_CONFIG_RESET_VALUE |
  274. ctx->mdp->highest_bank_bit << 18);
  275. if ((rect_mode == SDE_SSPP_RECT_SOLO || rect_mode == SDE_SSPP_RECT_0) ||
  276. !test_bit(SDE_SSPP_UBWC_STATS, &ctx->cap->features))
  277. ubwc_ctrl_off = SSPP_UBWC_STATIC_CTRL;
  278. else
  279. ubwc_ctrl_off = SSPP_UBWC_STATIC_CTRL_REC1;
  280. if (IS_UBWC_40_SUPPORTED(ctx->catalog->ubwc_version)) {
  281. SDE_REG_WRITE(c, ubwc_ctrl_off,
  282. SDE_FORMAT_IS_YUV(fmt) ? 0 : BIT(30));
  283. } else if (IS_UBWC_30_SUPPORTED(ctx->catalog->ubwc_version)) {
  284. color_en_mask = const_color_en ? BIT(30) : 0;
  285. SDE_REG_WRITE(c, ubwc_ctrl_off,
  286. color_en_mask | (ctx->mdp->ubwc_swizzle) |
  287. (ctx->mdp->highest_bank_bit << 4));
  288. } else if (IS_UBWC_20_SUPPORTED(ctx->catalog->ubwc_version)) {
  289. alpha_en_mask = const_alpha_en ? BIT(31) : 0;
  290. SDE_REG_WRITE(c, ubwc_ctrl_off,
  291. alpha_en_mask | (ctx->mdp->ubwc_swizzle) |
  292. (ctx->mdp->highest_bank_bit << 4));
  293. } else if (IS_UBWC_10_SUPPORTED(ctx->catalog->ubwc_version)) {
  294. alpha_en_mask = const_alpha_en ? BIT(31) : 0;
  295. SDE_REG_WRITE(c, ubwc_ctrl_off,
  296. alpha_en_mask | (ctx->mdp->ubwc_swizzle & 0x1) |
  297. BIT(8) | (ctx->mdp->highest_bank_bit << 4));
  298. }
  299. }
  300. /**
  301. * Setup source pixel format, flip,
  302. */
  303. static void sde_hw_sspp_setup_format(struct sde_hw_pipe *ctx,
  304. const struct sde_format *fmt,
  305. bool const_alpha_en, u32 flags,
  306. enum sde_sspp_multirect_index rect_mode)
  307. {
  308. struct sde_hw_blk_reg_map *c;
  309. u32 chroma_samp, unpack, src_format;
  310. u32 opmode = 0;
  311. u32 op_mode_off, unpack_pat_off, format_off;
  312. u32 idx;
  313. bool const_color_en = true;
  314. if (_sspp_subblk_offset(ctx, SDE_SSPP_SRC, &idx) || !fmt)
  315. return;
  316. if (rect_mode == SDE_SSPP_RECT_SOLO || rect_mode == SDE_SSPP_RECT_0) {
  317. op_mode_off = SSPP_SRC_OP_MODE;
  318. unpack_pat_off = SSPP_SRC_UNPACK_PATTERN;
  319. format_off = SSPP_SRC_FORMAT;
  320. } else {
  321. op_mode_off = SSPP_SRC_OP_MODE_REC1;
  322. unpack_pat_off = SSPP_SRC_UNPACK_PATTERN_REC1;
  323. format_off = SSPP_SRC_FORMAT_REC1;
  324. }
  325. c = &ctx->hw;
  326. opmode = SDE_REG_READ(c, op_mode_off + idx);
  327. opmode &= ~(MDSS_MDP_OP_FLIP_LR | MDSS_MDP_OP_FLIP_UD |
  328. MDSS_MDP_OP_BWC_EN | MDSS_MDP_OP_PE_OVERRIDE);
  329. if (flags & SDE_SSPP_FLIP_LR)
  330. opmode |= MDSS_MDP_OP_FLIP_LR;
  331. if (flags & SDE_SSPP_FLIP_UD)
  332. opmode |= MDSS_MDP_OP_FLIP_UD;
  333. chroma_samp = fmt->chroma_sample;
  334. if (flags & SDE_SSPP_SOURCE_ROTATED_90) {
  335. if (chroma_samp == SDE_CHROMA_H2V1)
  336. chroma_samp = SDE_CHROMA_H1V2;
  337. else if (chroma_samp == SDE_CHROMA_H1V2)
  338. chroma_samp = SDE_CHROMA_H2V1;
  339. }
  340. src_format = (chroma_samp << 23) | (fmt->fetch_planes << 19) |
  341. (fmt->bits[C3_ALPHA] << 6) | (fmt->bits[C2_R_Cr] << 4) |
  342. (fmt->bits[C1_B_Cb] << 2) | (fmt->bits[C0_G_Y] << 0);
  343. if (flags & SDE_SSPP_ROT_90)
  344. src_format |= BIT(11); /* ROT90 */
  345. if (fmt->alpha_enable && fmt->fetch_planes == SDE_PLANE_INTERLEAVED)
  346. src_format |= BIT(8); /* SRCC3_EN */
  347. if (flags & SDE_SSPP_SOLID_FILL)
  348. src_format |= BIT(22);
  349. unpack = (fmt->element[3] << 24) | (fmt->element[2] << 16) |
  350. (fmt->element[1] << 8) | (fmt->element[0] << 0);
  351. src_format |= ((fmt->unpack_count - 1) << 12) |
  352. (fmt->unpack_tight << 17) |
  353. (fmt->unpack_align_msb << 18);
  354. if (SDE_FORMAT_IS_FP16(fmt)) {
  355. src_format |= BIT(16) | BIT(10) | BIT(9);
  356. } else if (fmt->bpp <= 4) {
  357. src_format |= ((fmt->bpp - 1) << 9);
  358. } else if (fmt->bpp <= 8) {
  359. src_format |= BIT(16) | ((fmt->bpp - 5) << 9);
  360. }
  361. if ((flags & SDE_SSPP_ROT_90) && test_bit(SDE_SSPP_INLINE_CONST_CLR,
  362. &ctx->cap->features))
  363. const_color_en = false;
  364. if (fmt->fetch_mode != SDE_FETCH_LINEAR) {
  365. if (SDE_FORMAT_IS_UBWC(fmt))
  366. opmode |= MDSS_MDP_OP_BWC_EN;
  367. src_format |= (fmt->fetch_mode & 3) << 30; /*FRAME_FORMAT */
  368. sde_hw_sspp_setup_ubwc(ctx, c, fmt, const_alpha_en, const_color_en, rect_mode);
  369. }
  370. opmode |= MDSS_MDP_OP_PE_OVERRIDE;
  371. /* if this is YUV pixel format, enable CSC */
  372. if (SDE_FORMAT_IS_YUV(fmt))
  373. src_format |= BIT(15);
  374. if (SDE_FORMAT_IS_DX(fmt))
  375. src_format |= BIT(14);
  376. /* update scaler opmode, if appropriate */
  377. if (test_bit(SDE_SSPP_CSC, &ctx->cap->features))
  378. _sspp_setup_opmode(ctx, VIG_OP_CSC_EN | VIG_OP_CSC_SRC_DATAFMT,
  379. SDE_FORMAT_IS_YUV(fmt));
  380. else if (test_bit(SDE_SSPP_CSC_10BIT, &ctx->cap->features))
  381. _sspp_setup_csc10_opmode(ctx,
  382. VIG_CSC_10_EN | VIG_CSC_10_SRC_DATAFMT,
  383. SDE_FORMAT_IS_YUV(fmt));
  384. SDE_REG_WRITE(c, format_off + idx, src_format);
  385. SDE_REG_WRITE(c, unpack_pat_off + idx, unpack);
  386. SDE_REG_WRITE(c, op_mode_off + idx, opmode);
  387. /* clear previous UBWC error */
  388. SDE_REG_WRITE(c, SSPP_UBWC_ERROR_STATUS + idx, BIT(31));
  389. }
  390. static void sde_hw_sspp_clear_ubwc_error(struct sde_hw_pipe *ctx,
  391. enum sde_sspp_multirect_index multirect_index)
  392. {
  393. struct sde_hw_blk_reg_map *c;
  394. c = &ctx->hw;
  395. SDE_REG_WRITE(c, SSPP_UBWC_ERROR_STATUS, BIT(31));
  396. }
  397. static u32 sde_hw_sspp_get_ubwc_error(struct sde_hw_pipe *ctx,
  398. enum sde_sspp_multirect_index multirect_index)
  399. {
  400. struct sde_hw_blk_reg_map *c;
  401. u32 reg_code;
  402. c = &ctx->hw;
  403. reg_code = SDE_REG_READ(c, SSPP_UBWC_ERROR_STATUS);
  404. return reg_code;
  405. }
  406. static void sde_hw_sspp_clear_ubwc_error_v1(struct sde_hw_pipe *ctx,
  407. enum sde_sspp_multirect_index multirect_index)
  408. {
  409. struct sde_hw_blk_reg_map *c;
  410. c = &ctx->hw;
  411. if (multirect_index == SDE_SSPP_RECT_1)
  412. SDE_REG_WRITE(c, SSPP_UBWC_ERROR_STATUS_REC1, BIT(31));
  413. else
  414. SDE_REG_WRITE(c, SSPP_UBWC_ERROR_STATUS, BIT(31));
  415. }
  416. static u32 sde_hw_sspp_get_ubwc_error_v1(struct sde_hw_pipe *ctx,
  417. enum sde_sspp_multirect_index multirect_index)
  418. {
  419. struct sde_hw_blk_reg_map *c;
  420. u32 reg_code;
  421. c = &ctx->hw;
  422. if (multirect_index == SDE_SSPP_RECT_1)
  423. reg_code = SDE_REG_READ(c, SSPP_UBWC_ERROR_STATUS_REC1);
  424. else
  425. reg_code = SDE_REG_READ(c, SSPP_UBWC_ERROR_STATUS);
  426. return reg_code;
  427. }
  428. static void sde_hw_sspp_clear_meta_error(struct sde_hw_pipe *ctx,
  429. enum sde_sspp_multirect_index multirect_index)
  430. {
  431. struct sde_hw_blk_reg_map *c;
  432. c = &ctx->hw;
  433. if (multirect_index == SDE_SSPP_RECT_1)
  434. SDE_REG_WRITE(c, SSPP_META_ERROR_STATUS_REC1, BIT(31));
  435. else
  436. SDE_REG_WRITE(c, SSPP_META_ERROR_STATUS, BIT(31));
  437. }
  438. static u32 sde_hw_sspp_get_meta_error(struct sde_hw_pipe *ctx,
  439. enum sde_sspp_multirect_index multirect_index)
  440. {
  441. struct sde_hw_blk_reg_map *c;
  442. u32 reg_code;
  443. c = &ctx->hw;
  444. if (multirect_index == SDE_SSPP_RECT_1)
  445. reg_code = SDE_REG_READ(c, SSPP_META_ERROR_STATUS_REC1);
  446. else
  447. reg_code = SDE_REG_READ(c, SSPP_META_ERROR_STATUS);
  448. return reg_code;
  449. }
  450. static void sde_hw_sspp_ubwc_stats_set_roi(struct sde_hw_pipe *ctx,
  451. enum sde_sspp_multirect_index multirect_index,
  452. struct sde_drm_ubwc_stats_roi *roi)
  453. {
  454. struct sde_hw_blk_reg_map *c;
  455. u32 idx, ctrl_off, roi_off;
  456. u32 ctrl_val = 0, roi_val = 0;
  457. if (_sspp_subblk_offset(ctx, SDE_SSPP_SRC, &idx))
  458. return;
  459. if (multirect_index == SDE_SSPP_RECT_SOLO || multirect_index == SDE_SSPP_RECT_0) {
  460. ctrl_off = SSPP_UBWC_STATIC_CTRL + idx;
  461. roi_off = SSPP_UBWC_STATS_ROI + idx;
  462. } else {
  463. ctrl_off = SSPP_UBWC_STATIC_CTRL_REC1 + idx;
  464. roi_off = SSPP_UBWC_STATS_ROI_REC1 + idx;
  465. }
  466. c = &ctx->hw;
  467. ctrl_val = SDE_REG_READ(c, ctrl_off);
  468. if (roi) {
  469. ctrl_val |= BIT(24);
  470. if (roi->y_coord0) {
  471. ctrl_val |= BIT(25);
  472. roi_val |= roi->y_coord0;
  473. if (roi->y_coord1) {
  474. ctrl_val |= BIT(26);
  475. roi_val |= (roi->y_coord1) << 0x10;
  476. }
  477. }
  478. } else {
  479. ctrl_val &= ~(BIT(24) | BIT(25) | BIT(26));
  480. }
  481. SDE_REG_WRITE(c, ctrl_off, ctrl_val);
  482. SDE_REG_WRITE(c, roi_off, roi_val);
  483. }
  484. static void sde_hw_sspp_ubwc_stats_get_data(struct sde_hw_pipe *ctx,
  485. enum sde_sspp_multirect_index multirect_index,
  486. struct sde_drm_ubwc_stats_data *data)
  487. {
  488. struct sde_hw_blk_reg_map *c;
  489. u32 idx, value = 0;
  490. int i;
  491. if (_sspp_subblk_offset(ctx, SDE_SSPP_SRC, &idx))
  492. return;
  493. if (multirect_index == SDE_SSPP_RECT_SOLO || multirect_index == SDE_SSPP_RECT_0)
  494. idx += SSPP_UBWC_STATS_DATA;
  495. else
  496. idx += SSPP_UBWC_STATS_DATA_REC1;
  497. c = &ctx->hw;
  498. for (i = 0; i < UBWC_STATS_MAX_ROI; i++) {
  499. value = SDE_REG_READ(c, idx);
  500. data->worst_bw[i] = value & 0xFFFF;
  501. data->worst_bw_y_coord[i] = (value >> 0x10) & 0xFFFF;
  502. data->total_bw[i] = SDE_REG_READ(c, idx + 4);
  503. idx += 8;
  504. }
  505. }
  506. static void sde_hw_sspp_setup_secure(struct sde_hw_pipe *ctx,
  507. enum sde_sspp_multirect_index rect_mode,
  508. bool enable)
  509. {
  510. struct sde_hw_blk_reg_map *c;
  511. u32 secure = 0, secure_bit_mask;
  512. u32 idx;
  513. if (_sspp_subblk_offset(ctx, SDE_SSPP_SRC, &idx))
  514. return;
  515. c = &ctx->hw;
  516. if ((rect_mode == SDE_SSPP_RECT_SOLO)
  517. || (rect_mode == SDE_SSPP_RECT_0))
  518. secure_bit_mask =
  519. (rect_mode == SDE_SSPP_RECT_SOLO) ? 0xF : 0x5;
  520. else
  521. secure_bit_mask = 0xA;
  522. secure = SDE_REG_READ(c, SSPP_SRC_ADDR_SW_STATUS + idx);
  523. if (enable)
  524. secure |= secure_bit_mask;
  525. else
  526. secure &= ~secure_bit_mask;
  527. SDE_REG_WRITE(c, SSPP_SRC_ADDR_SW_STATUS + idx, secure);
  528. /* multiple planes share same sw_status register */
  529. wmb();
  530. }
  531. static void sde_hw_sspp_setup_pe_config(struct sde_hw_pipe *ctx,
  532. struct sde_hw_pixel_ext *pe_ext)
  533. {
  534. struct sde_hw_blk_reg_map *c;
  535. u8 color;
  536. u32 lr_pe[4], tb_pe[4], tot_req_pixels[4];
  537. const u32 bytemask = 0xff;
  538. const u32 shortmask = 0xffff;
  539. u32 idx;
  540. if (_sspp_subblk_offset(ctx, SDE_SSPP_SRC, &idx) || !pe_ext)
  541. return;
  542. c = &ctx->hw;
  543. /* program SW pixel extension override for all pipes*/
  544. for (color = 0; color < SDE_MAX_PLANES; color++) {
  545. /* color 2 has the same set of registers as color 1 */
  546. if (color == 2)
  547. continue;
  548. lr_pe[color] = ((pe_ext->right_ftch[color] & bytemask) << 24)|
  549. ((pe_ext->right_rpt[color] & bytemask) << 16)|
  550. ((pe_ext->left_ftch[color] & bytemask) << 8)|
  551. (pe_ext->left_rpt[color] & bytemask);
  552. tb_pe[color] = ((pe_ext->btm_ftch[color] & bytemask) << 24)|
  553. ((pe_ext->btm_rpt[color] & bytemask) << 16)|
  554. ((pe_ext->top_ftch[color] & bytemask) << 8)|
  555. (pe_ext->top_rpt[color] & bytemask);
  556. tot_req_pixels[color] = (((pe_ext->roi_h[color] +
  557. pe_ext->num_ext_pxls_top[color] +
  558. pe_ext->num_ext_pxls_btm[color]) & shortmask) << 16) |
  559. ((pe_ext->roi_w[color] +
  560. pe_ext->num_ext_pxls_left[color] +
  561. pe_ext->num_ext_pxls_right[color]) & shortmask);
  562. }
  563. /* color 0 */
  564. SDE_REG_WRITE(c, SSPP_SW_PIX_EXT_C0_LR + idx, lr_pe[0]);
  565. SDE_REG_WRITE(c, SSPP_SW_PIX_EXT_C0_TB + idx, tb_pe[0]);
  566. SDE_REG_WRITE(c, SSPP_SW_PIX_EXT_C0_REQ_PIXELS + idx,
  567. tot_req_pixels[0]);
  568. /* color 1 and color 2 */
  569. SDE_REG_WRITE(c, SSPP_SW_PIX_EXT_C1C2_LR + idx, lr_pe[1]);
  570. SDE_REG_WRITE(c, SSPP_SW_PIX_EXT_C1C2_TB + idx, tb_pe[1]);
  571. SDE_REG_WRITE(c, SSPP_SW_PIX_EXT_C1C2_REQ_PIXELS + idx,
  572. tot_req_pixels[1]);
  573. /* color 3 */
  574. SDE_REG_WRITE(c, SSPP_SW_PIX_EXT_C3_LR + idx, lr_pe[3]);
  575. SDE_REG_WRITE(c, SSPP_SW_PIX_EXT_C3_TB + idx, tb_pe[3]);
  576. SDE_REG_WRITE(c, SSPP_SW_PIX_EXT_C3_REQ_PIXELS + idx,
  577. tot_req_pixels[3]);
  578. }
  579. static void _sde_hw_sspp_setup_scaler(struct sde_hw_pipe *ctx,
  580. struct sde_hw_pipe_cfg *sspp,
  581. struct sde_hw_pixel_ext *pe,
  582. void *scaler_cfg)
  583. {
  584. struct sde_hw_blk_reg_map *c;
  585. int config_h = 0x0;
  586. int config_v = 0x0;
  587. u32 idx;
  588. (void)sspp;
  589. (void)scaler_cfg;
  590. if (_sspp_subblk_offset(ctx, SDE_SSPP_SCALER_QSEED2, &idx) || !pe)
  591. return;
  592. c = &ctx->hw;
  593. /* enable scaler(s) if valid filter set */
  594. if (pe->horz_filter[SDE_SSPP_COMP_0] < SDE_SCALE_FILTER_MAX)
  595. config_h |= pe->horz_filter[SDE_SSPP_COMP_0] << 8;
  596. if (pe->horz_filter[SDE_SSPP_COMP_1_2] < SDE_SCALE_FILTER_MAX)
  597. config_h |= pe->horz_filter[SDE_SSPP_COMP_1_2] << 12;
  598. if (pe->horz_filter[SDE_SSPP_COMP_3] < SDE_SCALE_FILTER_MAX)
  599. config_h |= pe->horz_filter[SDE_SSPP_COMP_3] << 16;
  600. if (config_h)
  601. config_h |= BIT(0);
  602. if (pe->vert_filter[SDE_SSPP_COMP_0] < SDE_SCALE_FILTER_MAX)
  603. config_v |= pe->vert_filter[SDE_SSPP_COMP_0] << 10;
  604. if (pe->vert_filter[SDE_SSPP_COMP_1_2] < SDE_SCALE_FILTER_MAX)
  605. config_v |= pe->vert_filter[SDE_SSPP_COMP_1_2] << 14;
  606. if (pe->vert_filter[SDE_SSPP_COMP_3] < SDE_SCALE_FILTER_MAX)
  607. config_v |= pe->vert_filter[SDE_SSPP_COMP_3] << 18;
  608. if (config_v)
  609. config_v |= BIT(1);
  610. SDE_REG_WRITE(c, SCALE_CONFIG + idx, config_h | config_v);
  611. SDE_REG_WRITE(c, COMP0_3_INIT_PHASE_X + idx,
  612. pe->init_phase_x[SDE_SSPP_COMP_0]);
  613. SDE_REG_WRITE(c, COMP0_3_INIT_PHASE_Y + idx,
  614. pe->init_phase_y[SDE_SSPP_COMP_0]);
  615. SDE_REG_WRITE(c, COMP0_3_PHASE_STEP_X + idx,
  616. pe->phase_step_x[SDE_SSPP_COMP_0]);
  617. SDE_REG_WRITE(c, COMP0_3_PHASE_STEP_Y + idx,
  618. pe->phase_step_y[SDE_SSPP_COMP_0]);
  619. SDE_REG_WRITE(c, COMP1_2_INIT_PHASE_X + idx,
  620. pe->init_phase_x[SDE_SSPP_COMP_1_2]);
  621. SDE_REG_WRITE(c, COMP1_2_INIT_PHASE_Y + idx,
  622. pe->init_phase_y[SDE_SSPP_COMP_1_2]);
  623. SDE_REG_WRITE(c, COMP1_2_PHASE_STEP_X + idx,
  624. pe->phase_step_x[SDE_SSPP_COMP_1_2]);
  625. SDE_REG_WRITE(c, COMP1_2_PHASE_STEP_Y + idx,
  626. pe->phase_step_y[SDE_SSPP_COMP_1_2]);
  627. }
  628. static void _sde_hw_sspp_setup_scaler3(struct sde_hw_pipe *ctx,
  629. struct sde_hw_pipe_cfg *sspp,
  630. struct sde_hw_pixel_ext *pe,
  631. void *scaler_cfg)
  632. {
  633. u32 idx;
  634. struct sde_hw_scaler3_cfg *scaler3_cfg = scaler_cfg;
  635. (void)pe;
  636. if (_sspp_subblk_offset(ctx, SDE_SSPP_SCALER_QSEED3, &idx) || !sspp
  637. || !scaler3_cfg || !ctx || !ctx->cap || !ctx->cap->sblk)
  638. return;
  639. sde_hw_setup_scaler3(&ctx->hw, scaler3_cfg,
  640. ctx->cap->sblk->scaler_blk.version, idx, sspp->layout.format);
  641. }
  642. static void sde_hw_sspp_setup_pre_downscale(struct sde_hw_pipe *ctx,
  643. struct sde_hw_inline_pre_downscale_cfg *pre_down)
  644. {
  645. u32 idx, val;
  646. if (!ctx || !pre_down || _sspp_subblk_offset(ctx, SDE_SSPP_SRC, &idx))
  647. return;
  648. val = pre_down->pre_downscale_x_0 |
  649. (pre_down->pre_downscale_x_1 << 4) |
  650. (pre_down->pre_downscale_y_0 << 8) |
  651. (pre_down->pre_downscale_y_1 << 12);
  652. SDE_REG_WRITE(&ctx->hw, SSPP_PRE_DOWN_SCALE + idx, val);
  653. }
  654. /**
  655. * sde_hw_sspp_setup_rects()
  656. */
  657. static void sde_hw_sspp_setup_rects(struct sde_hw_pipe *ctx,
  658. struct sde_hw_pipe_cfg *cfg,
  659. enum sde_sspp_multirect_index rect_index)
  660. {
  661. struct sde_hw_blk_reg_map *c;
  662. u32 src_size, src_xy, dst_size, dst_xy, ystride0, ystride1;
  663. u32 src_size_off, src_xy_off, out_size_off, out_xy_off;
  664. u32 decimation = 0;
  665. u32 idx;
  666. if (_sspp_subblk_offset(ctx, SDE_SSPP_SRC, &idx) || !cfg)
  667. return;
  668. c = &ctx->hw;
  669. if (rect_index == SDE_SSPP_RECT_SOLO || rect_index == SDE_SSPP_RECT_0) {
  670. src_size_off = SSPP_SRC_SIZE;
  671. src_xy_off = SSPP_SRC_XY;
  672. out_size_off = SSPP_OUT_SIZE;
  673. out_xy_off = SSPP_OUT_XY;
  674. } else {
  675. src_size_off = SSPP_SRC_SIZE_REC1;
  676. src_xy_off = SSPP_SRC_XY_REC1;
  677. out_size_off = SSPP_OUT_SIZE_REC1;
  678. out_xy_off = SSPP_OUT_XY_REC1;
  679. }
  680. /* src and dest rect programming */
  681. src_xy = (cfg->src_rect.y << 16) | (cfg->src_rect.x);
  682. src_size = (cfg->src_rect.h << 16) | (cfg->src_rect.w);
  683. dst_xy = (cfg->dst_rect.y << 16) | (cfg->dst_rect.x);
  684. dst_size = (cfg->dst_rect.h << 16) | (cfg->dst_rect.w);
  685. if (rect_index == SDE_SSPP_RECT_SOLO) {
  686. ystride0 = (cfg->layout.plane_pitch[0]) |
  687. (cfg->layout.plane_pitch[1] << 16);
  688. ystride1 = (cfg->layout.plane_pitch[2]) |
  689. (cfg->layout.plane_pitch[3] << 16);
  690. } else {
  691. ystride0 = SDE_REG_READ(c, SSPP_SRC_YSTRIDE0 + idx);
  692. ystride1 = SDE_REG_READ(c, SSPP_SRC_YSTRIDE1 + idx);
  693. if (rect_index == SDE_SSPP_RECT_0) {
  694. ystride0 = (ystride0 & 0xFFFF0000) |
  695. (cfg->layout.plane_pitch[0] & 0x0000FFFF);
  696. ystride1 = (ystride1 & 0xFFFF0000)|
  697. (cfg->layout.plane_pitch[2] & 0x0000FFFF);
  698. } else {
  699. ystride0 = (ystride0 & 0x0000FFFF) |
  700. ((cfg->layout.plane_pitch[0] << 16) &
  701. 0xFFFF0000);
  702. ystride1 = (ystride1 & 0x0000FFFF) |
  703. ((cfg->layout.plane_pitch[2] << 16) &
  704. 0xFFFF0000);
  705. }
  706. }
  707. /* program scaler, phase registers, if pipes supporting scaling */
  708. if (ctx->cap->features & SDE_SSPP_SCALER) {
  709. /* program decimation */
  710. decimation = ((1 << cfg->horz_decimation) - 1) << 8;
  711. decimation |= ((1 << cfg->vert_decimation) - 1);
  712. }
  713. /* rectangle register programming */
  714. SDE_REG_WRITE(c, src_size_off + idx, src_size);
  715. SDE_REG_WRITE(c, src_xy_off + idx, src_xy);
  716. SDE_REG_WRITE(c, out_size_off + idx, dst_size);
  717. SDE_REG_WRITE(c, out_xy_off + idx, dst_xy);
  718. SDE_REG_WRITE(c, SSPP_SRC_YSTRIDE0 + idx, ystride0);
  719. SDE_REG_WRITE(c, SSPP_SRC_YSTRIDE1 + idx, ystride1);
  720. SDE_REG_WRITE(c, SSPP_DECIMATION_CONFIG + idx, decimation);
  721. }
  722. /**
  723. * _sde_hw_sspp_setup_excl_rect() - set exclusion rect configs
  724. * @ctx: Pointer to pipe context
  725. * @excl_rect: Exclusion rect configs
  726. */
  727. static void _sde_hw_sspp_setup_excl_rect(struct sde_hw_pipe *ctx,
  728. struct sde_rect *excl_rect,
  729. enum sde_sspp_multirect_index rect_index)
  730. {
  731. struct sde_hw_blk_reg_map *c;
  732. u32 size, xy;
  733. u32 idx;
  734. u32 reg_xy, reg_size;
  735. u32 excl_ctrl = BIT(0);
  736. u32 enable_bit;
  737. if (_sspp_subblk_offset(ctx, SDE_SSPP_SRC, &idx) || !excl_rect)
  738. return;
  739. if (rect_index == SDE_SSPP_RECT_0 || rect_index == SDE_SSPP_RECT_SOLO) {
  740. reg_xy = SSPP_EXCL_REC_XY;
  741. reg_size = SSPP_EXCL_REC_SIZE;
  742. enable_bit = BIT(0);
  743. } else {
  744. reg_xy = SSPP_EXCL_REC_XY_REC1;
  745. reg_size = SSPP_EXCL_REC_SIZE_REC1;
  746. enable_bit = BIT(1);
  747. }
  748. c = &ctx->hw;
  749. xy = (excl_rect->y << 16) | (excl_rect->x);
  750. size = (excl_rect->h << 16) | (excl_rect->w);
  751. /* Set if multi-rect disabled, read+modify only if multi-rect enabled */
  752. if (rect_index != SDE_SSPP_RECT_SOLO)
  753. excl_ctrl = SDE_REG_READ(c, SSPP_EXCL_REC_CTL + idx);
  754. if (!size) {
  755. SDE_REG_WRITE(c, SSPP_EXCL_REC_CTL + idx,
  756. excl_ctrl & ~enable_bit);
  757. } else {
  758. SDE_REG_WRITE(c, SSPP_EXCL_REC_CTL + idx,
  759. excl_ctrl | enable_bit);
  760. SDE_REG_WRITE(c, reg_size + idx, size);
  761. SDE_REG_WRITE(c, reg_xy + idx, xy);
  762. }
  763. }
  764. static void sde_hw_sspp_setup_sourceaddress(struct sde_hw_pipe *ctx,
  765. struct sde_hw_pipe_cfg *cfg,
  766. enum sde_sspp_multirect_index rect_mode)
  767. {
  768. int i;
  769. u32 idx;
  770. if (_sspp_subblk_offset(ctx, SDE_SSPP_SRC, &idx))
  771. return;
  772. if (rect_mode == SDE_SSPP_RECT_SOLO) {
  773. for (i = 0; i < ARRAY_SIZE(cfg->layout.plane_addr); i++)
  774. SDE_REG_WRITE(&ctx->hw, SSPP_SRC0_ADDR + idx + i * 0x4,
  775. cfg->layout.plane_addr[i]);
  776. } else if (rect_mode == SDE_SSPP_RECT_0) {
  777. SDE_REG_WRITE(&ctx->hw, SSPP_SRC0_ADDR + idx,
  778. cfg->layout.plane_addr[0]);
  779. SDE_REG_WRITE(&ctx->hw, SSPP_SRC2_ADDR + idx,
  780. cfg->layout.plane_addr[2]);
  781. } else {
  782. SDE_REG_WRITE(&ctx->hw, SSPP_SRC1_ADDR + idx,
  783. cfg->layout.plane_addr[0]);
  784. SDE_REG_WRITE(&ctx->hw, SSPP_SRC3_ADDR + idx,
  785. cfg->layout.plane_addr[2]);
  786. }
  787. }
  788. u32 sde_hw_sspp_get_source_addr(struct sde_hw_pipe *ctx, bool is_virtual)
  789. {
  790. u32 idx;
  791. u32 offset = 0;
  792. if (!ctx || _sspp_subblk_offset(ctx, SDE_SSPP_SRC, &idx))
  793. return 0;
  794. offset = is_virtual ? (SSPP_SRC1_ADDR + idx) : (SSPP_SRC0_ADDR + idx);
  795. return SDE_REG_READ(&ctx->hw, offset);
  796. }
  797. static void sde_hw_sspp_setup_csc(struct sde_hw_pipe *ctx,
  798. struct sde_csc_cfg *data)
  799. {
  800. u32 idx;
  801. bool csc10 = false;
  802. if (_sspp_subblk_offset(ctx, SDE_SSPP_CSC, &idx) || !data)
  803. return;
  804. if (test_bit(SDE_SSPP_CSC_10BIT, &ctx->cap->features)) {
  805. idx += CSC_10BIT_OFFSET;
  806. csc10 = true;
  807. }
  808. sde_hw_csc_setup(&ctx->hw, idx, data, csc10);
  809. }
  810. static void sde_hw_sspp_setup_sharpening(struct sde_hw_pipe *ctx,
  811. struct sde_hw_sharp_cfg *cfg)
  812. {
  813. struct sde_hw_blk_reg_map *c;
  814. u32 idx;
  815. if (_sspp_subblk_offset(ctx, SDE_SSPP_SCALER_QSEED2, &idx) || !cfg ||
  816. !test_bit(SDE_SSPP_SCALER_QSEED2, &ctx->cap->features))
  817. return;
  818. c = &ctx->hw;
  819. SDE_REG_WRITE(c, VIG_0_QSEED2_SHARP + idx, cfg->strength);
  820. SDE_REG_WRITE(c, VIG_0_QSEED2_SHARP + idx + 0x4, cfg->edge_thr);
  821. SDE_REG_WRITE(c, VIG_0_QSEED2_SHARP + idx + 0x8, cfg->smooth_thr);
  822. SDE_REG_WRITE(c, VIG_0_QSEED2_SHARP + idx + 0xC, cfg->noise_thr);
  823. }
  824. static void sde_hw_sspp_setup_solidfill(struct sde_hw_pipe *ctx, u32 color, enum
  825. sde_sspp_multirect_index rect_index)
  826. {
  827. u32 idx;
  828. if (_sspp_subblk_offset(ctx, SDE_SSPP_SRC, &idx))
  829. return;
  830. if (rect_index == SDE_SSPP_RECT_SOLO || rect_index == SDE_SSPP_RECT_0)
  831. SDE_REG_WRITE(&ctx->hw, SSPP_SRC_CONSTANT_COLOR + idx, color);
  832. else
  833. SDE_REG_WRITE(&ctx->hw, SSPP_SRC_CONSTANT_COLOR_REC1 + idx,
  834. color);
  835. }
  836. static void sde_hw_sspp_setup_qos_lut(struct sde_hw_pipe *ctx,
  837. struct sde_hw_pipe_qos_cfg *cfg)
  838. {
  839. u32 idx;
  840. if (_sspp_subblk_offset(ctx, SDE_SSPP_SRC, &idx))
  841. return;
  842. SDE_REG_WRITE(&ctx->hw, SSPP_DANGER_LUT + idx, cfg->danger_lut);
  843. SDE_REG_WRITE(&ctx->hw, SSPP_SAFE_LUT + idx, cfg->safe_lut);
  844. if (ctx->cap && test_bit(SDE_PERF_SSPP_QOS_8LVL,
  845. &ctx->cap->perf_features)) {
  846. SDE_REG_WRITE(&ctx->hw, SSPP_CREQ_LUT_0 + idx, cfg->creq_lut);
  847. SDE_REG_WRITE(&ctx->hw, SSPP_CREQ_LUT_1 + idx,
  848. cfg->creq_lut >> 32);
  849. } else {
  850. SDE_REG_WRITE(&ctx->hw, SSPP_CREQ_LUT + idx, cfg->creq_lut);
  851. }
  852. }
  853. static void sde_hw_sspp_setup_qos_ctrl(struct sde_hw_pipe *ctx,
  854. struct sde_hw_pipe_qos_cfg *cfg)
  855. {
  856. u32 idx;
  857. u32 qos_ctrl = 0;
  858. if (_sspp_subblk_offset(ctx, SDE_SSPP_SRC, &idx))
  859. return;
  860. if (cfg->vblank_en) {
  861. qos_ctrl |= ((cfg->creq_vblank &
  862. SSPP_QOS_CTRL_CREQ_VBLANK_MASK) <<
  863. SSPP_QOS_CTRL_CREQ_VBLANK_OFF);
  864. qos_ctrl |= ((cfg->danger_vblank &
  865. SSPP_QOS_CTRL_DANGER_VBLANK_MASK) <<
  866. SSPP_QOS_CTRL_DANGER_VBLANK_OFF);
  867. qos_ctrl |= SSPP_QOS_CTRL_VBLANK_EN;
  868. }
  869. if (cfg->danger_safe_en)
  870. qos_ctrl |= SSPP_QOS_CTRL_DANGER_SAFE_EN;
  871. SDE_REG_WRITE(&ctx->hw, SSPP_QOS_CTRL + idx, qos_ctrl);
  872. }
  873. static void sde_hw_sspp_setup_ts_prefill(struct sde_hw_pipe *ctx,
  874. struct sde_hw_pipe_ts_cfg *cfg,
  875. enum sde_sspp_multirect_index index)
  876. {
  877. u32 idx;
  878. u32 ts_offset, ts_prefill_offset;
  879. u32 ts_count = 0, ts_bytes = 0;
  880. const struct sde_sspp_cfg *cap;
  881. if (!ctx || !cfg || !ctx->cap)
  882. return;
  883. if (_sspp_subblk_offset(ctx, SDE_SSPP_SRC, &idx))
  884. return;
  885. cap = ctx->cap;
  886. if ((index == SDE_SSPP_RECT_SOLO || index == SDE_SSPP_RECT_0) &&
  887. test_bit(SDE_PERF_SSPP_TS_PREFILL,
  888. &cap->perf_features)) {
  889. ts_offset = SSPP_TRAFFIC_SHAPER;
  890. ts_prefill_offset = SSPP_TRAFFIC_SHAPER_PREFILL;
  891. } else if (index == SDE_SSPP_RECT_1 &&
  892. test_bit(SDE_PERF_SSPP_TS_PREFILL_REC1,
  893. &cap->perf_features)) {
  894. ts_offset = SSPP_TRAFFIC_SHAPER_REC1;
  895. ts_prefill_offset = SSPP_TRAFFIC_SHAPER_REC1_PREFILL;
  896. } else {
  897. pr_err("%s: unexpected idx:%d\n", __func__, index);
  898. return;
  899. }
  900. if (cfg->time) {
  901. u64 temp = DIV_ROUND_UP_ULL(TS_CLK * 1000000ULL, cfg->time);
  902. ts_bytes = temp * cfg->size;
  903. if (ts_bytes > SSPP_TRAFFIC_SHAPER_BPC_MAX)
  904. ts_bytes = SSPP_TRAFFIC_SHAPER_BPC_MAX;
  905. }
  906. if (ts_bytes) {
  907. ts_count = DIV_ROUND_UP_ULL(cfg->size, ts_bytes);
  908. ts_bytes |= BIT(31) | BIT(27);
  909. }
  910. SDE_REG_WRITE(&ctx->hw, ts_offset, ts_bytes);
  911. SDE_REG_WRITE(&ctx->hw, ts_prefill_offset, ts_count);
  912. }
  913. static void sde_hw_sspp_setup_cdp(struct sde_hw_pipe *ctx,
  914. struct sde_hw_pipe_cdp_cfg *cfg,
  915. enum sde_sspp_multirect_index index)
  916. {
  917. u32 idx;
  918. u32 cdp_cntl = 0;
  919. u32 cdp_cntl_offset = 0;
  920. if (!ctx || !cfg)
  921. return;
  922. if (_sspp_subblk_offset(ctx, SDE_SSPP_SRC, &idx))
  923. return;
  924. if (index == SDE_SSPP_RECT_SOLO || index == SDE_SSPP_RECT_0) {
  925. cdp_cntl_offset = SSPP_CDP_CNTL;
  926. } else if (index == SDE_SSPP_RECT_1) {
  927. cdp_cntl_offset = SSPP_CDP_CNTL_REC1;
  928. } else {
  929. pr_err("%s: unexpected idx:%d\n", __func__, index);
  930. return;
  931. }
  932. if (cfg->enable)
  933. cdp_cntl |= BIT(0);
  934. if (cfg->ubwc_meta_enable)
  935. cdp_cntl |= BIT(1);
  936. if (cfg->tile_amortize_enable)
  937. cdp_cntl |= BIT(2);
  938. if (cfg->preload_ahead == SDE_SSPP_CDP_PRELOAD_AHEAD_64)
  939. cdp_cntl |= BIT(3);
  940. SDE_REG_WRITE(&ctx->hw, cdp_cntl_offset, cdp_cntl);
  941. }
  942. static void sde_hw_sspp_setup_sys_cache(struct sde_hw_pipe *ctx,
  943. struct sde_hw_pipe_sc_cfg *cfg)
  944. {
  945. u32 idx, val;
  946. if (_sspp_subblk_offset(ctx, SDE_SSPP_SRC, &idx))
  947. return;
  948. if (!cfg)
  949. return;
  950. val = SDE_REG_READ(&ctx->hw, SSPP_SYS_CACHE_MODE + idx);
  951. if (cfg->flags & SSPP_SYS_CACHE_EN_FLAG)
  952. val = (val & ~BIT(15)) | ((cfg->rd_en & 0x1) << 15);
  953. if (cfg->flags & SSPP_SYS_CACHE_SCID)
  954. val = (val & ~0x1F00) | ((cfg->rd_scid & 0x1f) << 8);
  955. if (cfg->flags & SSPP_SYS_CACHE_OP_MODE)
  956. val = (val & ~0xC0000) | ((cfg->op_mode & 0x3) << 18);
  957. if (cfg->flags & SSPP_SYS_CACHE_OP_TYPE)
  958. val = (val & ~0xF) | ((cfg->rd_op_type & 0xf) << 0);
  959. if (cfg->flags & SSPP_SYS_CACHE_NO_ALLOC)
  960. val = (val & ~0x10) | ((cfg->rd_noallocate & 0x1) << 4);
  961. SDE_REG_WRITE(&ctx->hw, SSPP_SYS_CACHE_MODE + idx, val);
  962. }
  963. static void sde_hw_sspp_setup_uidle(struct sde_hw_pipe *ctx,
  964. struct sde_hw_pipe_uidle_cfg *cfg,
  965. enum sde_sspp_multirect_index index)
  966. {
  967. u32 idx, val;
  968. u32 offset;
  969. if (_sspp_subblk_offset(ctx, SDE_SSPP_SRC, &idx))
  970. return;
  971. if (index == SDE_SSPP_RECT_1)
  972. offset = SSPP_UIDLE_CTRL_VALUE_REC1;
  973. else
  974. offset = SSPP_UIDLE_CTRL_VALUE;
  975. val = SDE_REG_READ(&ctx->hw, offset + idx);
  976. val = (val & ~BIT(31)) | (cfg->enable ? 0x0 : BIT(31));
  977. val = (val & ~0xFF00000) | (cfg->fal_allowed_threshold << 20);
  978. val = (val & ~0xF0000) | (cfg->fal10_exit_threshold << 16);
  979. val = (val & ~0xF00) | (cfg->fal10_threshold << 8);
  980. val = (val & ~0xF) | (cfg->fal1_threshold << 0);
  981. SDE_REG_WRITE(&ctx->hw, offset + idx, val);
  982. }
  983. static void _setup_layer_ops_colorproc(struct sde_hw_pipe *c,
  984. unsigned long features, bool is_virtual_pipe)
  985. {
  986. int ret = 0;
  987. if (is_virtual_pipe) {
  988. features &=
  989. ~(BIT(SDE_SSPP_VIG_IGC) | BIT(SDE_SSPP_VIG_GAMUT));
  990. c->cap->features = features;
  991. }
  992. if (test_bit(SDE_SSPP_HSIC, &features)) {
  993. if (c->cap->sblk->hsic_blk.version ==
  994. (SDE_COLOR_PROCESS_VER(0x1, 0x7))) {
  995. c->ops.setup_pa_hue = sde_setup_pipe_pa_hue_v1_7;
  996. c->ops.setup_pa_sat = sde_setup_pipe_pa_sat_v1_7;
  997. c->ops.setup_pa_val = sde_setup_pipe_pa_val_v1_7;
  998. c->ops.setup_pa_cont = sde_setup_pipe_pa_cont_v1_7;
  999. }
  1000. }
  1001. if (test_bit(SDE_SSPP_MEMCOLOR, &features)) {
  1002. if (c->cap->sblk->memcolor_blk.version ==
  1003. (SDE_COLOR_PROCESS_VER(0x1, 0x7)))
  1004. c->ops.setup_pa_memcolor =
  1005. sde_setup_pipe_pa_memcol_v1_7;
  1006. }
  1007. if (test_bit(SDE_SSPP_VIG_GAMUT, &features)) {
  1008. if (c->cap->sblk->gamut_blk.version ==
  1009. (SDE_COLOR_PROCESS_VER(0x5, 0x0))) {
  1010. ret = reg_dmav1_init_sspp_op_v4(SDE_SSPP_VIG_GAMUT,
  1011. c->idx);
  1012. if (!ret)
  1013. c->ops.setup_vig_gamut =
  1014. reg_dmav1_setup_vig_gamutv5;
  1015. else
  1016. c->ops.setup_vig_gamut = NULL;
  1017. }
  1018. if (c->cap->sblk->gamut_blk.version ==
  1019. (SDE_COLOR_PROCESS_VER(0x6, 0x0))) {
  1020. ret = reg_dmav1_init_sspp_op_v4(SDE_SSPP_VIG_GAMUT,
  1021. c->idx);
  1022. if (!ret)
  1023. c->ops.setup_vig_gamut =
  1024. reg_dmav1_setup_vig_gamutv6;
  1025. else
  1026. c->ops.setup_vig_gamut = NULL;
  1027. } else if (c->cap->sblk->gamut_blk.version ==
  1028. (SDE_COLOR_PROCESS_VER(0x6, 0x1))) {
  1029. ret = reg_dmav1_init_sspp_op_v4(SDE_SSPP_VIG_GAMUT,
  1030. c->idx);
  1031. if (!ret)
  1032. c->ops.setup_vig_gamut =
  1033. reg_dmav2_setup_vig_gamutv61;
  1034. else
  1035. c->ops.setup_vig_gamut = NULL;
  1036. }
  1037. }
  1038. if (test_bit(SDE_SSPP_VIG_IGC, &features)) {
  1039. if (c->cap->sblk->igc_blk[0].version ==
  1040. (SDE_COLOR_PROCESS_VER(0x5, 0x0))) {
  1041. ret = reg_dmav1_init_sspp_op_v4(SDE_SSPP_VIG_IGC,
  1042. c->idx);
  1043. if (!ret)
  1044. c->ops.setup_vig_igc =
  1045. reg_dmav1_setup_vig_igcv5;
  1046. else
  1047. c->ops.setup_vig_igc = NULL;
  1048. }
  1049. if (c->cap->sblk->igc_blk[0].version ==
  1050. (SDE_COLOR_PROCESS_VER(0x6, 0x0))) {
  1051. ret = reg_dmav1_init_sspp_op_v4(SDE_SSPP_VIG_IGC,
  1052. c->idx);
  1053. if (!ret)
  1054. c->ops.setup_vig_igc =
  1055. reg_dmav1_setup_vig_igcv6;
  1056. else
  1057. c->ops.setup_vig_igc = NULL;
  1058. }
  1059. }
  1060. if (test_bit(SDE_SSPP_DMA_IGC, &features)) {
  1061. if (c->cap->sblk->igc_blk[0].version ==
  1062. (SDE_COLOR_PROCESS_VER(0x5, 0x0))) {
  1063. ret = reg_dmav1_init_sspp_op_v4(SDE_SSPP_DMA_IGC,
  1064. c->idx);
  1065. if (!ret)
  1066. c->ops.setup_dma_igc =
  1067. reg_dmav1_setup_dma_igcv5;
  1068. else
  1069. c->ops.setup_dma_igc = NULL;
  1070. }
  1071. }
  1072. if (test_bit(SDE_SSPP_DMA_GC, &features)) {
  1073. if (c->cap->sblk->gc_blk[0].version ==
  1074. (SDE_COLOR_PROCESS_VER(0x5, 0x0))) {
  1075. ret = reg_dmav1_init_sspp_op_v4(SDE_SSPP_DMA_GC,
  1076. c->idx);
  1077. if (!ret)
  1078. c->ops.setup_dma_gc =
  1079. reg_dmav1_setup_dma_gcv5;
  1080. else
  1081. c->ops.setup_dma_gc = NULL;
  1082. }
  1083. }
  1084. if (test_bit(SDE_SSPP_FP16_IGC, &features) &&
  1085. IS_SDE_CP_VER_1_0(c->cap->sblk->fp16_igc_blk[0].version))
  1086. c->ops.setup_fp16_igc = sde_setup_fp16_igcv1;
  1087. if (test_bit(SDE_SSPP_FP16_GC, &features) &&
  1088. IS_SDE_CP_VER_1_0(c->cap->sblk->fp16_gc_blk[0].version))
  1089. c->ops.setup_fp16_gc = sde_setup_fp16_gcv1;
  1090. if (test_bit(SDE_SSPP_FP16_CSC, &features) &&
  1091. IS_SDE_CP_VER_1_0(c->cap->sblk->fp16_csc_blk[0].version))
  1092. c->ops.setup_fp16_csc = sde_setup_fp16_cscv1;
  1093. if (test_bit(SDE_SSPP_FP16_UNMULT, &features) &&
  1094. IS_SDE_CP_VER_1_0(c->cap->sblk->fp16_unmult_blk[0].version))
  1095. c->ops.setup_fp16_unmult = sde_setup_fp16_unmultv1;
  1096. }
  1097. static void sde_hw_sspp_setup_inverse_pma(struct sde_hw_pipe *ctx,
  1098. enum sde_sspp_multirect_index index, u32 enable)
  1099. {
  1100. u32 op_mode = 0;
  1101. u32 offset;
  1102. if (!ctx || (index == SDE_SSPP_RECT_1))
  1103. return;
  1104. offset = ctx->cap->sblk->unmult_offset[0];
  1105. if (enable)
  1106. op_mode |= BIT(0);
  1107. SDE_REG_WRITE(&ctx->hw, offset, op_mode);
  1108. }
  1109. static void sde_hw_sspp_setup_dgm_inverse_pma(struct sde_hw_pipe *ctx,
  1110. enum sde_sspp_multirect_index index, u32 enable)
  1111. {
  1112. u32 offset;
  1113. u32 op_mode = 0;
  1114. if (!ctx)
  1115. return;
  1116. if (index == SDE_SSPP_RECT_1)
  1117. offset = ctx->cap->sblk->unmult_offset[1];
  1118. else
  1119. offset = ctx->cap->sblk->unmult_offset[0];
  1120. op_mode = SDE_REG_READ(&ctx->hw, offset);
  1121. if (enable)
  1122. op_mode |= BIT(0);
  1123. else
  1124. op_mode &= ~BIT(0);
  1125. SDE_REG_WRITE(&ctx->hw, offset, op_mode);
  1126. }
  1127. static void sde_hw_sspp_setup_dgm_csc(struct sde_hw_pipe *ctx,
  1128. enum sde_sspp_multirect_index index, struct sde_csc_cfg *data)
  1129. {
  1130. u32 idx = 0;
  1131. u32 offset;
  1132. u32 op_mode = 0;
  1133. const struct sde_sspp_sub_blks *sblk;
  1134. if (!ctx || !ctx->cap || !ctx->cap->sblk)
  1135. return;
  1136. sblk = ctx->cap->sblk;
  1137. if (index == SDE_SSPP_RECT_1)
  1138. idx = 1;
  1139. offset = sblk->dgm_csc_blk[idx].base;
  1140. if (data) {
  1141. op_mode |= BIT(0);
  1142. sde_hw_csc_matrix_coeff_setup(&ctx->hw,
  1143. offset + CSC_10BIT_OFFSET, data, DGM_CSC_MATRIX_SHIFT);
  1144. }
  1145. SDE_REG_WRITE(&ctx->hw, offset, op_mode);
  1146. }
  1147. static void _setup_layer_ops(struct sde_hw_pipe *c,
  1148. unsigned long features, unsigned long perf_features,
  1149. bool is_virtual_pipe)
  1150. {
  1151. int ret;
  1152. if (test_bit(SDE_SSPP_SRC, &features)) {
  1153. c->ops.setup_format = sde_hw_sspp_setup_format;
  1154. c->ops.setup_rects = sde_hw_sspp_setup_rects;
  1155. c->ops.setup_sourceaddress = sde_hw_sspp_setup_sourceaddress;
  1156. c->ops.get_sourceaddress = sde_hw_sspp_get_source_addr;
  1157. c->ops.setup_solidfill = sde_hw_sspp_setup_solidfill;
  1158. c->ops.setup_pe = sde_hw_sspp_setup_pe_config;
  1159. c->ops.setup_secure_address = sde_hw_sspp_setup_secure;
  1160. c->ops.set_src_split_order = sde_hw_sspp_set_src_split_order;
  1161. }
  1162. if (test_bit(SDE_SSPP_EXCL_RECT, &features))
  1163. c->ops.setup_excl_rect = _sde_hw_sspp_setup_excl_rect;
  1164. if (test_bit(SDE_PERF_SSPP_QOS, &features)) {
  1165. c->ops.setup_qos_lut =
  1166. sde_hw_sspp_setup_qos_lut;
  1167. c->ops.setup_qos_ctrl = sde_hw_sspp_setup_qos_ctrl;
  1168. }
  1169. if (test_bit(SDE_PERF_SSPP_TS_PREFILL, &perf_features))
  1170. c->ops.setup_ts_prefill = sde_hw_sspp_setup_ts_prefill;
  1171. if (test_bit(SDE_SSPP_CSC, &features) ||
  1172. test_bit(SDE_SSPP_CSC_10BIT, &features))
  1173. c->ops.setup_csc = sde_hw_sspp_setup_csc;
  1174. if (test_bit(SDE_SSPP_DGM_CSC, &features))
  1175. c->ops.setup_dgm_csc = sde_hw_sspp_setup_dgm_csc;
  1176. if (test_bit(SDE_SSPP_SCALER_QSEED2, &features)) {
  1177. c->ops.setup_sharpening = sde_hw_sspp_setup_sharpening;
  1178. c->ops.setup_scaler = _sde_hw_sspp_setup_scaler;
  1179. }
  1180. if (sde_hw_sspp_multirect_enabled(c->cap))
  1181. c->ops.update_multirect = sde_hw_sspp_update_multirect;
  1182. if (test_bit(SDE_SSPP_SCALER_QSEED3, &features) ||
  1183. test_bit(SDE_SSPP_SCALER_QSEED3LITE, &features)) {
  1184. c->ops.setup_scaler = _sde_hw_sspp_setup_scaler3;
  1185. c->ops.setup_scaler_lut = is_qseed3_rev_qseed3lite(
  1186. c->catalog) ? reg_dmav1_setup_scaler3lite_lut
  1187. : reg_dmav1_setup_scaler3_lut;
  1188. ret = reg_dmav1_init_sspp_op_v4(is_qseed3_rev_qseed3lite(
  1189. c->catalog) ? SDE_SSPP_SCALER_QSEED3LITE
  1190. : SDE_SSPP_SCALER_QSEED3, c->idx);
  1191. if (!ret)
  1192. c->ops.setup_scaler = reg_dmav1_setup_vig_qseed3;
  1193. }
  1194. if (test_bit(SDE_SSPP_MULTIRECT_ERROR, &features)) {
  1195. c->ops.get_meta_error = sde_hw_sspp_get_meta_error;
  1196. c->ops.clear_meta_error = sde_hw_sspp_clear_meta_error;
  1197. c->ops.get_ubwc_error = sde_hw_sspp_get_ubwc_error_v1;
  1198. c->ops.clear_ubwc_error = sde_hw_sspp_clear_ubwc_error_v1;
  1199. } else {
  1200. c->ops.get_ubwc_error = sde_hw_sspp_get_ubwc_error;
  1201. c->ops.clear_ubwc_error = sde_hw_sspp_clear_ubwc_error;
  1202. }
  1203. if (test_bit(SDE_SSPP_PREDOWNSCALE, &features))
  1204. c->ops.setup_pre_downscale = sde_hw_sspp_setup_pre_downscale;
  1205. if (test_bit(SDE_PERF_SSPP_SYS_CACHE, &perf_features))
  1206. c->ops.setup_sys_cache = sde_hw_sspp_setup_sys_cache;
  1207. if (test_bit(SDE_PERF_SSPP_CDP, &perf_features))
  1208. c->ops.setup_cdp = sde_hw_sspp_setup_cdp;
  1209. if (test_bit(SDE_PERF_SSPP_UIDLE, &perf_features))
  1210. c->ops.setup_uidle = sde_hw_sspp_setup_uidle;
  1211. _setup_layer_ops_colorproc(c, features, is_virtual_pipe);
  1212. if (test_bit(SDE_SSPP_DGM_INVERSE_PMA, &features))
  1213. c->ops.setup_inverse_pma = sde_hw_sspp_setup_dgm_inverse_pma;
  1214. else if (test_bit(SDE_SSPP_INVERSE_PMA, &features))
  1215. c->ops.setup_inverse_pma = sde_hw_sspp_setup_inverse_pma;
  1216. if (test_bit(SDE_SSPP_UBWC_STATS, &features)) {
  1217. c->ops.set_ubwc_stats_roi = sde_hw_sspp_ubwc_stats_set_roi;
  1218. c->ops.get_ubwc_stats_data = sde_hw_sspp_ubwc_stats_get_data;
  1219. }
  1220. }
  1221. static struct sde_sspp_cfg *_sspp_offset(enum sde_sspp sspp,
  1222. void __iomem *addr,
  1223. struct sde_mdss_cfg *catalog,
  1224. struct sde_hw_blk_reg_map *b)
  1225. {
  1226. int i;
  1227. struct sde_sspp_cfg *cfg;
  1228. if ((sspp < SSPP_MAX) && catalog && addr && b) {
  1229. for (i = 0; i < catalog->sspp_count; i++) {
  1230. if (sspp == catalog->sspp[i].id) {
  1231. b->base_off = addr;
  1232. b->blk_off = catalog->sspp[i].base;
  1233. b->length = catalog->sspp[i].len;
  1234. b->hwversion = catalog->hwversion;
  1235. b->log_mask = SDE_DBG_MASK_SSPP;
  1236. /* Only shallow copy is needed */
  1237. cfg = kmemdup(&catalog->sspp[i], sizeof(*cfg),
  1238. GFP_KERNEL);
  1239. if (!cfg)
  1240. return ERR_PTR(-ENOMEM);
  1241. return cfg;
  1242. }
  1243. }
  1244. }
  1245. return ERR_PTR(-ENOMEM);
  1246. }
  1247. static struct sde_hw_blk_ops sde_hw_ops = {
  1248. .start = NULL,
  1249. .stop = NULL,
  1250. };
  1251. struct sde_hw_pipe *sde_hw_sspp_init(enum sde_sspp idx,
  1252. void __iomem *addr, struct sde_mdss_cfg *catalog,
  1253. bool is_virtual_pipe)
  1254. {
  1255. struct sde_hw_pipe *hw_pipe;
  1256. struct sde_sspp_cfg *cfg;
  1257. int rc;
  1258. if (!addr || !catalog)
  1259. return ERR_PTR(-EINVAL);
  1260. hw_pipe = kzalloc(sizeof(*hw_pipe), GFP_KERNEL);
  1261. if (!hw_pipe)
  1262. return ERR_PTR(-ENOMEM);
  1263. cfg = _sspp_offset(idx, addr, catalog, &hw_pipe->hw);
  1264. if (IS_ERR_OR_NULL(cfg)) {
  1265. kfree(hw_pipe);
  1266. return ERR_PTR(-EINVAL);
  1267. }
  1268. /* Assign ops */
  1269. hw_pipe->catalog = catalog;
  1270. hw_pipe->mdp = &catalog->mdp[0];
  1271. hw_pipe->idx = idx;
  1272. hw_pipe->cap = cfg;
  1273. _setup_layer_ops(hw_pipe, hw_pipe->cap->features,
  1274. hw_pipe->cap->perf_features, is_virtual_pipe);
  1275. if (catalog->qseed_hw_version)
  1276. sde_init_scaler_blk(&hw_pipe->cap->sblk->scaler_blk,
  1277. catalog->qseed_hw_version);
  1278. rc = sde_hw_blk_init(&hw_pipe->base, SDE_HW_BLK_SSPP, idx, &sde_hw_ops);
  1279. if (rc) {
  1280. SDE_ERROR("failed to init hw blk %d\n", rc);
  1281. goto blk_init_error;
  1282. }
  1283. if (!is_virtual_pipe) {
  1284. sde_dbg_reg_register_dump_range(SDE_DBG_NAME, cfg->name,
  1285. hw_pipe->hw.blk_off,
  1286. hw_pipe->hw.blk_off + hw_pipe->hw.length,
  1287. hw_pipe->hw.xin_id);
  1288. if (test_bit(SDE_SSPP_DGM_CSC, &hw_pipe->cap->features)) {
  1289. sde_dbg_reg_register_dump_range(SDE_DBG_NAME, "CSC_0",
  1290. hw_pipe->hw.blk_off + SSPP_DGM_CSC_0,
  1291. hw_pipe->hw.blk_off + SSPP_DGM_CSC_0 + SSPP_DGM_CSC_SIZE,
  1292. hw_pipe->hw.xin_id);
  1293. sde_dbg_reg_register_dump_range(SDE_DBG_NAME, "CSC_1",
  1294. hw_pipe->hw.blk_off + SSPP_DGM_CSC_1,
  1295. hw_pipe->hw.blk_off + SSPP_DGM_CSC_1 + SSPP_DGM_CSC_SIZE,
  1296. hw_pipe->hw.xin_id);
  1297. }
  1298. if (test_bit(SDE_SSPP_DMA_IGC, &hw_pipe->cap->features)) {
  1299. sde_dbg_reg_register_dump_range(SDE_DBG_NAME, "DGM_0",
  1300. hw_pipe->hw.blk_off + SSPP_DGM_0,
  1301. hw_pipe->hw.blk_off + SSPP_DGM_0 + SSPP_DGM_SIZE,
  1302. hw_pipe->hw.xin_id);
  1303. sde_dbg_reg_register_dump_range(SDE_DBG_NAME, "DGM_1",
  1304. hw_pipe->hw.blk_off + SSPP_DGM_1,
  1305. hw_pipe->hw.blk_off + SSPP_DGM_1 + SSPP_DGM_SIZE,
  1306. hw_pipe->hw.xin_id);
  1307. }
  1308. if (test_bit(SDE_SSPP_VIG_GAMUT, &hw_pipe->cap->features)) {
  1309. sde_dbg_reg_register_dump_range(SDE_DBG_NAME, cfg->sblk->gamut_blk.name,
  1310. hw_pipe->hw.blk_off + cfg->sblk->gamut_blk.base,
  1311. hw_pipe->hw.blk_off + cfg->sblk->gamut_blk.base + VIG_GAMUT_SIZE,
  1312. hw_pipe->hw.xin_id);
  1313. }
  1314. }
  1315. if (cfg->sblk->scaler_blk.len && !is_virtual_pipe)
  1316. sde_dbg_reg_register_dump_range(SDE_DBG_NAME,
  1317. cfg->sblk->scaler_blk.name,
  1318. hw_pipe->hw.blk_off + cfg->sblk->scaler_blk.base,
  1319. hw_pipe->hw.blk_off + cfg->sblk->scaler_blk.base +
  1320. cfg->sblk->scaler_blk.len,
  1321. hw_pipe->hw.xin_id);
  1322. return hw_pipe;
  1323. blk_init_error:
  1324. kfree(hw_pipe);
  1325. return ERR_PTR(rc);
  1326. }
  1327. void sde_hw_sspp_destroy(struct sde_hw_pipe *ctx)
  1328. {
  1329. if (ctx) {
  1330. sde_hw_blk_destroy(&ctx->base);
  1331. reg_dmav1_deinit_sspp_ops(ctx->idx);
  1332. kfree(ctx->cap);
  1333. }
  1334. kfree(ctx);
  1335. }