sde_encoder.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. /*
  2. * Copyright (c) 2015-2021, 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 <drm/drm_bridge.h>
  22. #include <linux/sde_rsc.h>
  23. #include "msm_prop.h"
  24. #include "sde_hw_mdss.h"
  25. #include "sde_kms.h"
  26. #include "sde_connector.h"
  27. #include "sde_power_handle.h"
  28. /*
  29. * Two to anticipate panels that can do cmd/vid dynamic switching
  30. * plan is to create all possible physical encoder types, and switch between
  31. * them at runtime
  32. */
  33. #define NUM_PHYS_ENCODER_TYPES 2
  34. #define MAX_PHYS_ENCODERS_PER_VIRTUAL \
  35. (MAX_H_TILES_PER_DISPLAY * NUM_PHYS_ENCODER_TYPES)
  36. #define MAX_CHANNELS_PER_ENC 4
  37. #define SDE_ENCODER_FRAME_EVENT_DONE BIT(0)
  38. #define SDE_ENCODER_FRAME_EVENT_ERROR BIT(1)
  39. #define SDE_ENCODER_FRAME_EVENT_PANEL_DEAD BIT(2)
  40. #define SDE_ENCODER_FRAME_EVENT_SIGNAL_RELEASE_FENCE BIT(3)
  41. #define SDE_ENCODER_FRAME_EVENT_SIGNAL_RETIRE_FENCE BIT(4)
  42. #define SDE_ENCODER_FRAME_EVENT_CWB_DONE BIT(5)
  43. #define IDLE_POWERCOLLAPSE_DURATION (66 - 16/2)
  44. #define IDLE_POWERCOLLAPSE_IN_EARLY_WAKEUP (200 - 16/2)
  45. /**
  46. * Encoder functions and data types
  47. * @intfs: Interfaces this encoder is using, INTF_MODE_NONE if unused
  48. * @wbs: Writebacks this encoder is using, INTF_MODE_NONE if unused
  49. * @needs_cdm: Encoder requests a CDM based on pixel format conversion needs
  50. * @display_num_of_h_tiles: Number of horizontal tiles in case of split
  51. * interface
  52. * @display_type: Type of the display
  53. * @topology: Topology of the display
  54. * @comp_info: Compression parameters information
  55. */
  56. struct sde_encoder_hw_resources {
  57. enum sde_intf_mode intfs[INTF_MAX];
  58. enum sde_intf_mode wbs[WB_MAX];
  59. bool needs_cdm;
  60. u32 display_num_of_h_tiles;
  61. enum sde_connector_display display_type;
  62. struct msm_display_topology topology;
  63. struct msm_compression_info *comp_info;
  64. };
  65. /**
  66. * sde_encoder_kickoff_params - info encoder requires at kickoff
  67. * @affected_displays: bitmask, bit set means the ROI of the commit lies within
  68. * the bounds of the physical display at the bit index
  69. * @recovery_events_enabled: indicates status of client for recoovery events
  70. * @frame_trigger_mode: indicates frame trigger mode
  71. */
  72. struct sde_encoder_kickoff_params {
  73. unsigned long affected_displays;
  74. bool recovery_events_enabled;
  75. enum frame_trigger_mode_type frame_trigger_mode;
  76. };
  77. /*
  78. * enum sde_enc_rc_states - states that the resource control maintains
  79. * @SDE_ENC_RC_STATE_OFF: Resource is in OFF state
  80. * @SDE_ENC_RC_STATE_PRE_OFF: Resource is transitioning to OFF state
  81. * @SDE_ENC_RC_STATE_ON: Resource is in ON state
  82. * @SDE_ENC_RC_STATE_MODESET: Resource is in modeset state
  83. * @SDE_ENC_RC_STATE_IDLE: Resource is in IDLE state
  84. */
  85. enum sde_enc_rc_states {
  86. SDE_ENC_RC_STATE_OFF,
  87. SDE_ENC_RC_STATE_PRE_OFF,
  88. SDE_ENC_RC_STATE_ON,
  89. SDE_ENC_RC_STATE_MODESET,
  90. SDE_ENC_RC_STATE_IDLE
  91. };
  92. /**
  93. * struct sde_encoder_virt - virtual encoder. Container of one or more physical
  94. * encoders. Virtual encoder manages one "logical" display. Physical
  95. * encoders manage one intf block, tied to a specific panel/sub-panel.
  96. * Virtual encoder defers as much as possible to the physical encoders.
  97. * Virtual encoder registers itself with the DRM Framework as the encoder.
  98. * @base: drm_encoder base class for registration with DRM
  99. * @enc_spin_lock: Virtual-Encoder-Wide Spin Lock for IRQ purposes
  100. * @bus_scaling_client: Client handle to the bus scaling interface
  101. * @te_source: vsync source pin information
  102. * @num_phys_encs: Actual number of physical encoders contained.
  103. * @phys_encs: Container of physical encoders managed.
  104. * @phys_vid_encs: Video physical encoders for panel mode switch.
  105. * @phys_cmd_encs: Command physical encoders for panel mode switch.
  106. * @cur_master: Pointer to the current master in this mode. Optimization
  107. * Only valid after enable. Cleared as disable.
  108. * @hw_pp Handle to the pingpong blocks used for the display. No.
  109. * pingpong blocks can be different than num_phys_encs.
  110. * @hw_dsc: Array of DSC block handles used for the display.
  111. * @hw_vdc: Array of VDC block handles used for the display.
  112. * @dirty_dsc_ids: Cached dsc indexes for dirty DSC blocks needing flush
  113. * @intfs_swapped Whether or not the phys_enc interfaces have been swapped
  114. * for partial update right-only cases, such as pingpong
  115. * split where virtual pingpong does not generate IRQs
  116. * @qdss_status: indicate if qdss is modified since last update
  117. * @crtc_vblank_cb: Callback into the upper layer / CRTC for
  118. * notification of the VBLANK
  119. * @crtc_vblank_cb_data: Data from upper layer for VBLANK notification
  120. * @crtc_kickoff_cb: Callback into CRTC that will flush & start
  121. * all CTL paths
  122. * @crtc_kickoff_cb_data: Opaque user data given to crtc_kickoff_cb
  123. * @debugfs_root: Debug file system root file node
  124. * @enc_lock: Lock around physical encoder create/destroy and
  125. access.
  126. * @frame_done_cnt: Atomic counter for tracking which phys_enc is
  127. * done with frame processing
  128. * @crtc_frame_event_cb: callback handler for frame event
  129. * @crtc_frame_event_cb_data: callback handler private data
  130. * @rsc_client: rsc client pointer
  131. * @rsc_state_init: boolean to indicate rsc config init
  132. * @disp_info: local copy of msm_display_info struct
  133. * @misr_enable: misr enable/disable status
  134. * @misr_reconfigure: boolean entry indicates misr reconfigure status
  135. * @misr_frame_count: misr frame count before start capturing the data
  136. * @idle_pc_enabled: indicate if idle power collapse is enabled
  137. * currently. This can be controlled by user-mode
  138. * @rc_lock: resource control mutex lock to protect
  139. * virt encoder over various state changes
  140. * @rc_state: resource controller state
  141. * @delayed_off_work: delayed worker to schedule disabling of
  142. * clks and resources after IDLE_TIMEOUT time.
  143. * @early_wakeup_work: worker to handle early wakeup event
  144. * @input_event_work: worker to handle input device touch events
  145. * @esd_trigger_work: worker to handle esd trigger events
  146. * @input_handler: handler for input device events
  147. * @topology: topology of the display
  148. * @vblank_enabled: boolean to track userspace vblank vote
  149. * @idle_pc_restore: flag to indicate idle_pc_restore happened
  150. * @frame_trigger_mode: frame trigger mode indication for command mode
  151. * display
  152. * @dynamic_hdr_updated: flag to indicate if mempool was unchanged
  153. * @rsc_config: rsc configuration for display vtotal, fps, etc.
  154. * @cur_conn_roi: current connector roi
  155. * @prv_conn_roi: previous connector roi to optimize if unchanged
  156. * @crtc pointer to drm_crtc
  157. * @recovery_events_enabled: status of hw recovery feature enable by client
  158. * @elevated_ahb_vote: increase AHB bus speed for the first frame
  159. * after power collapse
  160. * @pm_qos_cpu_req: qos request for all cpu core frequency
  161. * @valid_cpu_mask: actual voted cpu core mask
  162. * @mode_info: stores the current mode and should be used
  163. * only in commit phase
  164. * @delay_kickoff boolean to delay the kickoff, used in case
  165. * of esd attack to ensure esd workqueue detects
  166. * the previous frame transfer completion before
  167. * next update is triggered.
  168. * @autorefresh_solver_disable It tracks if solver state is disabled from this
  169. * encoder due to autorefresh concurrency.
  170. */
  171. struct sde_encoder_virt {
  172. struct drm_encoder base;
  173. spinlock_t enc_spinlock;
  174. struct mutex vblank_ctl_lock;
  175. uint32_t bus_scaling_client;
  176. uint32_t display_num_of_h_tiles;
  177. uint32_t te_source;
  178. unsigned int num_phys_encs;
  179. struct sde_encoder_phys *phys_encs[MAX_PHYS_ENCODERS_PER_VIRTUAL];
  180. struct sde_encoder_phys *phys_vid_encs[MAX_PHYS_ENCODERS_PER_VIRTUAL];
  181. struct sde_encoder_phys *phys_cmd_encs[MAX_PHYS_ENCODERS_PER_VIRTUAL];
  182. struct sde_encoder_phys *cur_master;
  183. struct sde_hw_pingpong *hw_pp[MAX_CHANNELS_PER_ENC];
  184. struct sde_hw_dsc *hw_dsc[MAX_CHANNELS_PER_ENC];
  185. struct sde_hw_vdc *hw_vdc[MAX_CHANNELS_PER_ENC];
  186. struct sde_hw_pingpong *hw_dsc_pp[MAX_CHANNELS_PER_ENC];
  187. enum sde_dsc dirty_dsc_ids[MAX_CHANNELS_PER_ENC];
  188. enum sde_vdc dirty_vdc_ids[MAX_CHANNELS_PER_ENC];
  189. bool intfs_swapped;
  190. bool qdss_status;
  191. void (*crtc_vblank_cb)(void *data, ktime_t ts);
  192. void *crtc_vblank_cb_data;
  193. struct dentry *debugfs_root;
  194. struct mutex enc_lock;
  195. atomic_t frame_done_cnt[MAX_PHYS_ENCODERS_PER_VIRTUAL];
  196. void (*crtc_frame_event_cb)(void *data, u32 event, ktime_t ts);
  197. struct sde_kms_frame_event_cb_data crtc_frame_event_cb_data;
  198. struct sde_rsc_client *rsc_client;
  199. bool rsc_state_init;
  200. struct msm_display_info disp_info;
  201. bool misr_enable;
  202. bool misr_reconfigure;
  203. u32 misr_frame_count;
  204. bool idle_pc_enabled;
  205. bool input_event_enabled;
  206. struct mutex rc_lock;
  207. enum sde_enc_rc_states rc_state;
  208. struct kthread_delayed_work delayed_off_work;
  209. struct kthread_work early_wakeup_work;
  210. struct kthread_work input_event_work;
  211. struct kthread_work esd_trigger_work;
  212. struct input_handler *input_handler;
  213. struct msm_display_topology topology;
  214. bool vblank_enabled;
  215. bool idle_pc_restore;
  216. enum frame_trigger_mode_type frame_trigger_mode;
  217. bool dynamic_hdr_updated;
  218. struct sde_rsc_cmd_config rsc_config;
  219. struct sde_rect cur_conn_roi;
  220. struct sde_rect prv_conn_roi;
  221. struct drm_crtc *crtc;
  222. bool recovery_events_enabled;
  223. bool elevated_ahb_vote;
  224. struct dev_pm_qos_request pm_qos_cpu_req[NR_CPUS];
  225. struct cpumask valid_cpu_mask;
  226. struct msm_mode_info mode_info;
  227. bool delay_kickoff;
  228. bool autorefresh_solver_disable;
  229. };
  230. #define to_sde_encoder_virt(x) container_of(x, struct sde_encoder_virt, base)
  231. /**
  232. * sde_encoder_get_hw_resources - Populate table of required hardware resources
  233. * @encoder: encoder pointer
  234. * @hw_res: resource table to populate with encoder required resources
  235. * @conn_state: report hw reqs based on this proposed connector state
  236. */
  237. void sde_encoder_get_hw_resources(struct drm_encoder *encoder,
  238. struct sde_encoder_hw_resources *hw_res,
  239. struct drm_connector_state *conn_state);
  240. /**
  241. * sde_encoder_early_wakeup - early wake up display
  242. * @encoder: encoder pointer
  243. */
  244. void sde_encoder_early_wakeup(struct drm_encoder *drm_enc);
  245. /**
  246. * sde_encoder_register_vblank_callback - provide callback to encoder that
  247. * will be called on the next vblank.
  248. * @encoder: encoder pointer
  249. * @cb: callback pointer, provide NULL to deregister and disable IRQs
  250. * @data: user data provided to callback
  251. */
  252. void sde_encoder_register_vblank_callback(struct drm_encoder *encoder,
  253. void (*cb)(void *, ktime_t), void *data);
  254. /**
  255. * sde_encoder_register_frame_event_callback - provide callback to encoder that
  256. * will be called after the request is complete, or other events.
  257. * @encoder: encoder pointer
  258. * @cb: callback pointer, provide NULL to deregister
  259. * @crtc: pointer to drm_crtc object interested in frame events
  260. */
  261. void sde_encoder_register_frame_event_callback(struct drm_encoder *encoder,
  262. void (*cb)(void *, u32, ktime_t), struct drm_crtc *crtc);
  263. /**
  264. * sde_encoder_get_rsc_client - gets the rsc client state for primary
  265. * for primary display.
  266. * @encoder: encoder pointer
  267. */
  268. struct sde_rsc_client *sde_encoder_get_rsc_client(struct drm_encoder *encoder);
  269. /**
  270. * sde_encoder_poll_line_counts - poll encoder line counts for start of frame
  271. * @encoder: encoder pointer
  272. * @Returns: zero on success
  273. */
  274. int sde_encoder_poll_line_counts(struct drm_encoder *encoder);
  275. /**
  276. * sde_encoder_prepare_for_kickoff - schedule double buffer flip of the ctl
  277. * path (i.e. ctl flush and start) at next appropriate time.
  278. * Immediately: if no previous commit is outstanding.
  279. * Delayed: Block until next trigger can be issued.
  280. * @encoder: encoder pointer
  281. * @params: kickoff time parameters
  282. * @Returns: Zero on success, last detected error otherwise
  283. */
  284. int sde_encoder_prepare_for_kickoff(struct drm_encoder *encoder,
  285. struct sde_encoder_kickoff_params *params);
  286. /**
  287. * sde_encoder_trigger_kickoff_pending - Clear the flush bits from previous
  288. * kickoff and trigger the ctl prepare progress for command mode display.
  289. * @encoder: encoder pointer
  290. */
  291. void sde_encoder_trigger_kickoff_pending(struct drm_encoder *encoder);
  292. /**
  293. * sde_encoder_kickoff - trigger a double buffer flip of the ctl path
  294. * (i.e. ctl flush and start) immediately.
  295. * @encoder: encoder pointer
  296. * @is_error: whether the current commit needs to be aborted and replaced
  297. * with a 'safe' commit
  298. * @config_changed: if true new configuration is applied on the control path
  299. */
  300. void sde_encoder_kickoff(struct drm_encoder *encoder, bool is_error,
  301. bool config_changed);
  302. /**
  303. * sde_encoder_wait_for_event - Waits for encoder events
  304. * @encoder: encoder pointer
  305. * @event: event to wait for
  306. * MSM_ENC_COMMIT_DONE - Wait for hardware to have flushed the current pending
  307. * frames to hardware at a vblank or wr_ptr_start
  308. * Encoders will map this differently depending on the
  309. * panel type.
  310. * vid mode -> vsync_irq
  311. * cmd mode -> wr_ptr_start_irq
  312. * MSM_ENC_TX_COMPLETE - Wait for the hardware to transfer all the pixels to
  313. * the panel. Encoders will map this differently
  314. * depending on the panel type.
  315. * vid mode -> vsync_irq
  316. * cmd mode -> pp_done
  317. * Returns: 0 on success, -EWOULDBLOCK if already signaled, error otherwise
  318. */
  319. int sde_encoder_wait_for_event(struct drm_encoder *drm_encoder,
  320. enum msm_event_wait event);
  321. /**
  322. * sde_encoder_idle_request - request for idle request to avoid 4 vsync cycle
  323. * to turn off the clocks.
  324. * @encoder: encoder pointer
  325. * Returns: 0 on success, errorcode otherwise
  326. */
  327. int sde_encoder_idle_request(struct drm_encoder *drm_enc);
  328. /*
  329. * sde_encoder_get_fps - get interface frame rate of the given encoder
  330. * @encoder: Pointer to drm encoder object
  331. */
  332. u32 sde_encoder_get_fps(struct drm_encoder *encoder);
  333. /*
  334. * sde_encoder_get_intf_mode - get interface mode of the given encoder
  335. * @encoder: Pointer to drm encoder object
  336. */
  337. enum sde_intf_mode sde_encoder_get_intf_mode(struct drm_encoder *encoder);
  338. /*
  339. * sde_encoder_get_frame_count - get hardware frame count of the given encoder
  340. * @encoder: Pointer to drm encoder object
  341. */
  342. u32 sde_encoder_get_frame_count(struct drm_encoder *encoder);
  343. /**
  344. * sde_encoder_get_avr_status - get combined avr_status from all intfs for given virt encoder
  345. * @drm_enc: Pointer to drm encoder structure
  346. */
  347. int sde_encoder_get_avr_status(struct drm_encoder *drm_enc);
  348. /*
  349. * sde_encoder_get_vblank_timestamp - get the last vsync timestamp
  350. * @encoder: Pointer to drm encoder object
  351. * @tvblank: vblank timestamp
  352. */
  353. bool sde_encoder_get_vblank_timestamp(struct drm_encoder *encoder,
  354. ktime_t *tvblank);
  355. /**
  356. * sde_encoder_control_te - control enabling/disabling VSYNC_IN_EN
  357. * @encoder: encoder pointer
  358. * @enable: boolean to indicate enable/disable
  359. */
  360. void sde_encoder_control_te(struct drm_encoder *encoder, bool enable);
  361. /**
  362. * sde_encoder_virt_restore - restore the encoder configs
  363. * @encoder: encoder pointer
  364. */
  365. void sde_encoder_virt_restore(struct drm_encoder *encoder);
  366. /**
  367. * sde_encoder_is_dsc_merge - check if encoder is in DSC merge mode
  368. * @drm_enc: Pointer to drm encoder object
  369. * @Return: true if encoder is in DSC merge mode
  370. */
  371. bool sde_encoder_is_dsc_merge(struct drm_encoder *drm_enc);
  372. /**
  373. * sde_encoder_check_curr_mode - check if given mode is supported or not
  374. * @drm_enc: Pointer to drm encoder object
  375. * @mode: Mode to be checked
  376. * @Return: true if it is cmd mode
  377. */
  378. bool sde_encoder_check_curr_mode(struct drm_encoder *drm_enc, u32 mode);
  379. /**
  380. * sde_encoder_init - initialize virtual encoder object
  381. * @dev: Pointer to drm device structure
  382. * @disp_info: Pointer to display information structure
  383. * Returns: Pointer to newly created drm encoder
  384. */
  385. struct drm_encoder *sde_encoder_init(
  386. struct drm_device *dev,
  387. struct msm_display_info *disp_info);
  388. /**
  389. * sde_encoder_destroy - destroy previously initialized virtual encoder
  390. * @drm_enc: Pointer to previously created drm encoder structure
  391. */
  392. void sde_encoder_destroy(struct drm_encoder *drm_enc);
  393. /**
  394. * sde_encoder_prepare_commit - prepare encoder at the very beginning of an
  395. * atomic commit, before any registers are written
  396. * @drm_enc: Pointer to previously created drm encoder structure
  397. */
  398. int sde_encoder_prepare_commit(struct drm_encoder *drm_enc);
  399. /**
  400. * sde_encoder_update_caps_for_cont_splash - update encoder settings during
  401. * device bootup when cont_splash is enabled
  402. * @drm_enc: Pointer to drm encoder structure
  403. * @splash_display: Pointer to sde_splash_display corresponding to this encoder
  404. * @enable: boolean indicates enable or displae state of splash
  405. * @Return: true if successful in updating the encoder structure
  406. */
  407. int sde_encoder_update_caps_for_cont_splash(struct drm_encoder *encoder,
  408. struct sde_splash_display *splash_display, bool enable);
  409. /**
  410. * sde_encoder_display_failure_notification - update sde encoder state for
  411. * esd timeout or other display failure notification. This event flows from
  412. * dsi, sde_connector to sde_encoder.
  413. *
  414. * This api must not be called from crtc_commit (display) thread because it
  415. * requests the flush work on same thread. It is called from esd check thread
  416. * based on current design.
  417. *
  418. * TODO: manage the event at sde_kms level for forward processing.
  419. * @drm_enc: Pointer to drm encoder structure
  420. * @skip_pre_kickoff: Caller can avoid pre_kickoff if it is triggering this
  421. * event only to switch the panel TE to watchdog mode.
  422. * @Return: true if successful in updating the encoder structure
  423. */
  424. int sde_encoder_display_failure_notification(struct drm_encoder *enc,
  425. bool skip_pre_kickoff);
  426. /**
  427. * sde_encoder_recovery_events_enabled - checks if client has enabled
  428. * sw recovery mechanism for this connector
  429. * @drm_enc: Pointer to drm encoder structure
  430. * @Return: true if enabled
  431. */
  432. bool sde_encoder_recovery_events_enabled(struct drm_encoder *encoder);
  433. /**
  434. * sde_encoder_enable_recovery_event - handler to enable the sw recovery
  435. * for this connector
  436. * @drm_enc: Pointer to drm encoder structure
  437. */
  438. void sde_encoder_enable_recovery_event(struct drm_encoder *encoder);
  439. /**
  440. * sde_encoder_in_clone_mode - checks if underlying phys encoder is in clone
  441. * mode or independent display mode. ref@ WB in Concurrent writeback mode.
  442. * @drm_enc: Pointer to drm encoder structure
  443. * @Return: true if successful in updating the encoder structure
  444. */
  445. bool sde_encoder_in_clone_mode(struct drm_encoder *enc);
  446. /*
  447. * sde_encoder_is_cwb_disabling - check if cwb encoder disable is pending
  448. * @drm_enc: Pointer to drm encoder structure
  449. * @drm_crtc: Pointer to drm crtc structure
  450. * @Return: true if cwb encoder disable is pending
  451. */
  452. bool sde_encoder_is_cwb_disabling(struct drm_encoder *drm_enc,
  453. struct drm_crtc *drm_crtc);
  454. /**
  455. * sde_encoder_is_primary_display - checks if underlying display is primary
  456. * display or not.
  457. * @drm_enc: Pointer to drm encoder structure
  458. * @Return: true if it is primary display. false if secondary display
  459. */
  460. bool sde_encoder_is_primary_display(struct drm_encoder *enc);
  461. /**
  462. * sde_encoder_is_dsi_display - checks if underlying display is DSI
  463. * display or not.
  464. * @drm_enc: Pointer to drm encoder structure
  465. * @Return: true if it is primary display. false if secondary display
  466. */
  467. bool sde_encoder_is_dsi_display(struct drm_encoder *enc);
  468. /**
  469. * sde_encoder_control_idle_pc - control enable/disable of idle power collapse
  470. * @drm_enc: Pointer to drm encoder structure
  471. * @enable: enable/disable flag
  472. */
  473. void sde_encoder_control_idle_pc(struct drm_encoder *enc, bool enable);
  474. /**
  475. * sde_encoder_in_cont_splash - checks if display is in continuous splash
  476. * @drm_enc: Pointer to drm encoder structure
  477. * @Return: true if display in continuous splash
  478. */
  479. int sde_encoder_in_cont_splash(struct drm_encoder *enc);
  480. /**
  481. * sde_encoder_helper_hw_reset - hw reset helper function
  482. * @drm_enc: Pointer to drm encoder structure
  483. */
  484. void sde_encoder_needs_hw_reset(struct drm_encoder *enc);
  485. /**
  486. * sde_encoder_uidle_enable - control enable/disable of uidle
  487. * @drm_enc: Pointer to drm encoder structure
  488. * @enable: enable/disable flag
  489. */
  490. void sde_encoder_uidle_enable(struct drm_encoder *drm_enc, bool enable);
  491. /**
  492. * sde_encoder_irq_control - control enable/disable of IRQ's
  493. * @drm_enc: Pointer to drm encoder structure
  494. * @enable: enable/disable flag
  495. */
  496. void sde_encoder_irq_control(struct drm_encoder *drm_enc, bool enable);
  497. /**sde_encoder_get_connector - get connector corresponding to encoder
  498. * @dev: Pointer to drm device structure
  499. * @drm_enc: Pointer to drm encoder structure
  500. * Returns: drm connector if found, null if not found
  501. */
  502. struct drm_connector *sde_encoder_get_connector(struct drm_device *dev,
  503. struct drm_encoder *drm_enc);
  504. /**sde_encoder_needs_dsc_disable - indicates if dsc should be disabled
  505. * based on previous topology
  506. * @drm_enc: Pointer to drm encoder structure
  507. */
  508. bool sde_encoder_needs_dsc_disable(struct drm_encoder *drm_enc);
  509. /**
  510. * sde_encoder_get_transfer_time - get the mdp transfer time in usecs
  511. * @drm_enc: Pointer to drm encoder structure
  512. * @transfer_time_us: Pointer to store the output value
  513. */
  514. void sde_encoder_get_transfer_time(struct drm_encoder *drm_enc,
  515. u32 *transfer_time_us);
  516. /*
  517. * sde_encoder_get_dfps_maxfps - get dynamic FPS max frame rate of
  518. the given encoder
  519. * @encoder: Pointer to drm encoder object
  520. */
  521. static inline u32 sde_encoder_get_dfps_maxfps(struct drm_encoder *drm_enc)
  522. {
  523. struct sde_encoder_virt *sde_enc;
  524. if (!drm_enc) {
  525. SDE_ERROR("invalid encoder\n");
  526. return 0;
  527. }
  528. sde_enc = to_sde_encoder_virt(drm_enc);
  529. return sde_enc->mode_info.dfps_maxfps;
  530. }
  531. /**
  532. * sde_encoder_virt_reset - delay encoder virt reset
  533. * @drm_enc: Pointer to drm encoder structure
  534. */
  535. void sde_encoder_virt_reset(struct drm_encoder *drm_enc);
  536. /**
  537. * sde_encoder_calc_last_vsync_timestamp - read last HW vsync timestamp counter
  538. * and calculate the corresponding vsync ktime. Return ktime_get
  539. * when HW support is not available
  540. * @drm_enc: Pointer to drm encoder structure
  541. */
  542. ktime_t sde_encoder_calc_last_vsync_timestamp(struct drm_encoder *drm_enc);
  543. /**
  544. * sde_encoder_get_kms - retrieve the kms from encoder
  545. * @drm_enc: Pointer to drm encoder structure
  546. */
  547. static inline struct sde_kms *sde_encoder_get_kms(struct drm_encoder *drm_enc)
  548. {
  549. struct msm_drm_private *priv;
  550. if (!drm_enc || !drm_enc->dev) {
  551. SDE_ERROR("invalid encoder\n");
  552. return NULL;
  553. }
  554. priv = drm_enc->dev->dev_private;
  555. if (!priv || !priv->kms) {
  556. SDE_ERROR("invalid kms\n");
  557. return NULL;
  558. }
  559. return to_sde_kms(priv->kms);
  560. }
  561. /*
  562. * sde_encoder_is_widebus_enabled - check if widebus is enabled for current mode
  563. * @drm_enc: Pointer to drm encoder structure
  564. * @Return: true if widebus is enabled for current mode
  565. */
  566. static inline bool sde_encoder_is_widebus_enabled(struct drm_encoder *drm_enc)
  567. {
  568. struct sde_encoder_virt *sde_enc;
  569. if (!drm_enc)
  570. return false;
  571. sde_enc = to_sde_encoder_virt(drm_enc);
  572. return sde_enc->mode_info.wide_bus_en;
  573. }
  574. #endif /* __SDE_ENCODER_H__ */