sde_hw_intf.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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_INTF_H
  6. #define _SDE_HW_INTF_H
  7. #include "sde_hw_catalog.h"
  8. #include "sde_hw_mdss.h"
  9. #include "sde_hw_util.h"
  10. #include "sde_hw_blk.h"
  11. #include "sde_kms.h"
  12. struct sde_hw_intf;
  13. /* intf timing settings */
  14. struct intf_timing_params {
  15. u32 width; /* active width */
  16. u32 height; /* active height */
  17. u32 xres; /* Display panel width */
  18. u32 yres; /* Display panel height */
  19. u32 h_back_porch;
  20. u32 h_front_porch;
  21. u32 v_back_porch;
  22. u32 v_front_porch;
  23. u32 hsync_pulse_width;
  24. u32 vsync_pulse_width;
  25. u32 hsync_polarity;
  26. u32 vsync_polarity;
  27. u32 border_clr;
  28. u32 underflow_clr;
  29. u32 hsync_skew;
  30. u32 v_front_porch_fixed;
  31. bool wide_bus_en;
  32. bool compression_en;
  33. u32 extra_dto_cycles; /* for DP only */
  34. bool dsc_4hs_merge; /* DSC 4HS merge */
  35. bool poms_align_vsync; /* poms with vsync aligned */
  36. u32 dce_bytes_per_line;
  37. u32 vrefresh;
  38. };
  39. struct intf_prog_fetch {
  40. u8 enable;
  41. /* vsync counter for the front porch pixel line */
  42. u32 fetch_start;
  43. };
  44. struct intf_status {
  45. u8 is_en; /* interface timing engine is enabled or not */
  46. bool is_prog_fetch_en; /* interface prog fetch counter is enabled or not */
  47. u32 frame_count; /* frame count since timing engine enabled */
  48. u32 line_count; /* current line count including blanking */
  49. };
  50. struct intf_tear_status {
  51. u32 read_count; /* frame & line count for tear init value */
  52. u32 write_count; /* frame & line count for tear write */
  53. };
  54. struct intf_avr_params {
  55. u32 default_fps;
  56. u32 min_fps;
  57. u32 avr_mode; /* 0 - disable, 1 - continuous, 2 - one-shot */
  58. };
  59. /**
  60. * struct sde_hw_intf_ops : Interface to the interface Hw driver functions
  61. * Assumption is these functions will be called after clocks are enabled
  62. * @ setup_timing_gen : programs the timing engine
  63. * @ setup_prog_fetch : enables/disables the programmable fetch logic
  64. * @ setup_rot_start : enables/disables the rotator start trigger
  65. * @ enable_timing: enable/disable timing engine
  66. * @ get_status: returns if timing engine is enabled or not
  67. * @ setup_misr: enables/disables MISR in HW register
  68. * @ collect_misr: reads and stores MISR data from HW register
  69. * @ get_line_count: reads current vertical line counter
  70. * @ get_underrun_line_count: reads current underrun pixel clock count and
  71. * converts it into line count
  72. * @setup_vsync_source: Configure vsync source selection for intf
  73. * @bind_pingpong_blk: enable/disable the connection with pingpong which will
  74. * feed pixels to this interface
  75. */
  76. struct sde_hw_intf_ops {
  77. void (*setup_timing_gen)(struct sde_hw_intf *intf,
  78. const struct intf_timing_params *p,
  79. const struct sde_format *fmt);
  80. void (*setup_prg_fetch)(struct sde_hw_intf *intf,
  81. const struct intf_prog_fetch *fetch);
  82. void (*setup_rot_start)(struct sde_hw_intf *intf,
  83. const struct intf_prog_fetch *fetch);
  84. void (*enable_timing)(struct sde_hw_intf *intf,
  85. u8 enable);
  86. void (*get_status)(struct sde_hw_intf *intf,
  87. struct intf_status *status);
  88. void (*setup_misr)(struct sde_hw_intf *intf,
  89. bool enable, u32 frame_count);
  90. int (*collect_misr)(struct sde_hw_intf *intf,
  91. bool nonblock, u32 *misr_value);
  92. /**
  93. * returns the current scan line count of the display
  94. * video mode panels use get_line_count whereas get_vsync_info
  95. * is used for command mode panels
  96. */
  97. u32 (*get_line_count)(struct sde_hw_intf *intf);
  98. u32 (*get_underrun_line_count)(struct sde_hw_intf *intf);
  99. void (*setup_vsync_source)(struct sde_hw_intf *intf, u32 frame_rate);
  100. void (*bind_pingpong_blk)(struct sde_hw_intf *intf,
  101. bool enable,
  102. const enum sde_pingpong pp);
  103. /**
  104. * enables vysnc generation and sets up init value of
  105. * read pointer and programs the tear check cofiguration
  106. */
  107. int (*setup_tearcheck)(struct sde_hw_intf *intf,
  108. struct sde_hw_tear_check *cfg);
  109. /**
  110. * enables tear check block
  111. */
  112. int (*enable_tearcheck)(struct sde_hw_intf *intf,
  113. bool enable);
  114. /**
  115. * updates tearcheck configuration
  116. */
  117. void (*update_tearcheck)(struct sde_hw_intf *intf,
  118. struct sde_hw_tear_check *cfg);
  119. /**
  120. * read, modify, write to either set or clear listening to external TE
  121. * @Return: 1 if TE was originally connected, 0 if not, or -ERROR
  122. */
  123. int (*connect_external_te)(struct sde_hw_intf *intf,
  124. bool enable_external_te);
  125. /**
  126. * provides the programmed and current
  127. * line_count
  128. */
  129. int (*get_vsync_info)(struct sde_hw_intf *intf,
  130. struct sde_hw_pp_vsync_info *info);
  131. /**
  132. * configure and enable the autorefresh config
  133. */
  134. int (*setup_autorefresh)(struct sde_hw_intf *intf,
  135. struct sde_hw_autorefresh *cfg);
  136. /**
  137. * retrieve autorefresh config from hardware
  138. */
  139. int (*get_autorefresh)(struct sde_hw_intf *intf,
  140. struct sde_hw_autorefresh *cfg);
  141. /**
  142. * poll until write pointer transmission starts
  143. * @Return: 0 on success, -ETIMEDOUT on timeout
  144. */
  145. int (*poll_timeout_wr_ptr)(struct sde_hw_intf *intf, u32 timeout_us);
  146. /**
  147. * Select vsync signal for tear-effect configuration
  148. */
  149. void (*vsync_sel)(struct sde_hw_intf *intf, u32 vsync_source);
  150. /**
  151. * Program the AVR_TOTAL for min fps rate
  152. */
  153. int (*avr_setup)(struct sde_hw_intf *intf,
  154. const struct intf_timing_params *params,
  155. const struct intf_avr_params *avr_params);
  156. /**
  157. * Signal the trigger on each commit for AVR
  158. */
  159. void (*avr_trigger)(struct sde_hw_intf *ctx);
  160. /**
  161. * Enable AVR and select the mode
  162. */
  163. void (*avr_ctrl)(struct sde_hw_intf *intf,
  164. const struct intf_avr_params *avr_params);
  165. /**
  166. * Indicates the AVR armed status
  167. *
  168. * @return: false if a trigger is pending, else true while AVR is enabled
  169. */
  170. u32 (*get_avr_status)(struct sde_hw_intf *intf);
  171. /**
  172. * Enable/disable 64 bit compressed data input to interface block
  173. */
  174. void (*enable_compressed_input)(struct sde_hw_intf *intf,
  175. bool compression_en, bool dsc_4hs_merge);
  176. /**
  177. * Check the intf tear check status and reset it to start_pos
  178. */
  179. int (*check_and_reset_tearcheck)(struct sde_hw_intf *intf,
  180. struct intf_tear_status *status);
  181. /**
  182. * Reset the interface frame & line counter
  183. */
  184. void (*reset_counter)(struct sde_hw_intf *intf);
  185. /**
  186. * Get the HW vsync timestamp counter
  187. */
  188. u64 (*get_vsync_timestamp)(struct sde_hw_intf *intf);
  189. /**
  190. * Enable processing of 2 pixels per clock
  191. */
  192. void (*enable_wide_bus)(struct sde_hw_intf *intf, bool enable);
  193. /**
  194. * Get the INTF interrupt status
  195. */
  196. u32 (*get_intr_status)(struct sde_hw_intf *intf);
  197. };
  198. struct sde_hw_intf {
  199. struct sde_hw_blk base;
  200. struct sde_hw_blk_reg_map hw;
  201. /* intf */
  202. enum sde_intf idx;
  203. const struct sde_intf_cfg *cap;
  204. const struct sde_mdss_cfg *mdss;
  205. struct split_pipe_cfg cfg;
  206. /* ops */
  207. struct sde_hw_intf_ops ops;
  208. };
  209. /**
  210. * to_sde_hw_intf - convert base object sde_hw_base to container
  211. * @hw: Pointer to base hardware block
  212. * return: Pointer to hardware block container
  213. */
  214. static inline struct sde_hw_intf *to_sde_hw_intf(struct sde_hw_blk *hw)
  215. {
  216. return container_of(hw, struct sde_hw_intf, base);
  217. }
  218. /**
  219. * sde_hw_intf_init(): Initializes the intf driver for the passed
  220. * interface idx.
  221. * @idx: interface index for which driver object is required
  222. * @addr: mapped register io address of MDP
  223. * @m : pointer to mdss catalog data
  224. */
  225. struct sde_hw_intf *sde_hw_intf_init(enum sde_intf idx,
  226. void __iomem *addr,
  227. struct sde_mdss_cfg *m);
  228. /**
  229. * sde_hw_intf_destroy(): Destroys INTF driver context
  230. * @intf: Pointer to INTF driver context
  231. */
  232. void sde_hw_intf_destroy(struct sde_hw_intf *intf);
  233. #endif /*_SDE_HW_INTF_H */