sde_hw_ctl.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2015-2020, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _SDE_HW_CTL_H
  6. #define _SDE_HW_CTL_H
  7. #include "sde_hw_mdss.h"
  8. #include "sde_hw_util.h"
  9. #include "sde_hw_catalog.h"
  10. #include "sde_hw_sspp.h"
  11. #include "sde_hw_blk.h"
  12. #define INVALID_CTL_STATUS 0xfffff88e
  13. #define CTL_MAX_DSPP_COUNT (DSPP_MAX - DSPP_0)
  14. /**
  15. * sde_ctl_mode_sel: Interface mode selection
  16. * SDE_CTL_MODE_SEL_VID: Video mode interface
  17. * SDE_CTL_MODE_SEL_CMD: Command mode interface
  18. */
  19. enum sde_ctl_mode_sel {
  20. SDE_CTL_MODE_SEL_VID = 0,
  21. SDE_CTL_MODE_SEL_CMD
  22. };
  23. /**
  24. * sde_ctl_rot_op_mode - inline rotation mode
  25. * SDE_CTL_ROT_OP_MODE_OFFLINE: offline rotation
  26. * SDE_CTL_ROT_OP_MODE_RESERVED: reserved
  27. * SDE_CTL_ROT_OP_MODE_INLINE_SYNC: inline rotation synchronous mode
  28. * SDE_CTL_ROT_OP_MODE_INLINE_ASYNC: inline rotation asynchronous mode
  29. */
  30. enum sde_ctl_rot_op_mode {
  31. SDE_CTL_ROT_OP_MODE_OFFLINE,
  32. SDE_CTL_ROT_OP_MODE_RESERVED,
  33. SDE_CTL_ROT_OP_MODE_INLINE_SYNC,
  34. SDE_CTL_ROT_OP_MODE_INLINE_ASYNC,
  35. };
  36. /**
  37. * ctl_hw_flush_type - active ctl hw types
  38. * SDE_HW_FLUSH_WB: WB block
  39. * SDE_HW_FLUSH_DSC: DSC block
  40. * SDE_HW_FLUSH_VDC: VDC bits of DSC block
  41. * SDE_HW_FLUSH_MERGE_3D: Merge 3D block
  42. * SDE_HW_FLUSH_CDM: CDM block
  43. * SDE_HW_FLUSH_CWB: CWB block
  44. * SDE_HW_FLUSH_PERIPH: Peripheral
  45. * SDE_HW_FLUSH_INTF: Interface
  46. */
  47. enum ctl_hw_flush_type {
  48. SDE_HW_FLUSH_WB,
  49. SDE_HW_FLUSH_DSC,
  50. SDE_HW_FLUSH_VDC,
  51. SDE_HW_FLUSH_MERGE_3D,
  52. SDE_HW_FLUSH_CDM,
  53. SDE_HW_FLUSH_CWB,
  54. SDE_HW_FLUSH_PERIPH,
  55. SDE_HW_FLUSH_INTF,
  56. SDE_HW_FLUSH_MAX
  57. };
  58. struct sde_hw_ctl;
  59. /**
  60. * struct sde_hw_stage_cfg - blending stage cfg
  61. * @stage : SSPP_ID at each stage
  62. * @multirect_index: index of the rectangle of SSPP.
  63. */
  64. struct sde_hw_stage_cfg {
  65. enum sde_sspp stage[SDE_STAGE_MAX][PIPES_PER_STAGE];
  66. enum sde_sspp_multirect_index multirect_index
  67. [SDE_STAGE_MAX][PIPES_PER_STAGE];
  68. };
  69. /**
  70. * struct sde_hw_intf_cfg :Describes how the SDE writes data to output interface
  71. * @intf : Interface id
  72. * @wb: Writeback id
  73. * @mode_3d: 3d mux configuration
  74. * @intf_mode_sel: Interface mode, cmd / vid
  75. * @stream_sel: Stream selection for multi-stream interfaces
  76. */
  77. struct sde_hw_intf_cfg {
  78. enum sde_intf intf;
  79. enum sde_wb wb;
  80. enum sde_3d_blend_mode mode_3d;
  81. enum sde_ctl_mode_sel intf_mode_sel;
  82. int stream_sel;
  83. };
  84. /**
  85. * struct sde_hw_intf_cfg_v1 :Describes the data strcuture to configure the
  86. * output interfaces for a particular display on a
  87. * platform which supports ctl path version 1.
  88. * @intf_count: No. of active interfaces for this display
  89. * @intf : Interface ids of active interfaces
  90. * @intf_mode_sel: Interface mode, cmd / vid
  91. * @intf_master: Master interface for split display
  92. * @wb_count: No. of active writebacks
  93. * @wb: Writeback ids of active writebacks
  94. * @merge_3d_count No. of active merge_3d blocks
  95. * @merge_3d: Id of the active merge 3d blocks
  96. * @cwb_count: No. of active concurrent writebacks
  97. * @cwb: Id of active cwb blocks
  98. * @cdm_count: No. of active chroma down module
  99. * @cdm: Id of active cdm blocks
  100. * @dsc_count: No. of active dsc blocks
  101. * @dsc: Id of active dsc blocks
  102. * @vdc_count: No. of active vdc blocks
  103. * @vdc: Id of active vdc blocks
  104. */
  105. struct sde_hw_intf_cfg_v1 {
  106. uint32_t intf_count;
  107. enum sde_intf intf[MAX_INTF_PER_CTL_V1];
  108. enum sde_ctl_mode_sel intf_mode_sel;
  109. enum sde_intf intf_master;
  110. uint32_t wb_count;
  111. enum sde_wb wb[MAX_WB_PER_CTL_V1];
  112. uint32_t merge_3d_count;
  113. enum sde_merge_3d merge_3d[MAX_MERGE_3D_PER_CTL_V1];
  114. uint32_t cwb_count;
  115. enum sde_cwb cwb[MAX_CWB_PER_CTL_V1];
  116. uint32_t cdm_count;
  117. enum sde_cdm cdm[MAX_CDM_PER_CTL_V1];
  118. uint32_t dsc_count;
  119. enum sde_dsc dsc[MAX_DSC_PER_CTL_V1];
  120. uint32_t vdc_count;
  121. enum sde_vdc vdc[MAX_VDC_PER_CTL_V1];
  122. };
  123. /**
  124. * struct sde_ctl_flush_cfg - struct describing flush configuration managed
  125. * via set, trigger and clear ops.
  126. * set ops corresponding to the hw_block is called, when the block's
  127. * configuration is changed and needs to be committed on Hw. Flush mask caches
  128. * the different bits for the ongoing commit.
  129. * clear ops clears the bitmask and cancels the update to the corresponding
  130. * hw block.
  131. * trigger op will trigger the update on the hw for the blocks cached in the
  132. * pending flush mask.
  133. *
  134. * @pending_flush_mask: pending ctl_flush
  135. * CTL path version SDE_CTL_CFG_VERSION_1_0_0 has * two level flush mechanism
  136. * for lower pipe controls. individual control should be flushed before
  137. * exercising top level flush
  138. * @pending_hw_flush_mask: pending flush mask for each active HW blk
  139. * @pending_dspp_flush_masks: pending flush masks for sub-blks of each DSPP
  140. */
  141. struct sde_ctl_flush_cfg {
  142. u32 pending_flush_mask;
  143. u32 pending_hw_flush_mask[SDE_HW_FLUSH_MAX];
  144. u32 pending_dspp_flush_masks[CTL_MAX_DSPP_COUNT];
  145. };
  146. /**
  147. * struct sde_hw_ctl_ops - Interface to the wb Hw driver functions
  148. * Assumption is these functions will be called after clocks are enabled
  149. */
  150. struct sde_hw_ctl_ops {
  151. /**
  152. * kickoff hw operation for Sw controlled interfaces
  153. * DSI cmd mode and WB interface are SW controlled
  154. * @ctx : ctl path ctx pointer
  155. * @Return: error code
  156. */
  157. int (*trigger_start)(struct sde_hw_ctl *ctx);
  158. /**
  159. * kickoff prepare is in progress hw operation for sw
  160. * controlled interfaces: DSI cmd mode and WB interface
  161. * are SW controlled
  162. * @ctx : ctl path ctx pointer
  163. * @Return: error code
  164. */
  165. int (*trigger_pending)(struct sde_hw_ctl *ctx);
  166. /**
  167. * kickoff rotator operation for Sw controlled interfaces
  168. * DSI cmd mode and WB interface are SW controlled
  169. * @ctx : ctl path ctx pointer
  170. * @Return: error code
  171. */
  172. int (*trigger_rot_start)(struct sde_hw_ctl *ctx);
  173. /**
  174. * enable/disable UIDLE feature
  175. * @ctx : ctl path ctx pointer
  176. * @enable: true to enable the feature
  177. */
  178. void (*uidle_enable)(struct sde_hw_ctl *ctx, bool enable);
  179. /**
  180. * Clear the value of the cached pending_flush_mask
  181. * No effect on hardware
  182. * @ctx : ctl path ctx pointer
  183. * @Return: error code
  184. */
  185. int (*clear_pending_flush)(struct sde_hw_ctl *ctx);
  186. /**
  187. * Query the value of the cached pending_flush_mask
  188. * No effect on hardware
  189. * @ctx : ctl path ctx pointer
  190. * @cfg : current flush configuration
  191. * @Return: error code
  192. */
  193. int (*get_pending_flush)(struct sde_hw_ctl *ctx,
  194. struct sde_ctl_flush_cfg *cfg);
  195. /**
  196. * OR in the given flushbits to the flush_cfg
  197. * No effect on hardware
  198. * @ctx : ctl path ctx pointer
  199. * @cfg : flush configuration pointer
  200. * @Return: error code
  201. */
  202. int (*update_pending_flush)(struct sde_hw_ctl *ctx,
  203. struct sde_ctl_flush_cfg *cfg);
  204. /**
  205. * Write the value of the pending_flush_mask to hardware
  206. * @ctx : ctl path ctx pointer
  207. * @Return: error code
  208. */
  209. int (*trigger_flush)(struct sde_hw_ctl *ctx);
  210. /**
  211. * Read the value of the flush register
  212. * @ctx : ctl path ctx pointer
  213. * @Return: value of the ctl flush register.
  214. */
  215. u32 (*get_flush_register)(struct sde_hw_ctl *ctx);
  216. /**
  217. * Setup ctl_path interface config
  218. * @ctx
  219. * @cfg : interface config structure pointer
  220. * @Return: error code
  221. */
  222. int (*setup_intf_cfg)(struct sde_hw_ctl *ctx,
  223. struct sde_hw_intf_cfg *cfg);
  224. /**
  225. * Reset ctl_path interface config
  226. * @ctx : ctl path ctx pointer
  227. * @cfg : interface config structure pointer
  228. * @merge_3d_idx : index of merge3d blk
  229. * @Return: error code
  230. */
  231. int (*reset_post_disable)(struct sde_hw_ctl *ctx,
  232. struct sde_hw_intf_cfg_v1 *cfg, u32 merge_3d_idx);
  233. /** update cwb for ctl_path
  234. * @ctx : ctl path ctx pointer
  235. * @cfg : interface config structure pointer
  236. * @enable : enable/disable the dynamic sub-blocks in interface cfg
  237. * @Return: error code
  238. */
  239. int (*update_intf_cfg)(struct sde_hw_ctl *ctx,
  240. struct sde_hw_intf_cfg_v1 *cfg, bool enable);
  241. /**
  242. * Setup ctl_path interface config for SDE_CTL_ACTIVE_CFG
  243. * @ctx : ctl path ctx pointer
  244. * @cfg : interface config structure pointer
  245. * @Return: error code
  246. */
  247. int (*setup_intf_cfg_v1)(struct sde_hw_ctl *ctx,
  248. struct sde_hw_intf_cfg_v1 *cfg);
  249. /**
  250. * Update the interface selection with input WB config
  251. * @ctx : ctl path ctx pointer
  252. * @cfg : pointer to input wb config
  253. * @enable : set if true, clear otherwise
  254. */
  255. void (*update_wb_cfg)(struct sde_hw_ctl *ctx,
  256. struct sde_hw_intf_cfg *cfg, bool enable);
  257. int (*reset)(struct sde_hw_ctl *c);
  258. /**
  259. * get_reset - check ctl reset status bit
  260. * @ctx : ctl path ctx pointer
  261. * Returns: current value of ctl reset status
  262. */
  263. u32 (*get_reset)(struct sde_hw_ctl *ctx);
  264. /**
  265. * get_scheduler_reset - check ctl scheduler status bit
  266. * @ctx : ctl path ctx pointer
  267. * Returns: current value of ctl scheduler and idle status
  268. */
  269. u32 (*get_scheduler_status)(struct sde_hw_ctl *ctx);
  270. /**
  271. * hard_reset - force reset on ctl_path
  272. * @ctx : ctl path ctx pointer
  273. * @enable : whether to enable/disable hard reset
  274. */
  275. void (*hard_reset)(struct sde_hw_ctl *c, bool enable);
  276. /*
  277. * wait_reset_status - checks ctl reset status
  278. * @ctx : ctl path ctx pointer
  279. *
  280. * This function checks the ctl reset status bit.
  281. * If the reset bit is set, it keeps polling the status till the hw
  282. * reset is complete.
  283. * Returns: 0 on success or -error if reset incomplete within interval
  284. */
  285. int (*wait_reset_status)(struct sde_hw_ctl *ctx);
  286. /**
  287. * update_bitmask_sspp: updates mask corresponding to sspp
  288. * @blk : blk id
  289. * @enable : true to enable, 0 to disable
  290. */
  291. int (*update_bitmask_sspp)(struct sde_hw_ctl *ctx,
  292. enum sde_sspp blk, bool enable);
  293. /**
  294. * update_bitmask_sspp: updates mask corresponding to sspp
  295. * @blk : blk id
  296. * @enable : true to enable, 0 to disable
  297. */
  298. int (*update_bitmask_mixer)(struct sde_hw_ctl *ctx,
  299. enum sde_lm blk, bool enable);
  300. /**
  301. * update_bitmask_sspp: updates mask corresponding to sspp
  302. * @blk : blk id
  303. * @enable : true to enable, 0 to disable
  304. */
  305. int (*update_bitmask_dspp)(struct sde_hw_ctl *ctx,
  306. enum sde_dspp blk, bool enable);
  307. /**
  308. * update_bitmask_sspp: updates mask corresponding to sspp
  309. * @blk : blk id
  310. * @enable : true to enable, 0 to disable
  311. */
  312. int (*update_bitmask_dspp_pavlut)(struct sde_hw_ctl *ctx,
  313. enum sde_dspp blk, bool enable);
  314. /**
  315. * Program DSPP sub block specific bit of dspp flush register.
  316. * @ctx : ctl path ctx pointer
  317. * @dspp : HW block ID of dspp block
  318. * @sub_blk : enum of DSPP sub block to flush
  319. * @enable : true to enable, 0 to disable
  320. *
  321. * This API is for CTL with DSPP flush hierarchy registers.
  322. */
  323. int (*update_bitmask_dspp_subblk)(struct sde_hw_ctl *ctx,
  324. enum sde_dspp dspp, u32 sub_blk, bool enable);
  325. /**
  326. * update_bitmask_sspp: updates mask corresponding to sspp
  327. * @blk : blk id
  328. * @enable : true to enable, 0 to disable
  329. */
  330. int (*update_bitmask_rot)(struct sde_hw_ctl *ctx,
  331. enum sde_rot blk, bool enable);
  332. /**
  333. * update_bitmask: updates flush mask
  334. * @type : blk type to flush
  335. * @blk_idx : blk idx
  336. * @enable : true to enable, 0 to disable
  337. */
  338. int (*update_bitmask)(struct sde_hw_ctl *ctx,
  339. enum ctl_hw_flush_type type, u32 blk_idx, bool enable);
  340. /**
  341. * read CTL_TOP register value and return
  342. * the data.
  343. * @ctx : ctl path ctx pointer
  344. * @return : CTL top register value
  345. */
  346. u32 (*read_ctl_top)(struct sde_hw_ctl *ctx);
  347. /**
  348. * get interfaces for the active CTL .
  349. * @ctx : ctl path ctx pointer
  350. * @return : bit mask with the active interfaces for the CTL
  351. */
  352. u32 (*get_ctl_intf)(struct sde_hw_ctl *ctx);
  353. /**
  354. * read CTL layers register value and return
  355. * the data.
  356. * @ctx : ctl path ctx pointer
  357. * @index : layer index for this ctl path
  358. * @return : CTL layers register value
  359. */
  360. u32 (*read_ctl_layers)(struct sde_hw_ctl *ctx, int index);
  361. /**
  362. * read active register configuration for this block
  363. * @ctx : ctl path ctx pointer
  364. * @blk : hw blk type, supported blocks are DSC, MERGE_3D, INTF,
  365. * CDM, WB
  366. * @index : blk index
  367. * @return : true if blk at idx is active or false
  368. */
  369. bool (*read_active_status)(struct sde_hw_ctl *ctx,
  370. enum sde_hw_blk_type blk, int index);
  371. /**
  372. * Set all blend stages to disabled
  373. * @ctx : ctl path ctx pointer
  374. */
  375. void (*clear_all_blendstages)(struct sde_hw_ctl *ctx);
  376. /**
  377. * Configure layer mixer to pipe configuration
  378. * @ctx : ctl path ctx pointer
  379. * @lm : layer mixer enumeration
  380. * @cfg : blend stage configuration
  381. * @active_cfg: active no blend stage configuration
  382. */
  383. void (*setup_blendstage)(struct sde_hw_ctl *ctx,
  384. enum sde_lm lm, struct sde_hw_stage_cfg *cfg,
  385. struct sde_hw_stage_cfg *active_cfg);
  386. /**
  387. * Get all the sspp staged on a layer mixer
  388. * @ctx : ctl path ctx pointer
  389. * @lm : layer mixer enumeration
  390. * @info : array address to populate connected sspp index info
  391. * @info_max_cnt : maximum sspp info elements based on array size
  392. * @Return: count of sspps info elements populated
  393. */
  394. u32 (*get_staged_sspp)(struct sde_hw_ctl *ctx, enum sde_lm lm,
  395. struct sde_sspp_index_info *info, u32 info_max_cnt);
  396. /**
  397. * Flush the reg dma by sending last command.
  398. * @ctx : ctl path ctx pointer
  399. * @blocking : if set to true api will block until flush is done
  400. * @Return: error code
  401. */
  402. int (*reg_dma_flush)(struct sde_hw_ctl *ctx, bool blocking);
  403. /**
  404. * check if ctl start trigger state to confirm the frame pending
  405. * status
  406. * @ctx : ctl path ctx pointer
  407. * @Return: error code
  408. */
  409. int (*get_start_state)(struct sde_hw_ctl *ctx);
  410. };
  411. /**
  412. * struct sde_hw_ctl : CTL PATH driver object
  413. * @base: hardware block base structure
  414. * @hw: block register map object
  415. * @idx: control path index
  416. * @caps: control path capabilities
  417. * @mixer_count: number of mixers
  418. * @mixer_hw_caps: mixer hardware capabilities
  419. * @flush: storage for pending ctl_flush managed via ops
  420. * @ops: operation list
  421. */
  422. struct sde_hw_ctl {
  423. struct sde_hw_blk base;
  424. struct sde_hw_blk_reg_map hw;
  425. /* ctl path */
  426. int idx;
  427. const struct sde_ctl_cfg *caps;
  428. int mixer_count;
  429. const struct sde_lm_cfg *mixer_hw_caps;
  430. struct sde_ctl_flush_cfg flush;
  431. /* ops */
  432. struct sde_hw_ctl_ops ops;
  433. };
  434. /**
  435. * sde_hw_ctl - convert base object sde_hw_base to container
  436. * @hw: Pointer to base hardware block
  437. * return: Pointer to hardware block container
  438. */
  439. static inline struct sde_hw_ctl *to_sde_hw_ctl(struct sde_hw_blk *hw)
  440. {
  441. return container_of(hw, struct sde_hw_ctl, base);
  442. }
  443. /**
  444. * sde_hw_ctl_init(): Initializes the ctl_path hw driver object.
  445. * should be called before accessing every ctl path registers.
  446. * @idx: ctl_path index for which driver object is required
  447. * @addr: mapped register io address of MDP
  448. * @m : pointer to mdss catalog data
  449. */
  450. struct sde_hw_ctl *sde_hw_ctl_init(enum sde_ctl idx,
  451. void __iomem *addr,
  452. struct sde_mdss_cfg *m);
  453. /**
  454. * sde_hw_ctl_destroy(): Destroys ctl driver context
  455. * should be called to free the context
  456. */
  457. void sde_hw_ctl_destroy(struct sde_hw_ctl *ctx);
  458. #endif /*_SDE_HW_CTL_H */