sde_hw_ctl.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  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. * @enable : enable/disable the cwb hw block
  227. * @Return: error code
  228. */
  229. int (*update_cwb_cfg)(struct sde_hw_ctl *ctx,
  230. struct sde_hw_intf_cfg_v1 *cfg, bool enable);
  231. /**
  232. * Setup ctl_path interface config for SDE_CTL_ACTIVE_CFG
  233. * @ctx : ctl path ctx pointer
  234. * @cfg : interface config structure pointer
  235. * @Return: error code
  236. */
  237. int (*setup_intf_cfg_v1)(struct sde_hw_ctl *ctx,
  238. struct sde_hw_intf_cfg_v1 *cfg);
  239. /**
  240. * Setup ctl_path dsc config for SDE_CTL_ACTIVE_CFG
  241. * @ctx : ctl path ctx pointer
  242. * @cfg : dsc config structure pointer
  243. * @Return: error code
  244. */
  245. int (*setup_dsc_cfg)(struct sde_hw_ctl *ctx,
  246. struct sde_ctl_dsc_cfg *cfg);
  247. /** Update the interface selection with input WB config
  248. * @ctx : ctl path ctx pointer
  249. * @cfg : pointer to input wb config
  250. * @enable : set if true, clear otherwise
  251. */
  252. void (*update_wb_cfg)(struct sde_hw_ctl *ctx,
  253. struct sde_hw_intf_cfg *cfg, bool enable);
  254. int (*reset)(struct sde_hw_ctl *c);
  255. /**
  256. * get_reset - check ctl reset status bit
  257. * @ctx : ctl path ctx pointer
  258. * Returns: current value of ctl reset status
  259. */
  260. u32 (*get_reset)(struct sde_hw_ctl *ctx);
  261. /**
  262. * get_scheduler_reset - check ctl scheduler status bit
  263. * @ctx : ctl path ctx pointer
  264. * Returns: current value of ctl scheduler and idle status
  265. */
  266. u32 (*get_scheduler_status)(struct sde_hw_ctl *ctx);
  267. /**
  268. * hard_reset - force reset on ctl_path
  269. * @ctx : ctl path ctx pointer
  270. * @enable : whether to enable/disable hard reset
  271. */
  272. void (*hard_reset)(struct sde_hw_ctl *c, bool enable);
  273. /*
  274. * wait_reset_status - checks ctl reset status
  275. * @ctx : ctl path ctx pointer
  276. *
  277. * This function checks the ctl reset status bit.
  278. * If the reset bit is set, it keeps polling the status till the hw
  279. * reset is complete.
  280. * Returns: 0 on success or -error if reset incomplete within interval
  281. */
  282. int (*wait_reset_status)(struct sde_hw_ctl *ctx);
  283. /**
  284. * update_bitmask_sspp: updates mask corresponding to sspp
  285. * @blk : blk id
  286. * @enable : true to enable, 0 to disable
  287. */
  288. int (*update_bitmask_sspp)(struct sde_hw_ctl *ctx,
  289. enum sde_sspp blk, bool enable);
  290. /**
  291. * update_bitmask_sspp: updates mask corresponding to sspp
  292. * @blk : blk id
  293. * @enable : true to enable, 0 to disable
  294. */
  295. int (*update_bitmask_mixer)(struct sde_hw_ctl *ctx,
  296. enum sde_lm blk, bool enable);
  297. /**
  298. * update_bitmask_sspp: updates mask corresponding to sspp
  299. * @blk : blk id
  300. * @enable : true to enable, 0 to disable
  301. */
  302. int (*update_bitmask_dspp)(struct sde_hw_ctl *ctx,
  303. enum sde_dspp blk, bool enable);
  304. /**
  305. * update_bitmask_sspp: updates mask corresponding to sspp
  306. * @blk : blk id
  307. * @enable : true to enable, 0 to disable
  308. */
  309. int (*update_bitmask_dspp_pavlut)(struct sde_hw_ctl *ctx,
  310. enum sde_dspp blk, bool enable);
  311. /**
  312. * update_bitmask_sspp: updates mask corresponding to sspp
  313. * @blk : blk id
  314. * @enable : true to enable, 0 to disable
  315. */
  316. int (*update_bitmask_intf)(struct sde_hw_ctl *ctx,
  317. enum sde_intf blk, bool enable);
  318. /**
  319. * update_bitmask_sspp: updates mask corresponding to sspp
  320. * @blk : blk id
  321. * @enable : true to enable, 0 to disable
  322. */
  323. int (*update_bitmask_cdm)(struct sde_hw_ctl *ctx,
  324. enum sde_cdm 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_wb)(struct sde_hw_ctl *ctx,
  331. enum sde_wb blk, bool enable);
  332. /**
  333. * update_bitmask_sspp: updates mask corresponding to sspp
  334. * @blk : blk id
  335. * @enable : true to enable, 0 to disable
  336. */
  337. int (*update_bitmask_rot)(struct sde_hw_ctl *ctx,
  338. enum sde_rot blk, bool enable);
  339. /**
  340. * update_bitmask_dsc: updates mask corresponding to dsc
  341. * @blk : blk id
  342. * @enable : true to enable, 0 to disable
  343. */
  344. int (*update_bitmask_dsc)(struct sde_hw_ctl *ctx,
  345. enum sde_dsc blk, bool enable);
  346. /**
  347. * update_bitmask_merge3d: updates mask corresponding to merge_3d
  348. * @blk : blk id
  349. * @enable : true to enable, 0 to disable
  350. */
  351. int (*update_bitmask_merge3d)(struct sde_hw_ctl *ctx,
  352. enum sde_merge_3d blk, bool enable);
  353. /**
  354. * update_bitmask_cwb: updates mask corresponding to cwb
  355. * @blk : blk id
  356. * @enable : true to enable, 0 to disable
  357. */
  358. int (*update_bitmask_cwb)(struct sde_hw_ctl *ctx,
  359. enum sde_cwb blk, bool enable);
  360. /**
  361. * update_bitmask_periph: updates mask corresponding to peripheral
  362. * @blk : blk id
  363. * @enable : true to enable, 0 to disable
  364. */
  365. int (*update_bitmask_periph)(struct sde_hw_ctl *ctx,
  366. enum sde_intf blk, bool enable);
  367. /**
  368. * read CTL_TOP register value and return
  369. * the data.
  370. * @ctx : ctl path ctx pointer
  371. * @return : CTL top register value
  372. */
  373. u32 (*read_ctl_top)(struct sde_hw_ctl *ctx);
  374. /**
  375. * get interfaces for the active CTL .
  376. * @ctx : ctl path ctx pointer
  377. * @return : bit mask with the active interfaces for the CTL
  378. */
  379. u32 (*get_ctl_intf)(struct sde_hw_ctl *ctx);
  380. /**
  381. * read CTL layers register value and return
  382. * the data.
  383. * @ctx : ctl path ctx pointer
  384. * @index : layer index for this ctl path
  385. * @return : CTL layers register value
  386. */
  387. u32 (*read_ctl_layers)(struct sde_hw_ctl *ctx, int index);
  388. /**
  389. * Set all blend stages to disabled
  390. * @ctx : ctl path ctx pointer
  391. */
  392. void (*clear_all_blendstages)(struct sde_hw_ctl *ctx);
  393. /**
  394. * Configure layer mixer to pipe configuration
  395. * @ctx : ctl path ctx pointer
  396. * @lm : layer mixer enumeration
  397. * @cfg : blend stage configuration
  398. */
  399. void (*setup_blendstage)(struct sde_hw_ctl *ctx,
  400. enum sde_lm lm, struct sde_hw_stage_cfg *cfg);
  401. /**
  402. * Get all the sspp staged on a layer mixer
  403. * @ctx : ctl path ctx pointer
  404. * @lm : layer mixer enumeration
  405. * @info : array address to populate connected sspp index info
  406. * @info_max_cnt : maximum sspp info elements based on array size
  407. * @Return: count of sspps info elements populated
  408. */
  409. u32 (*get_staged_sspp)(struct sde_hw_ctl *ctx, enum sde_lm lm,
  410. struct sde_sspp_index_info *info, u32 info_max_cnt);
  411. /**
  412. * Flush the reg dma by sending last command.
  413. * @ctx : ctl path ctx pointer
  414. * @blocking : if set to true api will block until flush is done
  415. * @Return: error code
  416. */
  417. int (*reg_dma_flush)(struct sde_hw_ctl *ctx, bool blocking);
  418. /**
  419. * check if ctl start trigger state to confirm the frame pending
  420. * status
  421. * @ctx : ctl path ctx pointer
  422. * @Return: error code
  423. */
  424. int (*get_start_state)(struct sde_hw_ctl *ctx);
  425. };
  426. /**
  427. * struct sde_hw_ctl : CTL PATH driver object
  428. * @base: hardware block base structure
  429. * @hw: block register map object
  430. * @idx: control path index
  431. * @caps: control path capabilities
  432. * @mixer_count: number of mixers
  433. * @mixer_hw_caps: mixer hardware capabilities
  434. * @flush: storage for pending ctl_flush managed via ops
  435. * @ops: operation list
  436. */
  437. struct sde_hw_ctl {
  438. struct sde_hw_blk base;
  439. struct sde_hw_blk_reg_map hw;
  440. /* ctl path */
  441. int idx;
  442. const struct sde_ctl_cfg *caps;
  443. int mixer_count;
  444. const struct sde_lm_cfg *mixer_hw_caps;
  445. struct sde_ctl_flush_cfg flush;
  446. /* ops */
  447. struct sde_hw_ctl_ops ops;
  448. };
  449. /**
  450. * sde_hw_ctl - convert base object sde_hw_base to container
  451. * @hw: Pointer to base hardware block
  452. * return: Pointer to hardware block container
  453. */
  454. static inline struct sde_hw_ctl *to_sde_hw_ctl(struct sde_hw_blk *hw)
  455. {
  456. return container_of(hw, struct sde_hw_ctl, base);
  457. }
  458. /**
  459. * sde_hw_ctl_init(): Initializes the ctl_path hw driver object.
  460. * should be called before accessing every ctl path registers.
  461. * @idx: ctl_path index for which driver object is required
  462. * @addr: mapped register io address of MDP
  463. * @m : pointer to mdss catalog data
  464. */
  465. struct sde_hw_ctl *sde_hw_ctl_init(enum sde_ctl idx,
  466. void __iomem *addr,
  467. struct sde_mdss_cfg *m);
  468. /**
  469. * sde_hw_ctl_destroy(): Destroys ctl driver context
  470. * should be called to free the context
  471. */
  472. void sde_hw_ctl_destroy(struct sde_hw_ctl *ctx);
  473. #endif /*_SDE_HW_CTL_H */