sde_hw_intf.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  4. * Copyright (c) 2015-2021, The Linux Foundation. All rights reserved.
  5. */
  6. #ifndef _SDE_HW_INTF_H
  7. #define _SDE_HW_INTF_H
  8. #include "sde_hw_catalog.h"
  9. #include "sde_hw_mdss.h"
  10. #include "sde_hw_util.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_frame_count; /* frame count for tear init value */
  52. u32 read_line_count; /* line count for tear init value */
  53. u32 write_frame_count; /* frame count for tear write */
  54. u32 write_line_count; /* line count for tear write */
  55. };
  56. struct intf_avr_params {
  57. u32 default_fps;
  58. u32 min_fps;
  59. u32 avr_mode; /* one of enum @sde_rm_qsync_modes */
  60. u32 avr_step_lines; /* 0 or 1 means disabled */
  61. };
  62. /**
  63. * struct intf_wd_jitter_params : Interface to the INTF WD Jitter params.
  64. * jitter : max instantaneous jitter.
  65. * ltj_max : max long term jitter value.
  66. * ltj_slope : slope of long term jitter.
  67. *ltj_step_dir: direction of the step in LTJ
  68. *ltj_initial_val: LTJ initial value
  69. *ltj_fractional_val: LTJ fractional initial value
  70. */
  71. struct intf_wd_jitter_params {
  72. u32 jitter;
  73. u32 ltj_max;
  74. u32 ltj_slope;
  75. u8 ltj_step_dir;
  76. u32 ltj_initial_val;
  77. u32 ltj_fractional_val;
  78. };
  79. /**
  80. * struct sde_hw_intf_ops : Interface to the interface Hw driver functions
  81. * Assumption is these functions will be called after clocks are enabled
  82. * @ setup_timing_gen : programs the timing engine
  83. * @ setup_prog_fetch : enables/disables the programmable fetch logic
  84. * @ setup_rot_start : enables/disables the rotator start trigger
  85. * @ enable_timing: enable/disable timing engine
  86. * @ get_status: returns if timing engine is enabled or not
  87. * @ setup_misr: enables/disables MISR in HW register
  88. * @ collect_misr: reads and stores MISR data from HW register
  89. * @ get_line_count: reads current vertical line counter
  90. * @ get_underrun_line_count: reads current underrun pixel clock count and
  91. * converts it into line count
  92. * @setup_vsync_source: Configure vsync source selection for intf
  93. * @configure_wd_jitter: Configure WD jitter.
  94. * @ write_wd_ltj: Write WD long term jitter.
  95. * @get_wd_ltj_status: Read WD long term jitter status.
  96. * @bind_pingpong_blk: enable/disable the connection with pingpong which will
  97. * feed pixels to this interface
  98. * @get_autorefresh_status: Check the status of autorefresh is busy or idle
  99. */
  100. struct sde_hw_intf_ops {
  101. void (*setup_timing_gen)(struct sde_hw_intf *intf,
  102. const struct intf_timing_params *p,
  103. const struct sde_format *fmt);
  104. void (*setup_prg_fetch)(struct sde_hw_intf *intf,
  105. const struct intf_prog_fetch *fetch);
  106. void (*setup_rot_start)(struct sde_hw_intf *intf,
  107. const struct intf_prog_fetch *fetch);
  108. void (*enable_timing)(struct sde_hw_intf *intf,
  109. u8 enable);
  110. void (*get_status)(struct sde_hw_intf *intf,
  111. struct intf_status *status);
  112. void (*setup_misr)(struct sde_hw_intf *intf,
  113. bool enable, u32 frame_count);
  114. int (*collect_misr)(struct sde_hw_intf *intf,
  115. bool nonblock, u32 *misr_value);
  116. /**
  117. * returns the current scan line count of the display
  118. * video mode panels use get_line_count whereas get_vsync_info
  119. * is used for command mode panels
  120. */
  121. u32 (*get_line_count)(struct sde_hw_intf *intf);
  122. u32 (*get_underrun_line_count)(struct sde_hw_intf *intf);
  123. void (*setup_vsync_source)(struct sde_hw_intf *intf, u32 frame_rate);
  124. void (*configure_wd_jitter)(struct sde_hw_intf *intf,
  125. struct intf_wd_jitter_params *wd_jitter);
  126. void (*write_wd_ltj)(struct sde_hw_intf *intf,
  127. struct intf_wd_jitter_params *wd_jitter);
  128. void (*get_wd_ltj_status)(struct sde_hw_intf *intf,
  129. struct intf_wd_jitter_params *wd_jitter);
  130. void (*bind_pingpong_blk)(struct sde_hw_intf *intf,
  131. bool enable,
  132. const enum sde_pingpong pp);
  133. u32 (*get_autorefresh_status)(struct sde_hw_intf *intf);
  134. /**
  135. * enables vysnc generation and sets up init value of
  136. * read pointer and programs the tear check cofiguration
  137. */
  138. int (*setup_tearcheck)(struct sde_hw_intf *intf,
  139. struct sde_hw_tear_check *cfg);
  140. /**
  141. * enables tear check block
  142. */
  143. int (*enable_tearcheck)(struct sde_hw_intf *intf,
  144. bool enable);
  145. /**
  146. * updates tearcheck configuration
  147. */
  148. void (*update_tearcheck)(struct sde_hw_intf *intf,
  149. struct sde_hw_tear_check *cfg);
  150. /**
  151. * read, modify, write to either set or clear listening to external TE
  152. * @Return: 1 if TE was originally connected, 0 if not, or -ERROR
  153. */
  154. int (*connect_external_te)(struct sde_hw_intf *intf,
  155. bool enable_external_te);
  156. /**
  157. * provides the programmed and current
  158. * line_count
  159. */
  160. int (*get_vsync_info)(struct sde_hw_intf *intf,
  161. struct sde_hw_pp_vsync_info *info);
  162. /**
  163. * configure and enable the autorefresh config
  164. */
  165. int (*setup_autorefresh)(struct sde_hw_intf *intf,
  166. struct sde_hw_autorefresh *cfg);
  167. /**
  168. * retrieve autorefresh config from hardware
  169. */
  170. int (*get_autorefresh)(struct sde_hw_intf *intf,
  171. struct sde_hw_autorefresh *cfg);
  172. /**
  173. * poll until write pointer transmission starts
  174. * @Return: 0 on success, -ETIMEDOUT on timeout
  175. */
  176. int (*poll_timeout_wr_ptr)(struct sde_hw_intf *intf, u32 timeout_us);
  177. /**
  178. * Select vsync signal for tear-effect configuration
  179. */
  180. void (*vsync_sel)(struct sde_hw_intf *intf, u32 vsync_source);
  181. /**
  182. * Program the AVR_TOTAL for min fps rate
  183. */
  184. int (*avr_setup)(struct sde_hw_intf *intf,
  185. const struct intf_timing_params *params,
  186. const struct intf_avr_params *avr_params);
  187. /**
  188. * Signal the trigger on each commit for AVR
  189. */
  190. void (*avr_trigger)(struct sde_hw_intf *ctx);
  191. /**
  192. * Enable AVR and select the mode
  193. */
  194. void (*avr_ctrl)(struct sde_hw_intf *intf,
  195. const struct intf_avr_params *avr_params);
  196. /**
  197. * Enable trigger based on TE level
  198. */
  199. void (*enable_te_level_trigger)(struct sde_hw_intf *intf, bool enable);
  200. /**
  201. * Indicates the AVR armed status
  202. *
  203. * @return: false if a trigger is pending, else true while AVR is enabled
  204. */
  205. u32 (*get_avr_status)(struct sde_hw_intf *intf);
  206. /**
  207. * Enable/disable 64 bit compressed data input to interface block
  208. */
  209. void (*enable_compressed_input)(struct sde_hw_intf *intf,
  210. bool compression_en, bool dsc_4hs_merge);
  211. /**
  212. * Check the intf tear check status and reset it to start_pos
  213. */
  214. int (*check_and_reset_tearcheck)(struct sde_hw_intf *intf,
  215. struct intf_tear_status *status);
  216. /**
  217. * Reset the interface frame & line counter
  218. */
  219. void (*reset_counter)(struct sde_hw_intf *intf);
  220. /**
  221. * Get the HW vsync timestamp counter
  222. */
  223. u64 (*get_vsync_timestamp)(struct sde_hw_intf *intf, bool is_vid);
  224. /**
  225. * Enable processing of 2 pixels per clock
  226. */
  227. void (*enable_wide_bus)(struct sde_hw_intf *intf, bool enable);
  228. /**
  229. * Get the INTF interrupt status
  230. */
  231. u32 (*get_intr_status)(struct sde_hw_intf *intf);
  232. /**
  233. * Override tear check rd_ptr_val with adjusted_linecnt
  234. * when qsync is enabled.
  235. */
  236. void (*override_tear_rd_ptr_val)(struct sde_hw_intf *intf,
  237. u32 adjusted_linecnt);
  238. /**
  239. * Check if intf supports 32-bit registers for TE
  240. */
  241. bool (*is_te_32bit_supported)(struct sde_hw_intf *intf);
  242. };
  243. struct sde_hw_intf {
  244. struct sde_hw_blk_reg_map hw;
  245. /* intf */
  246. enum sde_intf idx;
  247. const struct sde_intf_cfg *cap;
  248. const struct sde_mdss_cfg *mdss;
  249. struct split_pipe_cfg cfg;
  250. /* ops */
  251. struct sde_hw_intf_ops ops;
  252. };
  253. /**
  254. * to_sde_hw_intf - convert base hw object to sde_hw_intf container
  255. * @hw: Pointer to hardware block register map object
  256. * return: Pointer to hardware block container
  257. */
  258. static inline struct sde_hw_intf *to_sde_hw_intf(struct sde_hw_blk_reg_map *hw)
  259. {
  260. return container_of(hw, struct sde_hw_intf, hw);
  261. }
  262. /**
  263. * sde_hw_intf_init(): Initializes the intf driver for the passed
  264. * interface idx.
  265. * @idx: interface index for which driver object is required
  266. * @addr: mapped register io address of MDP
  267. * @m : pointer to mdss catalog data
  268. */
  269. struct sde_hw_blk_reg_map *sde_hw_intf_init(enum sde_intf idx,
  270. void __iomem *addr,
  271. struct sde_mdss_cfg *m);
  272. /**
  273. * sde_hw_intf_destroy(): Destroys INTF driver context
  274. * @hw: Pointer to hardware block register map object
  275. */
  276. void sde_hw_intf_destroy(struct sde_hw_blk_reg_map *hw);
  277. #endif /*_SDE_HW_INTF_H */