sde_hw_wb.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2015-2021, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _SDE_HW_WB_H
  6. #define _SDE_HW_WB_H
  7. #include "sde_hw_catalog.h"
  8. #include "sde_hw_mdss.h"
  9. #include "sde_hw_top.h"
  10. #include "sde_hw_util.h"
  11. struct sde_hw_wb;
  12. struct sde_hw_wb_cfg {
  13. struct sde_hw_fmt_layout dest;
  14. enum sde_intf_mode intf_mode;
  15. struct sde_rect roi;
  16. struct sde_rect crop;
  17. bool is_secure;
  18. };
  19. /**
  20. * enum CDP preload ahead address size
  21. */
  22. enum {
  23. SDE_WB_CDP_PRELOAD_AHEAD_32,
  24. SDE_WB_CDP_PRELOAD_AHEAD_64
  25. };
  26. /**
  27. * struct sde_hw_wb_cdp_cfg : CDP configuration
  28. * @enable: true to enable CDP
  29. * @ubwc_meta_enable: true to enable ubwc metadata preload
  30. * @tile_amortize_enable: true to enable amortization control for tile format
  31. * @preload_ahead: number of request to preload ahead
  32. * SDE_WB_CDP_PRELOAD_AHEAD_32,
  33. * SDE_WB_CDP_PRELOAD_AHEAD_64
  34. */
  35. struct sde_hw_wb_cdp_cfg {
  36. bool enable;
  37. bool ubwc_meta_enable;
  38. bool tile_amortize_enable;
  39. u32 preload_ahead;
  40. };
  41. /**
  42. * struct sde_hw_wb_qos_cfg : Writeback pipe QoS configuration
  43. * @danger_lut: LUT for generate danger level based on fill level
  44. * @safe_lut: LUT for generate safe level based on fill level
  45. * @creq_lut: LUT for generate creq level based on fill level
  46. * @danger_safe_en: enable danger safe generation
  47. */
  48. struct sde_hw_wb_qos_cfg {
  49. u32 danger_lut;
  50. u32 safe_lut;
  51. u64 creq_lut;
  52. bool danger_safe_en;
  53. };
  54. /**
  55. *
  56. * struct sde_hw_wb_ops : Interface to the wb Hw driver functions
  57. * Assumption is these functions will be called after clocks are enabled
  58. */
  59. struct sde_hw_wb_ops {
  60. void (*setup_csc_data)(struct sde_hw_wb *ctx,
  61. struct sde_csc_cfg *data);
  62. void (*setup_outaddress)(struct sde_hw_wb *ctx,
  63. struct sde_hw_wb_cfg *wb);
  64. void (*setup_outformat)(struct sde_hw_wb *ctx,
  65. struct sde_hw_wb_cfg *wb);
  66. void (*setup_rotator)(struct sde_hw_wb *ctx,
  67. struct sde_hw_wb_cfg *wb);
  68. void (*setup_dither)(struct sde_hw_wb *ctx,
  69. struct sde_hw_wb_cfg *wb);
  70. void (*setup_cdwn)(struct sde_hw_wb *ctx,
  71. struct sde_hw_wb_cfg *wb);
  72. void (*setup_trafficshaper)(struct sde_hw_wb *ctx,
  73. struct sde_hw_wb_cfg *wb);
  74. void (*setup_roi)(struct sde_hw_wb *ctx,
  75. struct sde_hw_wb_cfg *wb);
  76. void (*setup_crop)(struct sde_hw_wb *ctx,
  77. struct sde_hw_wb_cfg *wb, bool crop);
  78. /**
  79. * setup_qos_lut - setup danger, safe, creq, etc. LUTs
  80. * @ctx: Pointer to pipe context
  81. * @cfg: Pointer to pipe QoS configuration
  82. */
  83. void (*setup_qos_lut)(struct sde_hw_wb *ctx,
  84. struct sde_hw_wb_qos_cfg *cfg);
  85. /**
  86. * setup_cdp - setup CDP
  87. * @ctx: Pointer to pipe context
  88. * @cfg: Pointer to pipe CDP configuration
  89. */
  90. void (*setup_cdp)(struct sde_hw_wb *ctx,
  91. struct sde_hw_wb_cdp_cfg *cfg);
  92. /**
  93. * bind_pingpong_blk - enable/disable the connection with pp
  94. * @ctx: Pointer to wb context
  95. * @enable: enable/disable connection
  96. * @pp: pingpong blk id
  97. */
  98. void (*bind_pingpong_blk)(struct sde_hw_wb *ctx,
  99. bool enable,
  100. const enum sde_pingpong pp);
  101. /**
  102. * bind_dcwb_pp_blk - enable/disable the connection with cwb pp
  103. * @ctx: Pointer to wb context
  104. * @enable: enable/disable connection
  105. * @pp: pingpong blk id
  106. */
  107. void (*bind_dcwb_pp_blk)(struct sde_hw_wb *ctx,
  108. bool enable,
  109. const enum sde_pingpong pp);
  110. /**
  111. * program_cwb_ctrl - program cwb block configp
  112. * @ctx: Pointer to wb context
  113. * @pp_idx: Current CWB block index to poram
  114. * @data_src: Source CWB/PingPong block index
  115. * @dspp_out: Tap dspp output or default LM output
  116. * @enable: enable or disable the CWB path to tap the output
  117. */
  118. void (*program_cwb_ctrl)(struct sde_hw_wb *ctx, const enum sde_cwb cwb,
  119. const enum sde_cwb data_src, bool dspp_out, bool enable);
  120. /**
  121. * program_dcwb_ctrl - program cwb block configp
  122. * @ctx: Pointer to wb context
  123. * @pp_idx: Current CWB block index to poram
  124. * @data_src: Source CWB/PingPong block index
  125. * @tap_location: Tap LM output, dspp output or Demura output
  126. * @enable: enable or disable the CWB path to tap the output
  127. */
  128. void (*program_dcwb_ctrl)(struct sde_hw_wb *ctx, const enum sde_dcwb cwb,
  129. const enum sde_cwb data_src, int tap_location, bool enable);
  130. };
  131. /**
  132. * struct sde_hw_wb : WB driver object
  133. * @base: hardware block base structure
  134. * @hw: block hardware details
  135. * @catalog: back pointer to catalog
  136. * @mdp: pointer to associated mdp portion of the catalog
  137. * @idx: hardware index number within type
  138. * @wb_hw_caps: hardware capabilities
  139. * @ops: function pointers
  140. * @hw_mdp: MDP top level hardware block
  141. * @cwb_hw: CWB control hwio details
  142. * @dcwb_hw: DCWB control hwio details
  143. */
  144. struct sde_hw_wb {
  145. struct sde_hw_blk base;
  146. struct sde_hw_blk_reg_map hw;
  147. struct sde_mdss_cfg *catalog;
  148. struct sde_mdp_cfg *mdp;
  149. /* wb path */
  150. int idx;
  151. const struct sde_wb_cfg *caps;
  152. /* ops */
  153. struct sde_hw_wb_ops ops;
  154. struct sde_hw_mdp *hw_mdp;
  155. struct sde_hw_blk_reg_map cwb_hw;
  156. struct sde_hw_blk_reg_map dcwb_hw;
  157. };
  158. /**
  159. * sde_hw_wb - convert base object sde_hw_base to container
  160. * @hw: Pointer to base hardware block
  161. * return: Pointer to hardware block container
  162. */
  163. static inline struct sde_hw_wb *to_sde_hw_wb(struct sde_hw_blk *hw)
  164. {
  165. return container_of(hw, struct sde_hw_wb, base);
  166. }
  167. /**
  168. * sde_hw_wb_init(): Initializes and return writeback hw driver object.
  169. * @idx: wb_path index for which driver object is required
  170. * @addr: mapped register io address of MDP
  171. * @m : pointer to mdss catalog data
  172. * @hw_mdp: pointer to mdp top hw driver object
  173. */
  174. struct sde_hw_wb *sde_hw_wb_init(enum sde_wb idx,
  175. void __iomem *addr,
  176. struct sde_mdss_cfg *m,
  177. struct sde_hw_mdp *hw_mdp);
  178. /**
  179. * sde_hw_wb_destroy(): Destroy writeback hw driver object.
  180. * @hw_wb: Pointer to writeback hw driver object
  181. */
  182. void sde_hw_wb_destroy(struct sde_hw_wb *hw_wb);
  183. #endif /*_SDE_HW_WB_H */