sde_hw_sspp.c 41 KB

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