sde_encoder.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. /*
  2. * Copyright (c) 2015-2019, The Linux Foundation. All rights reserved.
  3. * Copyright (C) 2013 Red Hat
  4. * Author: Rob Clark <[email protected]>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License version 2 as published by
  8. * the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along with
  16. * this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef __SDE_ENCODER_H__
  19. #define __SDE_ENCODER_H__
  20. #include <drm/drm_crtc.h>
  21. #include "msm_prop.h"
  22. #include "sde_hw_mdss.h"
  23. #include "sde_kms.h"
  24. #define SDE_ENCODER_FRAME_EVENT_DONE BIT(0)
  25. #define SDE_ENCODER_FRAME_EVENT_ERROR BIT(1)
  26. #define SDE_ENCODER_FRAME_EVENT_PANEL_DEAD BIT(2)
  27. #define SDE_ENCODER_FRAME_EVENT_SIGNAL_RELEASE_FENCE BIT(3)
  28. #define SDE_ENCODER_FRAME_EVENT_SIGNAL_RETIRE_FENCE BIT(4)
  29. #define IDLE_POWERCOLLAPSE_DURATION (66 - 16/2)
  30. #define IDLE_POWERCOLLAPSE_IN_EARLY_WAKEUP (200 - 16/2)
  31. /**
  32. * Encoder functions and data types
  33. * @intfs: Interfaces this encoder is using, INTF_MODE_NONE if unused
  34. * @wbs: Writebacks this encoder is using, INTF_MODE_NONE if unused
  35. * @needs_cdm: Encoder requests a CDM based on pixel format conversion needs
  36. * @display_num_of_h_tiles: Number of horizontal tiles in case of split
  37. * interface
  38. * @is_primary: set to true if the display is primary display
  39. * @topology: Topology of the display
  40. */
  41. struct sde_encoder_hw_resources {
  42. enum sde_intf_mode intfs[INTF_MAX];
  43. enum sde_intf_mode wbs[WB_MAX];
  44. bool needs_cdm;
  45. u32 display_num_of_h_tiles;
  46. bool is_primary;
  47. struct msm_display_topology topology;
  48. };
  49. /**
  50. * sde_encoder_kickoff_params - info encoder requires at kickoff
  51. * @is_primary: set to true if the display is primary display
  52. * @affected_displays: bitmask, bit set means the ROI of the commit lies within
  53. * the bounds of the physical display at the bit index
  54. * @recovery_events_enabled: indicates status of client for recoovery events
  55. * @frame_trigger_mode: indicates frame trigger mode
  56. */
  57. struct sde_encoder_kickoff_params {
  58. u32 is_primary;
  59. unsigned long affected_displays;
  60. bool recovery_events_enabled;
  61. enum frame_trigger_mode_type frame_trigger_mode;
  62. };
  63. /**
  64. * sde_encoder_get_hw_resources - Populate table of required hardware resources
  65. * @encoder: encoder pointer
  66. * @hw_res: resource table to populate with encoder required resources
  67. * @conn_state: report hw reqs based on this proposed connector state
  68. */
  69. void sde_encoder_get_hw_resources(struct drm_encoder *encoder,
  70. struct sde_encoder_hw_resources *hw_res,
  71. struct drm_connector_state *conn_state);
  72. /**
  73. * sde_encoder_register_vblank_callback - provide callback to encoder that
  74. * will be called on the next vblank.
  75. * @encoder: encoder pointer
  76. * @cb: callback pointer, provide NULL to deregister and disable IRQs
  77. * @data: user data provided to callback
  78. */
  79. void sde_encoder_register_vblank_callback(struct drm_encoder *encoder,
  80. void (*cb)(void *), void *data);
  81. /**
  82. * sde_encoder_register_frame_event_callback - provide callback to encoder that
  83. * will be called after the request is complete, or other events.
  84. * @encoder: encoder pointer
  85. * @cb: callback pointer, provide NULL to deregister
  86. * @crtc: pointer to drm_crtc object interested in frame events
  87. */
  88. void sde_encoder_register_frame_event_callback(struct drm_encoder *encoder,
  89. void (*cb)(void *, u32), struct drm_crtc *crtc);
  90. /**
  91. * sde_encoder_get_rsc_client - gets the rsc client state for primary
  92. * for primary display.
  93. * @encoder: encoder pointer
  94. */
  95. struct sde_rsc_client *sde_encoder_get_rsc_client(struct drm_encoder *encoder);
  96. /**
  97. * sde_encoder_poll_line_counts - poll encoder line counts for start of frame
  98. * @encoder: encoder pointer
  99. * @Returns: zero on success
  100. */
  101. int sde_encoder_poll_line_counts(struct drm_encoder *encoder);
  102. /**
  103. * sde_encoder_prepare_for_kickoff - schedule double buffer flip of the ctl
  104. * path (i.e. ctl flush and start) at next appropriate time.
  105. * Immediately: if no previous commit is outstanding.
  106. * Delayed: Block until next trigger can be issued.
  107. * @encoder: encoder pointer
  108. * @params: kickoff time parameters
  109. * @Returns: Zero on success, last detected error otherwise
  110. */
  111. int sde_encoder_prepare_for_kickoff(struct drm_encoder *encoder,
  112. struct sde_encoder_kickoff_params *params);
  113. /**
  114. * sde_encoder_trigger_kickoff_pending - Clear the flush bits from previous
  115. * kickoff and trigger the ctl prepare progress for command mode display.
  116. * @encoder: encoder pointer
  117. */
  118. void sde_encoder_trigger_kickoff_pending(struct drm_encoder *encoder);
  119. /**
  120. * sde_encoder_kickoff - trigger a double buffer flip of the ctl path
  121. * (i.e. ctl flush and start) immediately.
  122. * @encoder: encoder pointer
  123. * @is_error: whether the current commit needs to be aborted and replaced
  124. * with a 'safe' commit
  125. */
  126. void sde_encoder_kickoff(struct drm_encoder *encoder, bool is_error);
  127. /**
  128. * sde_encoder_wait_for_event - Waits for encoder events
  129. * @encoder: encoder pointer
  130. * @event: event to wait for
  131. * MSM_ENC_COMMIT_DONE - Wait for hardware to have flushed the current pending
  132. * frames to hardware at a vblank or ctl_start
  133. * Encoders will map this differently depending on the
  134. * panel type.
  135. * vid mode -> vsync_irq
  136. * cmd mode -> ctl_start
  137. * MSM_ENC_TX_COMPLETE - Wait for the hardware to transfer all the pixels to
  138. * the panel. Encoders will map this differently
  139. * depending on the panel type.
  140. * vid mode -> vsync_irq
  141. * cmd mode -> pp_done
  142. * Returns: 0 on success, -EWOULDBLOCK if already signaled, error otherwise
  143. */
  144. int sde_encoder_wait_for_event(struct drm_encoder *drm_encoder,
  145. enum msm_event_wait event);
  146. /**
  147. * sde_encoder_idle_request - request for idle request to avoid 4 vsync cycle
  148. * to turn off the clocks.
  149. * @encoder: encoder pointer
  150. * Returns: 0 on success, errorcode otherwise
  151. */
  152. int sde_encoder_idle_request(struct drm_encoder *drm_enc);
  153. /*
  154. * sde_encoder_get_fps - get interface frame rate of the given encoder
  155. * @encoder: Pointer to drm encoder object
  156. */
  157. u32 sde_encoder_get_fps(struct drm_encoder *encoder);
  158. /*
  159. * sde_encoder_get_intf_mode - get interface mode of the given encoder
  160. * @encoder: Pointer to drm encoder object
  161. */
  162. enum sde_intf_mode sde_encoder_get_intf_mode(struct drm_encoder *encoder);
  163. /**
  164. * sde_encoder_control_te - control enabling/disabling VSYNC_IN_EN
  165. * @encoder: encoder pointer
  166. * @enable: boolean to indicate enable/disable
  167. */
  168. void sde_encoder_control_te(struct drm_encoder *encoder, bool enable);
  169. /**
  170. * sde_encoder_virt_restore - restore the encoder configs
  171. * @encoder: encoder pointer
  172. */
  173. void sde_encoder_virt_restore(struct drm_encoder *encoder);
  174. /**
  175. * sde_encoder_is_dsc_merge - check if encoder is in DSC merge mode
  176. * @drm_enc: Pointer to drm encoder object
  177. * @Return: true if encoder is in DSC merge mode
  178. */
  179. bool sde_encoder_is_dsc_merge(struct drm_encoder *drm_enc);
  180. /**
  181. * sde_encoder_check_curr_mode - check if given mode is supported or not
  182. * @drm_enc: Pointer to drm encoder object
  183. * @mode: Mode to be checked
  184. * @Return: true if it is cmd mode
  185. */
  186. bool sde_encoder_check_curr_mode(struct drm_encoder *drm_enc, u32 mode);
  187. /**
  188. * sde_encoder_init - initialize virtual encoder object
  189. * @dev: Pointer to drm device structure
  190. * @disp_info: Pointer to display information structure
  191. * Returns: Pointer to newly created drm encoder
  192. */
  193. struct drm_encoder *sde_encoder_init(
  194. struct drm_device *dev,
  195. struct msm_display_info *disp_info);
  196. /**
  197. * sde_encoder_destroy - destroy previously initialized virtual encoder
  198. * @drm_enc: Pointer to previously created drm encoder structure
  199. */
  200. void sde_encoder_destroy(struct drm_encoder *drm_enc);
  201. /**
  202. * sde_encoder_prepare_commit - prepare encoder at the very beginning of an
  203. * atomic commit, before any registers are written
  204. * @drm_enc: Pointer to previously created drm encoder structure
  205. */
  206. void sde_encoder_prepare_commit(struct drm_encoder *drm_enc);
  207. /**
  208. * sde_encoder_update_caps_for_cont_splash - update encoder settings during
  209. * device bootup when cont_splash is enabled
  210. * @drm_enc: Pointer to drm encoder structure
  211. * @splash_display: Pointer to sde_splash_display corresponding to this encoder
  212. * @enable: boolean indicates enable or displae state of splash
  213. * @Return: true if successful in updating the encoder structure
  214. */
  215. int sde_encoder_update_caps_for_cont_splash(struct drm_encoder *encoder,
  216. struct sde_splash_display *splash_display, bool enable);
  217. /**
  218. * sde_encoder_display_failure_notification - update sde encoder state for
  219. * esd timeout or other display failure notification. This event flows from
  220. * dsi, sde_connector to sde_encoder.
  221. *
  222. * This api must not be called from crtc_commit (display) thread because it
  223. * requests the flush work on same thread. It is called from esd check thread
  224. * based on current design.
  225. *
  226. * TODO: manage the event at sde_kms level for forward processing.
  227. * @drm_enc: Pointer to drm encoder structure
  228. * @skip_pre_kickoff: Caller can avoid pre_kickoff if it is triggering this
  229. * event only to switch the panel TE to watchdog mode.
  230. * @Return: true if successful in updating the encoder structure
  231. */
  232. int sde_encoder_display_failure_notification(struct drm_encoder *enc,
  233. bool skip_pre_kickoff);
  234. /**
  235. * sde_encoder_recovery_events_enabled - checks if client has enabled
  236. * sw recovery mechanism for this connector
  237. * @drm_enc: Pointer to drm encoder structure
  238. * @Return: true if enabled
  239. */
  240. bool sde_encoder_recovery_events_enabled(struct drm_encoder *encoder);
  241. /**
  242. * sde_encoder_recovery_events_handler - handler to enable/disable the
  243. * sw recovery for this connector
  244. * @drm_enc: Pointer to drm encoder structure
  245. */
  246. void sde_encoder_recovery_events_handler(struct drm_encoder *encoder,
  247. bool val);
  248. /**
  249. * sde_encoder_in_clone_mode - checks if underlying phys encoder is in clone
  250. * mode or independent display mode. ref@ WB in Concurrent writeback mode.
  251. * @drm_enc: Pointer to drm encoder structure
  252. * @Return: true if successful in updating the encoder structure
  253. */
  254. bool sde_encoder_in_clone_mode(struct drm_encoder *enc);
  255. /**
  256. * sde_encoder_is_primary_display - checks if underlying display is primary
  257. * display or not.
  258. * @drm_enc: Pointer to drm encoder structure
  259. * @Return: true if it is primary display. false if secondary display
  260. */
  261. bool sde_encoder_is_primary_display(struct drm_encoder *enc);
  262. /**
  263. * sde_encoder_control_idle_pc - control enable/disable of idle power collapse
  264. * @drm_enc: Pointer to drm encoder structure
  265. * @enable: enable/disable flag
  266. */
  267. void sde_encoder_control_idle_pc(struct drm_encoder *enc, bool enable);
  268. /**
  269. * sde_encoder_in_cont_splash - checks if display is in continuous splash
  270. * @drm_enc: Pointer to drm encoder structure
  271. * @Return: true if display in continuous splash
  272. */
  273. int sde_encoder_in_cont_splash(struct drm_encoder *enc);
  274. /**
  275. * sde_encoder_uidle_enable - control enable/disable of uidle
  276. * @drm_enc: Pointer to drm encoder structure
  277. * @enable: enable/disable flag
  278. */
  279. void sde_encoder_uidle_enable(struct drm_encoder *drm_enc, bool enable);
  280. #endif /* __SDE_ENCODER_H__ */