sde_reg_dma.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  4. * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
  5. */
  6. #ifndef _SDE_REG_DMA_H
  7. #define _SDE_REG_DMA_H
  8. #include "msm_drv.h"
  9. #include "sde_hw_catalog.h"
  10. #include "sde_hw_mdss.h"
  11. #include "sde_hw_top.h"
  12. #include "sde_hw_util.h"
  13. /**
  14. * enum sde_reg_dma_op - defines operations supported by reg dma
  15. * @REG_DMA_READ: Read the histogram into buffer provided
  16. * @REG_DMA_WRITE: Write the reg dma configuration into MDP block
  17. * @REG_DMA_OP_MAX: Max operation which indicates that op is invalid
  18. */
  19. enum sde_reg_dma_op {
  20. REG_DMA_READ,
  21. REG_DMA_WRITE,
  22. REG_DMA_OP_MAX
  23. };
  24. /**
  25. * enum sde_reg_dma_read_sel - defines the blocks for histogram read
  26. * @DSPP0_HIST: select dspp0
  27. * @DSPP1_HIST: select dspp1
  28. * @DSPP2_HIST: select dspp2
  29. * @DSPP3_HIST: select dspp3
  30. * @DSPP_HIST_MAX: invalid selection
  31. */
  32. enum sde_reg_dma_read_sel {
  33. DSPP0_HIST,
  34. DSPP1_HIST,
  35. DSPP2_HIST,
  36. DSPP3_HIST,
  37. DSPP_HIST_MAX,
  38. };
  39. /**
  40. * enum sde_reg_dma_features - defines features supported by reg dma
  41. * @QSEED: qseed feature
  42. * @GAMUT: gamut feature
  43. * @IGC: inverse gamma correction
  44. * @PCC: polynomical color correction
  45. * @VLUT: PA vlut
  46. * @MEMC_SKIN: memory color skin
  47. * @MEMC_SKY: memory color sky
  48. * @MEMC_FOLIAGE: memory color foliage
  49. * @MEMC_PROT: memory color protect
  50. * @SIX_ZONE: six zone
  51. * @HSIC: Hue, saturation and contrast
  52. * @GC: gamma correction
  53. * @SPR_INIT: Sub pixel rendering init feature
  54. * @SPR_PU: Sub pixel rendering partial update feature
  55. * @LTM_INIT: LTM INIT
  56. * @LTM_ROI: LTM ROI
  57. * @LTM_VLUT: LTM VLUT
  58. * @RC_MASK_CFG: Rounded corner config and mask
  59. * @RC_PU_CFG: Rounded corner partial update
  60. * @DEMURA_CFG: Demura feature
  61. * @REG_DMA_FEATURES_MAX: invalid selection
  62. */
  63. enum sde_reg_dma_features {
  64. QSEED,
  65. GAMUT,
  66. IGC,
  67. PCC,
  68. VLUT,
  69. MEMC_SKIN,
  70. MEMC_SKY,
  71. MEMC_FOLIAGE,
  72. MEMC_PROT,
  73. SIX_ZONE,
  74. HSIC,
  75. GC,
  76. SPR_INIT,
  77. SPR_UDC,
  78. SPR_PU_CFG,
  79. LTM_INIT,
  80. LTM_ROI,
  81. LTM_VLUT,
  82. RC_MASK_CFG,
  83. RC_PU_CFG,
  84. DEMURA_CFG,
  85. DEMURA_CFG0_PARAM2,
  86. REG_DMA_FEATURES_MAX,
  87. };
  88. /**
  89. * enum sde_reg_dma_queue - defines reg dma write queue values
  90. * @DMA_CTL_QUEUE0: select queue0
  91. * @DMA_CTL_QUEUE1: select queue1
  92. * @DMA_CTL_QUEUE_MAX: invalid selection
  93. */
  94. enum sde_reg_dma_queue {
  95. DMA_CTL_QUEUE0,
  96. DMA_CTL_QUEUE1,
  97. DMA_CTL_QUEUE_MAX,
  98. };
  99. #define LUTBUS_TABLE_SELECT_MAX 2
  100. #define LUTBUS_IGC_TRANS_SIZE 3
  101. #define LUTBUS_GAMUT_TRANS_SIZE 6
  102. #define LUTBUS_SIXZONE_TRANS_SIZE 5
  103. /**
  104. * enum sde_reg_dma_lutbus_block - block select values for lutbus op
  105. * @LUTBUS_BLOCK_IGC: select IGC block
  106. * @LUTBUS_BLOCK_GAMUT: select GAMUT block
  107. * @LUTBUS_BLOCK_SIXZONE: select SIXZONE block
  108. * @LUTBUS_BLOCK_MAX: invalid selection
  109. */
  110. enum sde_reg_dma_lutbus_block {
  111. LUTBUS_BLOCK_IGC = 0,
  112. LUTBUS_BLOCK_GAMUT,
  113. LUTBUS_BLOCK_SIXZONE = 3,
  114. LUTBUS_BLOCK_MAX,
  115. };
  116. /**
  117. * enum sde_reg_dma_trigger_mode - defines reg dma ops trigger mode
  118. * @WRITE_IMMEDIATE: trigger write op immediately
  119. * @WRITE_TRIGGER: trigger write op when sw trigger is issued
  120. * @READ_IMMEDIATE: trigger read op immediately
  121. * @READ_TRIGGER: trigger read op when sw trigger is issued
  122. * @TIGGER_MAX: invalid trigger selection
  123. */
  124. enum sde_reg_dma_trigger_mode {
  125. WRITE_IMMEDIATE,
  126. WRITE_TRIGGER,
  127. READ_IMMEDIATE,
  128. READ_TRIGGER,
  129. TIGGER_MAX,
  130. };
  131. /**
  132. * enum sde_reg_dma_setup_ops - defines reg dma write configuration
  133. * @HW_BLK_SELECT: op for selecting the hardware block
  134. * @REG_SINGLE_WRITE: op for writing single register value
  135. * at the address provided
  136. * @REG_BLK_WRITE_SINGLE: op for writing multiple registers using auto address
  137. * increment
  138. * @REG_BLK_WRITE_INC: op for writing multiple registers using hw index
  139. * register
  140. * @REG_BLK_WRITE_MULTIPLE: op for writing hw index based registers at
  141. * non-consecutive location
  142. * @REG_SINGLE_MODIFY: op for modifying single register value with bitmask at
  143. * the address provided(Reg = (Reg & Mask) | Data),
  144. * broadcast feature is not supported with this opcode.
  145. * @REG_BLK_LUT_WRITE: op for specific faster LUT writes, currently only
  146. * supports DSPP/SSPP Gamut and DSPP IGC.
  147. * @REG_DMA_SETUP_OPS_MAX: invalid operation
  148. */
  149. enum sde_reg_dma_setup_ops {
  150. HW_BLK_SELECT,
  151. REG_SINGLE_WRITE,
  152. REG_BLK_WRITE_SINGLE,
  153. REG_BLK_WRITE_INC,
  154. REG_BLK_WRITE_MULTIPLE,
  155. REG_SINGLE_MODIFY,
  156. REG_BLK_LUT_WRITE,
  157. REG_DMA_SETUP_OPS_MAX,
  158. };
  159. #define REG_DMA_BLK_MAX 32
  160. /**
  161. * enum sde_reg_dma_blk - defines blocks for which reg dma op should be
  162. * performed
  163. * @VIG0: select vig0 block
  164. * @VIG1: select vig1 block
  165. * @VIG2: select vig2 block
  166. * @VIG3: select vig3 block
  167. * @LM0: select lm0 block
  168. * @LM1: select lm1 block
  169. * @LM2: select lm2 block
  170. * @LM3: select lm3 block
  171. * @DSPP0: select dspp0 block
  172. * @DSPP1: select dspp1 block
  173. * @DSPP2: select dspp2 block
  174. * @DSPP3: select dspp3 block
  175. * @DMA0: select dma0 block
  176. * @DMA1: select dma1 block
  177. * @DMA2: select dma2 block
  178. * @DMA3: select dma3 block
  179. * @DMA4: select dma4 block
  180. * @DMA5: select dma5 block
  181. * @SSPP_IGC: select sspp igc block
  182. * @DSPP_IGC: select dspp igc block
  183. * @LTM0: select LTM0 block
  184. * @LTM1: select LTM1 block
  185. * @MDSS: select mdss block
  186. */
  187. enum sde_reg_dma_blk {
  188. VIG0 = BIT(0),
  189. VIG1 = BIT(1),
  190. VIG2 = BIT(2),
  191. VIG3 = BIT(3),
  192. LM0 = BIT(4),
  193. LM1 = BIT(5),
  194. LM2 = BIT(6),
  195. LM3 = BIT(7),
  196. DSPP0 = BIT(8),
  197. DSPP1 = BIT(9),
  198. DSPP2 = BIT(10),
  199. DSPP3 = BIT(11),
  200. DMA0 = BIT(12),
  201. DMA1 = BIT(13),
  202. DMA2 = BIT(14),
  203. DMA3 = BIT(15),
  204. SSPP_IGC = BIT(16),
  205. DSPP_IGC = BIT(17),
  206. LTM0 = BIT(18),
  207. LTM1 = BIT(19),
  208. DMA4 = BIT(20),
  209. DMA5 = BIT(21),
  210. LTM2 = BIT(22),
  211. LTM3 = BIT(23),
  212. MDSS = BIT(31)
  213. };
  214. /**
  215. * enum sde_reg_dma_last_cmd_mode - defines enums for kick off mode.
  216. * @REG_DMA_WAIT4_COMP: last_command api will wait for max of 1 msec allowing
  217. * reg dma trigger to complete.
  218. * @REG_DMA_NOWAIT: last_command api will not wait for reg dma trigger
  219. * completion.
  220. */
  221. enum sde_reg_dma_last_cmd_mode {
  222. REG_DMA_WAIT4_COMP,
  223. REG_DMA_NOWAIT,
  224. };
  225. /**
  226. * struct sde_reg_dma_buffer - defines reg dma buffer structure.
  227. * @drm_gem_object *buf: drm gem handle for the buffer
  228. * @asapce : pointer to address space
  229. * @buffer_size: buffer size
  230. * @index: write pointer index
  231. * @iova: device address
  232. * @vaddr: cpu address
  233. * @next_op_allowed: operation allowed on the buffer
  234. * @ops_completed: operations completed on buffer
  235. * @abs_write_cnt: count of mdss absolute addr writes in the current buffer
  236. */
  237. struct sde_reg_dma_buffer {
  238. struct drm_gem_object *buf;
  239. struct msm_gem_address_space *aspace;
  240. u32 buffer_size;
  241. u32 index;
  242. u64 iova;
  243. void *vaddr;
  244. u32 next_op_allowed;
  245. u32 ops_completed;
  246. u32 abs_write_cnt;
  247. };
  248. /**
  249. * struct sde_reg_dma_setup_ops_cfg - defines structure for reg dma ops on the
  250. * reg dma buffer.
  251. * @sde_reg_dma_setup_ops ops: ops to be performed
  252. * @sde_reg_dma_blk blk: block on which op needs to be performed
  253. * @sde_reg_dma_features feature: feature on which op needs to be done
  254. * @wrap_size: valid for REG_BLK_WRITE_MULTIPLE, indicates reg index location
  255. * size
  256. * @inc: valid for REG_BLK_WRITE_MULTIPLE indicates whether reg index location
  257. * needs an increment or decrement.
  258. * 0 - decrement
  259. * 1 - increment
  260. * @blk_offset: offset for blk, valid for HW_BLK_SELECT op only
  261. * @sde_reg_dma_buffer *dma_buf: reg dma buffer on which op needs to be
  262. * performed
  263. * @data: pointer to payload which has to be written into reg dma buffer for
  264. * selected op.
  265. * @mask: mask value for REG_SINGLE_MODIFY op
  266. * @data_size: size of payload in data
  267. * @table_sel: table select value for REG_BLK_LUT_WRITE opcode
  268. * @block_sel: block select value for REG_BLK_LUT_WRITE opcode
  269. * @trans_size: transfer size for REG_BLK_LUT_WRITE opcode
  270. * @lut_size: lut size in terms of transfer size
  271. */
  272. struct sde_reg_dma_setup_ops_cfg {
  273. enum sde_reg_dma_setup_ops ops;
  274. enum sde_reg_dma_blk blk;
  275. enum sde_reg_dma_features feature;
  276. u32 wrap_size;
  277. u32 inc;
  278. u32 blk_offset;
  279. struct sde_reg_dma_buffer *dma_buf;
  280. u32 *data;
  281. u32 mask;
  282. u32 data_size;
  283. u32 table_sel;
  284. u32 block_sel;
  285. u32 trans_size;
  286. u32 lut_size;
  287. };
  288. /**
  289. * struct sde_reg_dma_kickoff_cfg - commit reg dma buffer to hw engine
  290. * @ctl: ctl for which reg dma buffer needs to be committed.
  291. * @dma_buf: reg dma buffer with iova address and size info
  292. * @block_select: histogram read select
  293. * @trigger_mode: reg dma ops trigger mode
  294. * @queue_select: queue on which reg dma buffer will be submitted
  295. * @dma_type: DB or SB LUT DMA block selection
  296. * @feature: feature the provided kickoff buffer belongs to
  297. * @last_command: last command for this vsync
  298. */
  299. struct sde_reg_dma_kickoff_cfg {
  300. struct sde_hw_ctl *ctl;
  301. enum sde_reg_dma_op op;
  302. struct sde_reg_dma_buffer *dma_buf;
  303. enum sde_reg_dma_read_sel block_select;
  304. enum sde_reg_dma_trigger_mode trigger_mode;
  305. enum sde_reg_dma_queue queue_select;
  306. enum sde_reg_dma_type dma_type;
  307. enum sde_reg_dma_features feature;
  308. u32 last_command;
  309. };
  310. /**
  311. * struct sde_hw_reg_dma_ops - ops supported by reg dma frame work, based on
  312. * version of reg dma appropriate ops will be
  313. * installed during driver probe.
  314. * @check_support: checks if reg dma is supported on this platform for a
  315. * feature
  316. * @setup_payload: setup reg dma buffer based on ops and payload provided by
  317. * client
  318. * @kick_off: submit the reg dma buffer to hw enginge
  319. * @reset: reset the reg dma hw enginge for a ctl
  320. * @alloc_reg_dma_buf: allocate reg dma buffer
  321. * @dealloc_reg_dma: de-allocate reg dma buffer
  322. * @reset_reg_dma_buf: reset the buffer to init state
  323. * @last_command: notify control that last command is queued
  324. * @last_command_sb: notify control that last command for SB LUTDMA is queued
  325. * @dump_regs: dump reg dma registers
  326. */
  327. struct sde_hw_reg_dma_ops {
  328. int (*check_support)(enum sde_reg_dma_features feature,
  329. enum sde_reg_dma_blk blk,
  330. bool *is_supported);
  331. int (*setup_payload)(struct sde_reg_dma_setup_ops_cfg *cfg);
  332. int (*kick_off)(struct sde_reg_dma_kickoff_cfg *cfg);
  333. int (*reset)(struct sde_hw_ctl *ctl);
  334. struct sde_reg_dma_buffer* (*alloc_reg_dma_buf)(u32 size);
  335. int (*dealloc_reg_dma)(struct sde_reg_dma_buffer *lut_buf);
  336. int (*reset_reg_dma_buf)(struct sde_reg_dma_buffer *buf);
  337. int (*last_command)(struct sde_hw_ctl *ctl, enum sde_reg_dma_queue q,
  338. enum sde_reg_dma_last_cmd_mode mode);
  339. int (*last_command_sb)(struct sde_hw_ctl *ctl, enum sde_reg_dma_queue q,
  340. enum sde_reg_dma_last_cmd_mode mode);
  341. void (*dump_regs)(void);
  342. };
  343. /**
  344. * struct sde_hw_reg_dma - structure to hold reg dma hw info
  345. * @drm_dev: drm driver dev handle
  346. * @reg_dma_count: number of LUTDMA hw instances
  347. * @caps: LUTDMA hw caps on the platform
  348. * @ops: reg dma ops supported on the platform
  349. * @addr: reg dma hw block base address
  350. */
  351. struct sde_hw_reg_dma {
  352. struct drm_device *drm_dev;
  353. u32 reg_dma_count;
  354. const struct sde_reg_dma_cfg *caps;
  355. struct sde_hw_reg_dma_ops ops;
  356. void __iomem *addr;
  357. };
  358. /**
  359. * sde_reg_dma_init() - function called to initialize reg dma during sde
  360. * drm driver probe. If reg dma is supported by sde
  361. * ops for reg dma version will be installed.
  362. * if reg dma is not supported by sde default ops will
  363. * be installed. check_support of default ops will
  364. * return false, hence the clients should fall back to
  365. * AHB programming.
  366. * @addr: reg dma block base address
  367. * @m: catalog which contains sde hw capabilities and offsets
  368. * @dev: drm driver device handle
  369. */
  370. int sde_reg_dma_init(void __iomem *addr, struct sde_mdss_cfg *m,
  371. struct drm_device *dev);
  372. /**
  373. * sde_reg_dma_get_ops() - singleton module, ops is returned to the clients
  374. * who call this api.
  375. */
  376. struct sde_hw_reg_dma_ops *sde_reg_dma_get_ops(void);
  377. /**
  378. * sde_reg_dma_deinit() - de-initialize the reg dma
  379. */
  380. void sde_reg_dma_deinit(void);
  381. #endif /* _SDE_REG_DMA_H */