dpu_rm.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. */
  14. #ifndef __DPU_RM_H__
  15. #define __DPU_RM_H__
  16. #include <linux/list.h>
  17. #include "msm_kms.h"
  18. #include "dpu_hw_top.h"
  19. /**
  20. * struct dpu_rm - DPU dynamic hardware resource manager
  21. * @dev: device handle for event logging purposes
  22. * @rsvps: list of hardware reservations by each crtc->encoder->connector
  23. * @hw_blks: array of lists of hardware resources present in the system, one
  24. * list per type of hardware block
  25. * @hw_mdp: hardware object for mdp_top
  26. * @lm_max_width: cached layer mixer maximum width
  27. * @rsvp_next_seq: sequence number for next reservation for debugging purposes
  28. * @rm_lock: resource manager mutex
  29. */
  30. struct dpu_rm {
  31. struct drm_device *dev;
  32. struct list_head rsvps;
  33. struct list_head hw_blks[DPU_HW_BLK_MAX];
  34. struct dpu_hw_mdp *hw_mdp;
  35. uint32_t lm_max_width;
  36. uint32_t rsvp_next_seq;
  37. struct mutex rm_lock;
  38. };
  39. /**
  40. * struct dpu_rm_hw_blk - resource manager internal structure
  41. * forward declaration for single iterator definition without void pointer
  42. */
  43. struct dpu_rm_hw_blk;
  44. /**
  45. * struct dpu_rm_hw_iter - iterator for use with dpu_rm
  46. * @hw: dpu_hw object requested, or NULL on failure
  47. * @blk: dpu_rm internal block representation. Clients ignore. Used as iterator.
  48. * @enc_id: DRM ID of Encoder client wishes to search for, or 0 for Any Encoder
  49. * @type: Hardware Block Type client wishes to search for.
  50. */
  51. struct dpu_rm_hw_iter {
  52. void *hw;
  53. struct dpu_rm_hw_blk *blk;
  54. uint32_t enc_id;
  55. enum dpu_hw_blk_type type;
  56. };
  57. /**
  58. * dpu_rm_init - Read hardware catalog and create reservation tracking objects
  59. * for all HW blocks.
  60. * @rm: DPU Resource Manager handle
  61. * @cat: Pointer to hardware catalog
  62. * @mmio: mapped register io address of MDP
  63. * @dev: device handle for event logging purposes
  64. * @Return: 0 on Success otherwise -ERROR
  65. */
  66. int dpu_rm_init(struct dpu_rm *rm,
  67. struct dpu_mdss_cfg *cat,
  68. void __iomem *mmio,
  69. struct drm_device *dev);
  70. /**
  71. * dpu_rm_destroy - Free all memory allocated by dpu_rm_init
  72. * @rm: DPU Resource Manager handle
  73. * @Return: 0 on Success otherwise -ERROR
  74. */
  75. int dpu_rm_destroy(struct dpu_rm *rm);
  76. /**
  77. * dpu_rm_reserve - Given a CRTC->Encoder->Connector display chain, analyze
  78. * the use connections and user requirements, specified through related
  79. * topology control properties, and reserve hardware blocks to that
  80. * display chain.
  81. * HW blocks can then be accessed through dpu_rm_get_* functions.
  82. * HW Reservations should be released via dpu_rm_release_hw.
  83. * @rm: DPU Resource Manager handle
  84. * @drm_enc: DRM Encoder handle
  85. * @crtc_state: Proposed Atomic DRM CRTC State handle
  86. * @topology: Pointer to topology info for the display
  87. * @test_only: Atomic-Test phase, discard results (unless property overrides)
  88. * @Return: 0 on Success otherwise -ERROR
  89. */
  90. int dpu_rm_reserve(struct dpu_rm *rm,
  91. struct drm_encoder *drm_enc,
  92. struct drm_crtc_state *crtc_state,
  93. struct msm_display_topology topology,
  94. bool test_only);
  95. /**
  96. * dpu_rm_reserve - Given the encoder for the display chain, release any
  97. * HW blocks previously reserved for that use case.
  98. * @rm: DPU Resource Manager handle
  99. * @enc: DRM Encoder handle
  100. * @Return: 0 on Success otherwise -ERROR
  101. */
  102. void dpu_rm_release(struct dpu_rm *rm, struct drm_encoder *enc);
  103. /**
  104. * dpu_rm_get_mdp - Retrieve HW block for MDP TOP.
  105. * This is never reserved, and is usable by any display.
  106. * @rm: DPU Resource Manager handle
  107. * @Return: Pointer to hw block or NULL
  108. */
  109. struct dpu_hw_mdp *dpu_rm_get_mdp(struct dpu_rm *rm);
  110. /**
  111. * dpu_rm_init_hw_iter - setup given iterator for new iteration over hw list
  112. * using dpu_rm_get_hw
  113. * @iter: iter object to initialize
  114. * @enc_id: DRM ID of Encoder client wishes to search for, or 0 for Any Encoder
  115. * @type: Hardware Block Type client wishes to search for.
  116. */
  117. void dpu_rm_init_hw_iter(
  118. struct dpu_rm_hw_iter *iter,
  119. uint32_t enc_id,
  120. enum dpu_hw_blk_type type);
  121. /**
  122. * dpu_rm_get_hw - retrieve reserved hw object given encoder and hw type
  123. * Meant to do a single pass through the hardware list to iteratively
  124. * retrieve hardware blocks of a given type for a given encoder.
  125. * Initialize an iterator object.
  126. * Set hw block type of interest. Set encoder id of interest, 0 for any.
  127. * Function returns first hw of type for that encoder.
  128. * Subsequent calls will return the next reserved hw of that type in-order.
  129. * Iterator HW pointer will be null on failure to find hw.
  130. * @rm: DPU Resource Manager handle
  131. * @iter: iterator object
  132. * @Return: true on match found, false on no match found
  133. */
  134. bool dpu_rm_get_hw(struct dpu_rm *rm, struct dpu_rm_hw_iter *iter);
  135. /**
  136. * dpu_rm_check_property_topctl - validate property bitmask before it is set
  137. * @val: user's proposed topology control bitmask
  138. * @Return: 0 on success or error
  139. */
  140. int dpu_rm_check_property_topctl(uint64_t val);
  141. #endif /* __DPU_RM_H__ */