sde_reg_dma.h 11 KB

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