sde_crtc.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775
  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_CRTC_H_
  19. #define _SDE_CRTC_H_
  20. #include <linux/kthread.h>
  21. #include <linux/of_fdt.h>
  22. #include <drm/drm_crtc.h>
  23. #include "msm_prop.h"
  24. #include "sde_fence.h"
  25. #include "sde_kms.h"
  26. #include "sde_core_perf.h"
  27. #include "sde_hw_ds.h"
  28. #define SDE_CRTC_NAME_SIZE 12
  29. /* define the maximum number of in-flight frame events */
  30. /* Expand it to 2x for handling atleast 2 connectors safely */
  31. #define SDE_CRTC_FRAME_EVENT_SIZE (4 * 2)
  32. /**
  33. * enum sde_crtc_client_type: crtc client type
  34. * @RT_CLIENT: RealTime client like video/cmd mode display
  35. * voting through apps rsc
  36. * @NRT_CLIENT: Non-RealTime client like WB display
  37. * voting through apps rsc
  38. * @RT_RSC_CLIENT: Realtime display RSC voting client
  39. */
  40. enum sde_crtc_client_type {
  41. RT_CLIENT,
  42. NRT_CLIENT,
  43. RT_RSC_CLIENT,
  44. };
  45. /**
  46. * enum sde_crtc_output_capture_point
  47. * @MIXER_OUT : capture mixer output
  48. * @DSPP_OUT : capture output of dspp
  49. */
  50. enum sde_crtc_output_capture_point {
  51. CAPTURE_MIXER_OUT,
  52. CAPTURE_DSPP_OUT
  53. };
  54. /**
  55. * enum sde_crtc_idle_pc_state: states of idle power collapse
  56. * @IDLE_PC_NONE: no-op
  57. * @IDLE_PC_ENABLE: enable idle power-collapse
  58. * @IDLE_PC_DISABLE: disable idle power-collapse
  59. */
  60. enum sde_crtc_idle_pc_state {
  61. IDLE_PC_NONE,
  62. IDLE_PC_ENABLE,
  63. IDLE_PC_DISABLE,
  64. };
  65. /**
  66. * @connectors : Currently associated drm connectors for retire event
  67. * @num_connectors: Number of associated drm connectors for retire event
  68. * @list: event list
  69. */
  70. struct sde_crtc_retire_event {
  71. struct drm_connector *connectors[MAX_CONNECTORS];
  72. int num_connectors;
  73. struct list_head list;
  74. };
  75. /**
  76. * struct sde_crtc_mixer: stores the map for each virtual pipeline in the CRTC
  77. * @hw_lm: LM HW Driver context
  78. * @hw_ctl: CTL Path HW driver context
  79. * @hw_dspp: DSPP HW driver context
  80. * @hw_ds: DS HW driver context
  81. * @encoder: Encoder attached to this lm & ctl
  82. * @mixer_op_mode: mixer blending operation mode
  83. */
  84. struct sde_crtc_mixer {
  85. struct sde_hw_mixer *hw_lm;
  86. struct sde_hw_ctl *hw_ctl;
  87. struct sde_hw_dspp *hw_dspp;
  88. struct sde_hw_ds *hw_ds;
  89. struct drm_encoder *encoder;
  90. u32 mixer_op_mode;
  91. };
  92. /**
  93. * struct sde_crtc_frame_event_cb_data : info of drm objects of a frame event
  94. * @crtc: pointer to drm crtc object registered for frame event
  95. * @connector: pointer to drm connector which is source of frame event
  96. */
  97. struct sde_crtc_frame_event_cb_data {
  98. struct drm_crtc *crtc;
  99. struct drm_connector *connector;
  100. };
  101. /**
  102. * struct sde_crtc_frame_event: stores crtc frame event for crtc processing
  103. * @work: base work structure
  104. * @crtc: Pointer to crtc handling this event
  105. * @connector: pointer to drm connector which is source of frame event
  106. * @list: event list
  107. * @ts: timestamp at queue entry
  108. * @event: event identifier
  109. */
  110. struct sde_crtc_frame_event {
  111. struct kthread_work work;
  112. struct drm_crtc *crtc;
  113. struct drm_connector *connector;
  114. struct list_head list;
  115. ktime_t ts;
  116. u32 event;
  117. };
  118. /**
  119. * struct sde_crtc_event - event callback tracking structure
  120. * @list: Linked list tracking node
  121. * @kt_work: Kthread worker structure
  122. * @sde_crtc: Pointer to associated sde_crtc structure
  123. * @cb_func: Pointer to callback function
  124. * @usr: Pointer to user data to be provided to the callback
  125. */
  126. struct sde_crtc_event {
  127. struct list_head list;
  128. struct kthread_work kt_work;
  129. void *sde_crtc;
  130. void (*cb_func)(struct drm_crtc *crtc, void *usr);
  131. void *usr;
  132. };
  133. /**
  134. * struct sde_crtc_fps_info - structure for measuring fps periodicity
  135. * @frame_count : Total frames during configured periodic duration
  136. * @last_sampled_time_us: Stores the last ktime in microsecs when fps
  137. * was calculated
  138. * @measured_fps : Last measured fps value
  139. * @fps_periodic_duration : Duration in milliseconds to measure the fps.
  140. * Default value is 1 second.
  141. * @time_buf : Buffer for storing ktime of the commits
  142. * @next_time_index : index into time_buf for storing ktime for next commit
  143. */
  144. struct sde_crtc_fps_info {
  145. u32 frame_count;
  146. ktime_t last_sampled_time_us;
  147. u32 measured_fps;
  148. u32 fps_periodic_duration;
  149. ktime_t *time_buf;
  150. u32 next_time_index;
  151. };
  152. /**
  153. * struct sde_ltm_buffer - defines LTM buffer structure.
  154. * @fb: frm framebuffer for the buffer
  155. * @gem: drm gem handle for the buffer
  156. * @asapce : pointer to address space
  157. * @drm_fb_id: framebuffer id associated with this buffer
  158. * @offset: offset for alignment
  159. * @iova: device address
  160. * @kva: kernel virtual address
  161. * @node: list node for LTM buffer list;
  162. */
  163. struct sde_ltm_buffer {
  164. struct drm_framebuffer *fb;
  165. struct drm_gem_object *gem;
  166. struct msm_gem_address_space *aspace;
  167. u32 drm_fb_id;
  168. u32 offset;
  169. u64 iova;
  170. void *kva;
  171. struct list_head node;
  172. };
  173. /**
  174. * struct sde_crtc_misr_info - structure for misr information
  175. * @misr_enable : enable/disable flag
  176. * @misr_frame_count : Number of frames for misr calculation.
  177. */
  178. struct sde_crtc_misr_info {
  179. bool misr_enable;
  180. u32 misr_frame_count;
  181. };
  182. /*
  183. * Maximum number of free event structures to cache
  184. */
  185. #define SDE_CRTC_MAX_EVENT_COUNT 16
  186. /**
  187. * struct sde_crtc - virtualized CRTC data structure
  188. * @base : Base drm crtc structure
  189. * @name : ASCII description of this crtc
  190. * @num_ctls : Number of ctl paths in use
  191. * @num_mixers : Number of mixers in use
  192. * @mixers_swapped: Whether the mixers have been swapped for left/right update
  193. * especially in the case of DSC Merge.
  194. * @mixers : List of active mixers
  195. * @event : Pointer to last received drm vblank event. If there is a
  196. * pending vblank event, this will be non-null.
  197. * @vsync_count : Running count of received vsync events
  198. * @drm_requested_vblank : Whether vblanks have been enabled in the encoder
  199. * @property_info : Opaque structure for generic property support
  200. * @property_defaults : Array of default values for generic property support
  201. * @output_fence : output release fence context
  202. * @stage_cfg : H/w mixer stage configuration
  203. * @debugfs_root : Parent of debugfs node
  204. * @vblank_cb_count : count of vblank callback since last reset
  205. * @play_count : frame count between crtc enable and disable
  206. * @vblank_cb_time : ktime at vblank count reset
  207. * @vblank_last_cb_time : ktime at last vblank notification
  208. * @sysfs_dev : sysfs device node for crtc
  209. * @vsync_event_sf : vsync event notifier sysfs device
  210. * @vblank_requested : whether the user has requested vblank events
  211. * @suspend : whether or not a suspend operation is in progress
  212. * @enabled : whether the SDE CRTC is currently enabled. updated in the
  213. * commit-thread, not state-swap time which is earlier, so
  214. * safe to make decisions on during VBLANK on/off work
  215. * @ds_reconfig : force reconfiguration of the destination scaler block
  216. * @feature_list : list of color processing features supported on a crtc
  217. * @active_list : list of color processing features are active
  218. * @dirty_list : list of color processing features are dirty
  219. * @ad_dirty : list containing ad properties that are dirty
  220. * @ad_active : list containing ad properties that are active
  221. * @crtc_lock : crtc lock around create, destroy and access.
  222. * @frame_pending : Whether or not an update is pending
  223. * @frame_events : static allocation of in-flight frame events
  224. * @frame_event_list : available frame event list
  225. * @spin_lock : spin lock for frame event, transaction status, etc...
  226. * @event_thread : Pointer to event handler thread
  227. * @event_worker : Event worker queue
  228. * @event_cache : Local cache of event worker structures
  229. * @event_free_list : List of available event structures
  230. * @event_lock : Spinlock around event handling code
  231. * @misr_enable_sui : boolean entry indicates misr enable/disable status
  232. * for secure cases.
  233. * @misr_enable_debugfs : boolean entry indicates misr enable/disable status
  234. * from debugfs.
  235. * @misr_frame_count : misr frame count provided by client
  236. * @misr_data : store misr data before turning off the clocks.
  237. * @idle_notify_work: delayed worker to notify idle timeout to user space
  238. * @power_event : registered power event handle
  239. * @cur_perf : current performance committed to clock/bandwidth driver
  240. * @plane_mask_old: keeps track of the planes used in the previous commit
  241. * @frame_trigger_mode: frame trigger mode
  242. * @ltm_buffer_cnt : number of ltm buffers
  243. * @ltm_buffers : struct stores ltm buffer related data
  244. * @ltm_buf_free : list of LTM buffers that are available
  245. * @ltm_buf_busy : list of LTM buffers that are been used by HW
  246. * @ltm_hist_en : flag to indicate whether LTM hist is enabled or not
  247. * @ltm_buffer_lock : muttx to protect ltm_buffers allcation and free
  248. * @ltm_lock : Spinlock to protect ltm buffer_cnt, hist_en and ltm lists
  249. */
  250. struct sde_crtc {
  251. struct drm_crtc base;
  252. char name[SDE_CRTC_NAME_SIZE];
  253. /* HW Resources reserved for the crtc */
  254. u32 num_ctls;
  255. u32 num_mixers;
  256. bool mixers_swapped;
  257. struct sde_crtc_mixer mixers[CRTC_DUAL_MIXERS];
  258. struct drm_pending_vblank_event *event;
  259. u32 vsync_count;
  260. struct msm_property_info property_info;
  261. struct msm_property_data property_data[CRTC_PROP_COUNT];
  262. struct drm_property_blob *blob_info;
  263. /* output fence support */
  264. struct sde_fence_context *output_fence;
  265. struct sde_hw_stage_cfg stage_cfg;
  266. struct dentry *debugfs_root;
  267. u32 vblank_cb_count;
  268. u64 play_count;
  269. ktime_t vblank_cb_time;
  270. ktime_t vblank_last_cb_time;
  271. struct sde_crtc_fps_info fps_info;
  272. struct device *sysfs_dev;
  273. struct kernfs_node *vsync_event_sf;
  274. bool vblank_requested;
  275. bool suspend;
  276. bool enabled;
  277. bool ds_reconfig;
  278. struct list_head feature_list;
  279. struct list_head active_list;
  280. struct list_head dirty_list;
  281. struct list_head ad_dirty;
  282. struct list_head ad_active;
  283. struct list_head user_event_list;
  284. struct mutex crtc_lock;
  285. struct mutex crtc_cp_lock;
  286. atomic_t frame_pending;
  287. struct sde_crtc_frame_event frame_events[SDE_CRTC_FRAME_EVENT_SIZE];
  288. struct list_head frame_event_list;
  289. spinlock_t spin_lock;
  290. /* for handling internal event thread */
  291. struct sde_crtc_event event_cache[SDE_CRTC_MAX_EVENT_COUNT];
  292. struct list_head event_free_list;
  293. spinlock_t event_lock;
  294. bool misr_enable_sui;
  295. bool misr_enable_debugfs;
  296. u32 misr_frame_count;
  297. struct kthread_delayed_work idle_notify_work;
  298. struct sde_power_event *power_event;
  299. struct sde_core_perf_params cur_perf;
  300. struct sde_core_perf_params new_perf;
  301. u32 plane_mask_old;
  302. /* blob for histogram data */
  303. struct drm_property_blob *hist_blob;
  304. enum frame_trigger_mode_type frame_trigger_mode;
  305. u32 ltm_buffer_cnt;
  306. struct sde_ltm_buffer *ltm_buffers[LTM_BUFFER_SIZE];
  307. struct list_head ltm_buf_free;
  308. struct list_head ltm_buf_busy;
  309. bool ltm_hist_en;
  310. struct drm_msm_ltm_cfg_param ltm_cfg;
  311. struct mutex ltm_buffer_lock;
  312. spinlock_t ltm_lock;
  313. };
  314. #define to_sde_crtc(x) container_of(x, struct sde_crtc, base)
  315. /**
  316. * struct sde_crtc_state - sde container for atomic crtc state
  317. * @base: Base drm crtc state structure
  318. * @connectors : Currently associated drm connectors
  319. * @num_connectors: Number of associated drm connectors
  320. * @rsc_client : sde rsc client when mode is valid
  321. * @is_ppsplit : Whether current topology requires PPSplit special handling
  322. * @bw_control : true if bw/clk controlled by core bw/clk properties
  323. * @bw_split_vote : true if bw controlled by llcc/dram bw properties
  324. * @crtc_roi : Current CRTC ROI. Possibly sub-rectangle of mode.
  325. * Origin top left of CRTC.
  326. * @lm_bounds : LM boundaries based on current mode full resolution, no ROI.
  327. * Origin top left of CRTC.
  328. * @lm_roi : Current LM ROI, possibly sub-rectangle of mode.
  329. * Origin top left of CRTC.
  330. * @user_roi_list : List of user's requested ROIs as from set property
  331. * @property_state: Local storage for msm_prop properties
  332. * @property_values: Current crtc property values
  333. * @input_fence_timeout_ns : Cached input fence timeout, in ns
  334. * @num_dim_layers: Number of dim layers
  335. * @dim_layer: Dim layer configs
  336. * @num_ds: Number of destination scalers to be configured
  337. * @num_ds_enabled: Number of destination scalers enabled
  338. * @ds_dirty: Boolean to indicate if dirty or not
  339. * @ds_cfg: Destination scaler config
  340. * @scl3_lut_cfg: QSEED3 lut config
  341. * @new_perf: new performance state being requested
  342. */
  343. struct sde_crtc_state {
  344. struct drm_crtc_state base;
  345. struct drm_connector *connectors[MAX_CONNECTORS];
  346. int num_connectors;
  347. struct sde_rsc_client *rsc_client;
  348. bool rsc_update;
  349. bool bw_control;
  350. bool bw_split_vote;
  351. bool is_ppsplit;
  352. struct sde_rect crtc_roi;
  353. struct sde_rect lm_bounds[CRTC_DUAL_MIXERS];
  354. struct sde_rect lm_roi[CRTC_DUAL_MIXERS];
  355. struct msm_roi_list user_roi_list;
  356. struct msm_property_state property_state;
  357. struct msm_property_value property_values[CRTC_PROP_COUNT];
  358. uint64_t input_fence_timeout_ns;
  359. uint32_t num_dim_layers;
  360. struct sde_hw_dim_layer dim_layer[SDE_MAX_DIM_LAYERS];
  361. uint32_t num_ds;
  362. uint32_t num_ds_enabled;
  363. bool ds_dirty;
  364. struct sde_hw_ds_cfg ds_cfg[SDE_MAX_DS_COUNT];
  365. struct sde_hw_scaler3_lut_cfg scl3_lut_cfg;
  366. struct sde_core_perf_params new_perf;
  367. };
  368. enum sde_crtc_irq_state {
  369. IRQ_NOINIT,
  370. IRQ_ENABLED,
  371. IRQ_DISABLING,
  372. IRQ_DISABLED,
  373. };
  374. /**
  375. * sde_crtc_irq_info - crtc interrupt info
  376. * @irq: interrupt callback
  377. * @event: event type of the interrupt
  378. * @func: function pointer to enable/disable the interrupt
  379. * @list: list of user customized event in crtc
  380. * @state: state of the interrupt
  381. * @state_lock: spin lock for interrupt state
  382. */
  383. struct sde_crtc_irq_info {
  384. struct sde_irq_callback irq;
  385. u32 event;
  386. int (*func)(struct drm_crtc *crtc, bool en,
  387. struct sde_irq_callback *irq);
  388. struct list_head list;
  389. enum sde_crtc_irq_state state;
  390. spinlock_t state_lock;
  391. };
  392. #define to_sde_crtc_state(x) \
  393. container_of(x, struct sde_crtc_state, base)
  394. /**
  395. * sde_crtc_get_property - query integer value of crtc property
  396. * @S: Pointer to crtc state
  397. * @X: Property index, from enum msm_mdp_crtc_property
  398. * Returns: Integer value of requested property
  399. */
  400. #define sde_crtc_get_property(S, X) \
  401. ((S) && ((X) < CRTC_PROP_COUNT) ? ((S)->property_values[(X)].value) : 0)
  402. /**
  403. * sde_crtc_get_mixer_width - get the mixer width
  404. * Mixer width will be same as panel width(/2 for split)
  405. * unless destination scaler feature is enabled
  406. */
  407. static inline int sde_crtc_get_mixer_width(struct sde_crtc *sde_crtc,
  408. struct sde_crtc_state *cstate, struct drm_display_mode *mode)
  409. {
  410. u32 mixer_width;
  411. if (!sde_crtc || !cstate || !mode)
  412. return 0;
  413. if (cstate->num_ds_enabled)
  414. mixer_width = cstate->ds_cfg[0].lm_width;
  415. else
  416. mixer_width = (sde_crtc->num_mixers == CRTC_DUAL_MIXERS ?
  417. mode->hdisplay / CRTC_DUAL_MIXERS : mode->hdisplay);
  418. return mixer_width;
  419. }
  420. /**
  421. * sde_crtc_get_mixer_height - get the mixer height
  422. * Mixer height will be same as panel height unless
  423. * destination scaler feature is enabled
  424. */
  425. static inline int sde_crtc_get_mixer_height(struct sde_crtc *sde_crtc,
  426. struct sde_crtc_state *cstate, struct drm_display_mode *mode)
  427. {
  428. if (!sde_crtc || !cstate || !mode)
  429. return 0;
  430. return (cstate->num_ds_enabled ?
  431. cstate->ds_cfg[0].lm_height : mode->vdisplay);
  432. }
  433. /**
  434. * sde_crtc_frame_pending - retun the number of pending frames
  435. * @crtc: Pointer to drm crtc object
  436. */
  437. static inline int sde_crtc_frame_pending(struct drm_crtc *crtc)
  438. {
  439. struct sde_crtc *sde_crtc;
  440. if (!crtc)
  441. return -EINVAL;
  442. sde_crtc = to_sde_crtc(crtc);
  443. return atomic_read(&sde_crtc->frame_pending);
  444. }
  445. /**
  446. * sde_crtc_reset_hw - attempt hardware reset on errors
  447. * @crtc: Pointer to DRM crtc instance
  448. * @old_state: Pointer to crtc state for previous commit
  449. * @recovery_events: Whether or not recovery events are enabled
  450. * Returns: Zero if current commit should still be attempted
  451. */
  452. int sde_crtc_reset_hw(struct drm_crtc *crtc, struct drm_crtc_state *old_state,
  453. bool recovery_events);
  454. /**
  455. * sde_crtc_request_frame_reset - requests for next frame reset
  456. * @crtc: Pointer to drm crtc object
  457. */
  458. static inline int sde_crtc_request_frame_reset(struct drm_crtc *crtc)
  459. {
  460. struct sde_crtc *sde_crtc = to_sde_crtc(crtc);
  461. if (sde_crtc->frame_trigger_mode == FRAME_DONE_WAIT_POSTED_START)
  462. sde_crtc_reset_hw(crtc, crtc->state, false);
  463. return 0;
  464. }
  465. /**
  466. * sde_crtc_vblank - enable or disable vblanks for this crtc
  467. * @crtc: Pointer to drm crtc object
  468. * @en: true to enable vblanks, false to disable
  469. */
  470. int sde_crtc_vblank(struct drm_crtc *crtc, bool en);
  471. /**
  472. * sde_crtc_commit_kickoff - trigger kickoff of the commit for this crtc
  473. * @crtc: Pointer to drm crtc object
  474. * @old_state: Pointer to drm crtc old state object
  475. */
  476. void sde_crtc_commit_kickoff(struct drm_crtc *crtc,
  477. struct drm_crtc_state *old_state);
  478. /**
  479. * sde_crtc_prepare_commit - callback to prepare for output fences
  480. * @crtc: Pointer to drm crtc object
  481. * @old_state: Pointer to drm crtc old state object
  482. */
  483. void sde_crtc_prepare_commit(struct drm_crtc *crtc,
  484. struct drm_crtc_state *old_state);
  485. /**
  486. * sde_crtc_complete_commit - callback signalling completion of current commit
  487. * @crtc: Pointer to drm crtc object
  488. * @old_state: Pointer to drm crtc old state object
  489. */
  490. void sde_crtc_complete_commit(struct drm_crtc *crtc,
  491. struct drm_crtc_state *old_state);
  492. /**
  493. * sde_crtc_init - create a new crtc object
  494. * @dev: sde device
  495. * @plane: base plane
  496. * @Return: new crtc object or error
  497. */
  498. struct drm_crtc *sde_crtc_init(struct drm_device *dev, struct drm_plane *plane);
  499. /**
  500. * sde_crtc_post_init - update crtc object with post initialization. It
  501. * can update the debugfs, sysfs, entires.
  502. * @dev: sde device
  503. * @crtc: Pointer to drm crtc structure
  504. */
  505. int sde_crtc_post_init(struct drm_device *dev, struct drm_crtc *crtc);
  506. /**
  507. * sde_crtc_complete_flip - complete flip for clients
  508. * @crtc: Pointer to drm crtc object
  509. * @file: client to cancel's file handle
  510. */
  511. void sde_crtc_complete_flip(struct drm_crtc *crtc, struct drm_file *file);
  512. /**
  513. * sde_crtc_register_custom_event - api for enabling/disabling crtc event
  514. * @kms: Pointer to sde_kms
  515. * @crtc_drm: Pointer to crtc object
  516. * @event: Event that client is interested
  517. * @en: Flag to enable/disable the event
  518. */
  519. int sde_crtc_register_custom_event(struct sde_kms *kms,
  520. struct drm_crtc *crtc_drm, u32 event, bool en);
  521. /**
  522. * sde_crtc_get_intf_mode - get interface mode of the given crtc
  523. * @crtc: Pointert to crtc
  524. */
  525. enum sde_intf_mode sde_crtc_get_intf_mode(struct drm_crtc *crtc);
  526. /**
  527. * sde_crtc_get_fps_mode - get frame rate of the given crtc
  528. * @crtc: Pointert to crtc
  529. */
  530. u32 sde_crtc_get_fps_mode(struct drm_crtc *crtc);
  531. /**
  532. * sde_crtc_get_client_type - check the crtc type- rt, rsc_rt, etc.
  533. * @crtc: Pointer to crtc
  534. */
  535. static inline enum sde_crtc_client_type sde_crtc_get_client_type(
  536. struct drm_crtc *crtc)
  537. {
  538. struct sde_crtc_state *cstate =
  539. crtc ? to_sde_crtc_state(crtc->state) : NULL;
  540. if (!cstate)
  541. return RT_CLIENT;
  542. return cstate->rsc_client ? RT_RSC_CLIENT : RT_CLIENT;
  543. }
  544. /**
  545. * sde_crtc_is_enabled - check if sde crtc is enabled or not
  546. * @crtc: Pointer to crtc
  547. */
  548. static inline bool sde_crtc_is_enabled(struct drm_crtc *crtc)
  549. {
  550. return crtc ? crtc->enabled : false;
  551. }
  552. /**
  553. * sde_crtc_is_reset_required - validate the reset request based on the
  554. * pm_suspend and crtc's active status. crtc's are left active
  555. * on pm_suspend during LP1/LP2 states, as the display is still
  556. * left ON. Avoid reset for the subsequent pm_resume in such cases.
  557. * @crtc: Pointer to crtc
  558. * return: false if in suspend state and crtc active, true otherwise
  559. */
  560. static inline bool sde_crtc_is_reset_required(struct drm_crtc *crtc)
  561. {
  562. /*
  563. * reset is required even when there is no crtc_state as it is required
  564. * to create the initial state object
  565. */
  566. if (!crtc || !crtc->state)
  567. return true;
  568. /* reset not required if crtc is active during suspend state */
  569. if (sde_kms_is_suspend_state(crtc->dev) && crtc->state->active)
  570. return false;
  571. return true;
  572. }
  573. /**
  574. * sde_crtc_event_queue - request event callback
  575. * @crtc: Pointer to drm crtc structure
  576. * @func: Pointer to callback function
  577. * @usr: Pointer to user data to be passed to callback
  578. * @color_processing_event: True if color processing event
  579. * Returns: Zero on success
  580. */
  581. int sde_crtc_event_queue(struct drm_crtc *crtc,
  582. void (*func)(struct drm_crtc *crtc, void *usr),
  583. void *usr, bool color_processing_event);
  584. /**
  585. * sde_crtc_get_crtc_roi - retrieve the crtc_roi from the given state object
  586. * used to allow the planes to adjust their final lm out_xy value in the
  587. * case of partial update
  588. * @crtc_state: Pointer to crtc state
  589. * @crtc_roi: Output pointer to crtc roi in the given state
  590. */
  591. void sde_crtc_get_crtc_roi(struct drm_crtc_state *state,
  592. const struct sde_rect **crtc_roi);
  593. /**
  594. * sde_crtc_is_crtc_roi_dirty - retrieve whether crtc_roi was updated this frame
  595. * Note: Only use during atomic_check since dirty properties may be popped
  596. * @crtc_state: Pointer to crtc state
  597. * Return: true if roi is dirty, false otherwise
  598. */
  599. bool sde_crtc_is_crtc_roi_dirty(struct drm_crtc_state *state);
  600. /** sde_crt_get_secure_level - retrieve the secure level from the give state
  601. * object, this is used to determine the secure state of the crtc
  602. * @crtc : Pointer to drm crtc structure
  603. * @usr: Pointer to drm crtc state
  604. * return: secure_level
  605. */
  606. static inline int sde_crtc_get_secure_level(struct drm_crtc *crtc,
  607. struct drm_crtc_state *state)
  608. {
  609. if (!crtc || !state)
  610. return -EINVAL;
  611. return sde_crtc_get_property(to_sde_crtc_state(state),
  612. CRTC_PROP_SECURITY_LEVEL);
  613. }
  614. /**
  615. * sde_crtc_get_secure_transition - determines the operations to be
  616. * performed before transitioning to secure state
  617. * This function should be called after swapping the new state
  618. * @crtc: Pointer to drm crtc structure
  619. * @old_crtc_state: Poniter to previous CRTC state
  620. * Returns the bitmask of operations need to be performed, -Error in
  621. * case of error cases
  622. */
  623. int sde_crtc_get_secure_transition_ops(struct drm_crtc *crtc,
  624. struct drm_crtc_state *old_crtc_state,
  625. bool old_valid_fb);
  626. /**
  627. * sde_crtc_find_plane_fb_modes - finds the modes of all planes attached
  628. * to crtc
  629. * @crtc: Pointer to DRM crtc object
  630. * @fb_ns: number of non secure planes
  631. * @fb_sec: number of secure-playback planes
  632. * @fb_sec_dir: number of secure-ui/secure-camera planes
  633. */
  634. int sde_crtc_find_plane_fb_modes(struct drm_crtc *crtc,
  635. uint32_t *fb_ns, uint32_t *fb_sec, uint32_t *fb_sec_dir);
  636. /**
  637. * sde_crtc_state_find_plane_fb_modes - finds the modes of all planes attached
  638. * to the crtc state
  639. * @crtc_state: Pointer to DRM crtc state object
  640. * @fb_ns: number of non secure planes
  641. * @fb_sec: number of secure-playback planes
  642. * @fb_sec_dir: number of secure-ui/secure-camera planes
  643. */
  644. int sde_crtc_state_find_plane_fb_modes(struct drm_crtc_state *state,
  645. uint32_t *fb_ns, uint32_t *fb_sec, uint32_t *fb_sec_dir);
  646. /**
  647. * sde_crtc_secure_ctrl - Initiates the transition between secure and
  648. * non-secure world
  649. * @crtc: Pointer to crtc
  650. * @post_commit: if this operation is triggered after commit
  651. */
  652. int sde_crtc_secure_ctrl(struct drm_crtc *crtc, bool post_commit);
  653. /**
  654. * sde_crtc_helper_reset_properties - reset properties to default values in the
  655. * given DRM CRTC state object
  656. * @crtc: Pointer to DRM crtc object
  657. * @crtc_state: Pointer to DRM crtc state object
  658. * Returns: 0 on success, negative errno on failure
  659. */
  660. int sde_crtc_helper_reset_custom_properties(struct drm_crtc *crtc,
  661. struct drm_crtc_state *crtc_state);
  662. /**
  663. * sde_crtc_timeline_status - current buffer timeline status
  664. * @crtc: Pointer to crtc
  665. */
  666. void sde_crtc_timeline_status(struct drm_crtc *crtc);
  667. /**
  668. * sde_crtc_update_cont_splash_settings - update mixer settings
  669. * during device bootup for cont_splash use case
  670. * @crtc: Pointer to drm crtc structure
  671. */
  672. void sde_crtc_update_cont_splash_settings(
  673. struct drm_crtc *crtc);
  674. /**
  675. * sde_crtc_misr_setup - to configure and enable/disable MISR
  676. * @crtc: Pointer to drm crtc structure
  677. * @enable: boolean to indicate enable/disable misr
  678. * @frame_count: frame_count to be configured
  679. */
  680. void sde_crtc_misr_setup(struct drm_crtc *crtc, bool enable, u32 frame_count);
  681. /**
  682. * sde_crtc_get_misr_info - to configure and enable/disable MISR
  683. * @crtc: Pointer to drm crtc structure
  684. * @crtc_misr_info: Pointer to crtc misr info structure
  685. */
  686. void sde_crtc_get_misr_info(struct drm_crtc *crtc,
  687. struct sde_crtc_misr_info *crtc_misr_info);
  688. #endif /* _SDE_CRTC_H_ */