sde_rm.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef __SDE_RM_H__
  6. #define __SDE_RM_H__
  7. #include <linux/list.h>
  8. #include "msm_kms.h"
  9. #include "sde_hw_top.h"
  10. #define SINGLE_CTL 1
  11. #define DUAL_CTL 2
  12. /**
  13. * enum sde_rm_topology_name - HW resource use case in use by connector
  14. * @SDE_RM_TOPOLOGY_NONE: No topology in use currently
  15. * @SDE_RM_TOPOLOGY_SINGLEPIPE: 1 LM, 1 PP, 1 INTF/WB
  16. * @SDE_RM_TOPOLOGY_SINGLEPIPE_DSC: 1 LM, 1 DSC, 1 PP, 1 INTF/WB
  17. * @SDE_RM_TOPOLOGY_DUALPIPE: 2 LM, 2 PP, 2 INTF/WB
  18. * @SDE_RM_TOPOLOGY_DUALPIPE_DSC: 2 LM, 2 DSC, 2 PP, 2 INTF/WB
  19. * @SDE_RM_TOPOLOGY_DUALPIPE_3DMERGE: 2 LM, 2 PP, 3DMux, 1 INTF/WB
  20. * @SDE_RM_TOPOLOGY_DUALPIPE_3DMERGE_DSC: 2 LM, 2 PP, 3DMux, 1 DSC, 1 INTF/WB
  21. * @SDE_RM_TOPOLOGY_DUALPIPE_DSCMERGE: 2 LM, 2 PP, 2 DSC Merge, 1 INTF/WB
  22. * @SDE_RM_TOPOLOGY_PPSPLIT: 1 LM, 2 PPs, 2 INTF/WB
  23. */
  24. enum sde_rm_topology_name {
  25. SDE_RM_TOPOLOGY_NONE = 0,
  26. SDE_RM_TOPOLOGY_SINGLEPIPE,
  27. SDE_RM_TOPOLOGY_SINGLEPIPE_DSC,
  28. SDE_RM_TOPOLOGY_DUALPIPE,
  29. SDE_RM_TOPOLOGY_DUALPIPE_DSC,
  30. SDE_RM_TOPOLOGY_DUALPIPE_3DMERGE,
  31. SDE_RM_TOPOLOGY_DUALPIPE_3DMERGE_DSC,
  32. SDE_RM_TOPOLOGY_DUALPIPE_DSCMERGE,
  33. SDE_RM_TOPOLOGY_PPSPLIT,
  34. SDE_RM_TOPOLOGY_MAX,
  35. };
  36. /**
  37. * enum sde_rm_topology_control - HW resource use case in use by connector
  38. * @SDE_RM_TOPCTL_RESERVE_LOCK: If set, in AtomicTest phase, after a successful
  39. * test, reserve the resources for this display.
  40. * Normal behavior would not impact the reservation
  41. * list during the AtomicTest phase.
  42. * @SDE_RM_TOPCTL_RESERVE_CLEAR: If set, in AtomicTest phase, before testing,
  43. * release any reservation held by this display.
  44. * Normal behavior would not impact the
  45. * reservation list during the AtomicTest phase.
  46. * @SDE_RM_TOPCTL_DSPP: Require layer mixers with DSPP capabilities
  47. * @SDE_RM_TOPCTL_DS : Require layer mixers with DS capabilities
  48. * @SDE_RM_TOPCTL_CWB : Require layer mixers with CWB capabilities
  49. */
  50. enum sde_rm_topology_control {
  51. SDE_RM_TOPCTL_RESERVE_LOCK,
  52. SDE_RM_TOPCTL_RESERVE_CLEAR,
  53. SDE_RM_TOPCTL_DSPP,
  54. SDE_RM_TOPCTL_DS,
  55. SDE_RM_TOPCTL_CWB,
  56. };
  57. /**
  58. * enum sde_rm_topology_control - HW resource use case in use by connector
  59. * @SDE_RM_QSYNC_DISABLED: If set, Qsync feature is supported and in
  60. * disable state.
  61. * @SDE_RM_QSYNC_CONTINUOUS_MODE: If set, Qsync is enabled in continuous
  62. * mode.
  63. */
  64. enum sde_rm_qsync_modes {
  65. SDE_RM_QSYNC_DISABLED,
  66. SDE_RM_QSYNC_CONTINUOUS_MODE,
  67. };
  68. /**
  69. * struct sde_rm_topology_def - Topology table definition
  70. * @top_name: name identifying this topology
  71. * @num_lm: number of layer mixers used
  72. * @num_comp_enc: number of encoders used
  73. * @num_intf: number of interface used
  74. * @num_ctl: number of control path used
  75. * @needs_split_display: If set split display is enabled
  76. */
  77. struct sde_rm_topology_def {
  78. enum sde_rm_topology_name top_name;
  79. int num_lm;
  80. int num_comp_enc;
  81. int num_intf;
  82. int num_ctl;
  83. int needs_split_display;
  84. };
  85. /**
  86. * struct sde_rm - SDE dynamic hardware resource manager
  87. * @dev: device handle for event logging purposes
  88. * @rsvps: list of hardware reservations by each crtc->encoder->connector
  89. * @hw_blks: array of lists of hardware resources present in the system, one
  90. * list per type of hardware block
  91. * @hw_mdp: hardware object for mdp_top
  92. * @lm_max_width: cached layer mixer maximum width
  93. * @rsvp_next_seq: sequence number for next reservation for debugging purposes
  94. * @rm_lock: resource manager mutex
  95. * @avail_res: Pointer with curr available resources
  96. */
  97. struct sde_rm {
  98. struct drm_device *dev;
  99. struct list_head rsvps;
  100. struct list_head hw_blks[SDE_HW_BLK_MAX];
  101. struct sde_hw_mdp *hw_mdp;
  102. uint32_t lm_max_width;
  103. uint32_t rsvp_next_seq;
  104. struct mutex rm_lock;
  105. const struct sde_rm_topology_def *topology_tbl;
  106. struct msm_resource_caps_info avail_res;
  107. };
  108. /**
  109. * struct sde_rm_hw_blk - resource manager internal structure
  110. * forward declaration for single iterator definition without void pointer
  111. */
  112. struct sde_rm_hw_blk;
  113. /**
  114. * struct sde_rm_hw_iter - iterator for use with sde_rm
  115. * @hw: sde_hw object requested, or NULL on failure
  116. * @blk: sde_rm internal block representation. Clients ignore. Used as iterator.
  117. * @enc_id: DRM ID of Encoder client wishes to search for, or 0 for Any Encoder
  118. * @type: Hardware Block Type client wishes to search for.
  119. */
  120. struct sde_rm_hw_iter {
  121. void *hw;
  122. struct sde_rm_hw_blk *blk;
  123. uint32_t enc_id;
  124. enum sde_hw_blk_type type;
  125. };
  126. /**
  127. * struct sde_rm_hw_request - data for requesting hw blk
  128. * @hw: sde_hw object requested, or NULL on failure
  129. * @type: Hardware Block Type client wishes to search for
  130. * @id: Hardware block id
  131. */
  132. struct sde_rm_hw_request {
  133. void *hw;
  134. enum sde_hw_blk_type type;
  135. int id;
  136. };
  137. /**
  138. * sde_rm_get_topology_name - get the name of the given topology config
  139. * @topology: msm_display_topology topology config
  140. * @Return: name of the given topology
  141. */
  142. enum sde_rm_topology_name sde_rm_get_topology_name(
  143. struct msm_display_topology topology);
  144. /**
  145. * sde_rm_init - Read hardware catalog and create reservation tracking objects
  146. * for all HW blocks.
  147. * @rm: SDE Resource Manager handle
  148. * @cat: Pointer to hardware catalog
  149. * @mmio: mapped register io address of MDP
  150. * @dev: device handle for event logging purposes
  151. * @Return: 0 on Success otherwise -ERROR
  152. */
  153. int sde_rm_init(struct sde_rm *rm,
  154. struct sde_mdss_cfg *cat,
  155. void __iomem *mmio,
  156. struct drm_device *dev);
  157. /**
  158. * sde_rm_destroy - Free all memory allocated by sde_rm_init
  159. * @rm: SDE Resource Manager handle
  160. * @Return: 0 on Success otherwise -ERROR
  161. */
  162. int sde_rm_destroy(struct sde_rm *rm);
  163. /**
  164. * sde_rm_reserve - Given a CRTC->Encoder->Connector display chain, analyze
  165. * the use connections and user requirements, specified through related
  166. * topology control properties, and reserve hardware blocks to that
  167. * display chain.
  168. * HW blocks can then be accessed through sde_rm_get_* functions.
  169. * HW Reservations should be released via sde_rm_release_hw.
  170. * @rm: SDE Resource Manager handle
  171. * @drm_enc: DRM Encoder handle
  172. * @crtc_state: Proposed Atomic DRM CRTC State handle
  173. * @conn_state: Proposed Atomic DRM Connector State handle
  174. * @test_only: Atomic-Test phase, discard results (unless property overrides)
  175. * @Return: 0 on Success otherwise -ERROR
  176. */
  177. int sde_rm_reserve(struct sde_rm *rm,
  178. struct drm_encoder *drm_enc,
  179. struct drm_crtc_state *crtc_state,
  180. struct drm_connector_state *conn_state,
  181. bool test_only);
  182. /**
  183. * sde_rm_release - Given the encoder for the display chain, release any
  184. * HW blocks previously reserved for that use case.
  185. * @rm: SDE Resource Manager handle
  186. * @enc: DRM Encoder handle
  187. * @nxt: Choose option to release rsvp_nxt
  188. * @Return: 0 on Success otherwise -ERROR
  189. */
  190. void sde_rm_release(struct sde_rm *rm, struct drm_encoder *enc, bool nxt);
  191. /**
  192. * sde_rm_get_mdp - Retrieve HW block for MDP TOP.
  193. * This is never reserved, and is usable by any display.
  194. * @rm: SDE Resource Manager handle
  195. * @Return: Pointer to hw block or NULL
  196. */
  197. struct sde_hw_mdp *sde_rm_get_mdp(struct sde_rm *rm);
  198. /**
  199. * sde_rm_init_hw_iter - setup given iterator for new iteration over hw list
  200. * using sde_rm_get_hw
  201. * @iter: iter object to initialize
  202. * @enc_id: DRM ID of Encoder client wishes to search for, or 0 for Any Encoder
  203. * @type: Hardware Block Type client wishes to search for.
  204. */
  205. void sde_rm_init_hw_iter(
  206. struct sde_rm_hw_iter *iter,
  207. uint32_t enc_id,
  208. enum sde_hw_blk_type type);
  209. /**
  210. * sde_rm_get_hw - retrieve reserved hw object given encoder and hw type
  211. * Meant to do a single pass through the hardware list to iteratively
  212. * retrieve hardware blocks of a given type for a given encoder.
  213. * Initialize an iterator object.
  214. * Set hw block type of interest. Set encoder id of interest, 0 for any.
  215. * Function returns first hw of type for that encoder.
  216. * Subsequent calls will return the next reserved hw of that type in-order.
  217. * Iterator HW pointer will be null on failure to find hw.
  218. * @rm: SDE Resource Manager handle
  219. * @iter: iterator object
  220. * @Return: true on match found, false on no match found
  221. */
  222. bool sde_rm_get_hw(struct sde_rm *rm, struct sde_rm_hw_iter *iter);
  223. /**
  224. * sde_rm_request_hw_blk - retrieve the requested hardware block
  225. * @rm: SDE Resource Manager handle
  226. * @hw: holds the input and output information of the requested hw block
  227. * @Return: true on match found, false on no match found
  228. */
  229. bool sde_rm_request_hw_blk(struct sde_rm *rm, struct sde_rm_hw_request *hw);
  230. /**
  231. * sde_rm_cont_splash_res_init - Read the current MDSS configuration
  232. * to update the splash data structure with the topology
  233. * configured by the bootloader.
  234. * @priv: DRM private structure handle
  235. * @rm: SDE Resource Manager handle
  236. * @splash_data: Pointer to the splash_data structure to be updated.
  237. * @cat: Pointer to the SDE catalog
  238. * @Return: 0 on success or error
  239. */
  240. int sde_rm_cont_splash_res_init(struct msm_drm_private *priv,
  241. struct sde_rm *rm,
  242. struct sde_splash_data *splash_data,
  243. struct sde_mdss_cfg *cat);
  244. /**
  245. * sde_rm_update_topology - sets topology property of the connector
  246. * @conn_state: drm state of the connector
  247. * @topology: topology selected for the display
  248. * @return: 0 on success or error
  249. */
  250. int sde_rm_update_topology(struct drm_connector_state *conn_state,
  251. struct msm_display_topology *topology);
  252. /**
  253. * sde_rm_topology_is_dual_ctl - checks if topoloy requires two control paths
  254. * @rm: SDE Resource Manager handle
  255. * @topology: topology selected for the display
  256. * @return: true if two control paths are required or false
  257. */
  258. static inline bool sde_rm_topology_is_dual_ctl(struct sde_rm *rm,
  259. enum sde_rm_topology_name topology)
  260. {
  261. if ((!rm) || (topology <= SDE_RM_TOPOLOGY_NONE) ||
  262. (topology >= SDE_RM_TOPOLOGY_MAX)) {
  263. pr_err("invalid arguments: rm:%d topology:%d\n",
  264. rm == NULL, topology);
  265. return false;
  266. }
  267. return rm->topology_tbl[topology].num_ctl == DUAL_CTL;
  268. }
  269. /**
  270. * sde_rm_ext_blk_create_reserve - Create external HW blocks
  271. * in resource manager and reserve for specific encoder.
  272. * @rm: SDE Resource Manager handle
  273. * @hw: external HW block
  274. * @drm_enc: DRM Encoder handle
  275. * @Return: 0 on Success otherwise -ERROR
  276. */
  277. int sde_rm_ext_blk_create_reserve(struct sde_rm *rm,
  278. struct sde_hw_blk *hw,
  279. struct drm_encoder *enc);
  280. /**
  281. * sde_rm_ext_blk_destroy - Given the encoder for the display chain, release
  282. * external HW blocks created for that.
  283. * @rm: SDE Resource Manager handle
  284. * @enc: DRM Encoder handle
  285. * @Return: 0 on Success otherwise -ERROR
  286. */
  287. int sde_rm_ext_blk_destroy(struct sde_rm *rm,
  288. struct drm_encoder *enc);
  289. /**
  290. * sde_rm_get_resource_info - returns avail hw resource info
  291. * @mr: sde rm object
  292. * @drm_enc: drm encoder object
  293. * @avail_res: out parameter, available resource object
  294. */
  295. void sde_rm_get_resource_info(struct sde_rm *rm,
  296. struct drm_encoder *drm_enc,
  297. struct msm_resource_caps_info *avail_res);
  298. #endif /* __SDE_RM_H__ */