sde_hw_ctl.h 16 KB

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