sde_encoder.h 25 KB

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