sde_crtc.h 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219
  1. /*
  2. * Copyright (c) 2021-2023 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_CRTC_H_
  20. #define _SDE_CRTC_H_
  21. #include <linux/kthread.h>
  22. #include <linux/of_fdt.h>
  23. #include <drm/drm_crtc.h>
  24. #include <drm/drm_vblank.h>
  25. #include "msm_prop.h"
  26. #include "sde_fence.h"
  27. #include "sde_kms.h"
  28. #include "sde_core_perf.h"
  29. #include "sde_hw_ds.h"
  30. #include "sde_color_processing.h"
  31. #include "sde_encoder.h"
  32. #define SDE_CRTC_NAME_SIZE 12
  33. /* define the maximum number of in-flight frame events */
  34. /* Expand it to 2x for handling atleast 2 connectors safely */
  35. #define SDE_CRTC_EVENT_SIZE (4 * 2)
  36. /**
  37. * enum sde_crtc_client_type: crtc client type
  38. * @RT_CLIENT: RealTime client like video/cmd mode display
  39. * voting through apps rsc
  40. * @NRT_CLIENT: Non-RealTime client like WB display
  41. * voting through apps rsc
  42. * @RT_RSC_CLIENT: Realtime display RSC voting client
  43. */
  44. enum sde_crtc_client_type {
  45. RT_CLIENT,
  46. NRT_CLIENT,
  47. RT_RSC_CLIENT,
  48. };
  49. /**
  50. * enum sde_crtc_output_capture_point
  51. * @MIXER_OUT : capture mixer output
  52. * @DSPP_OUT : capture output of dspp
  53. * @CAPTURE_DEMURA_OUT : capture output of demura
  54. */
  55. enum sde_crtc_output_capture_point {
  56. CAPTURE_MIXER_OUT,
  57. CAPTURE_DSPP_OUT,
  58. CAPTURE_DEMURA_OUT
  59. };
  60. /**
  61. * enum fence_error_handle_flag: the flag to enable/disable fence error handling in kernel
  62. * @FENCE_ERROR_HANDLE_DISABLE : disable fence error handling in kernel
  63. * @FENCE_ERROR_HANDLE_ENABLE : enable fence error handling in kernel
  64. */
  65. enum fence_error_handle_flag {
  66. FENCE_ERROR_HANDLE_DISABLE,
  67. FENCE_ERROR_HANDLE_ENABLE,
  68. };
  69. /**
  70. * enum sde_crtc_idle_pc_state: states of idle power collapse
  71. * @IDLE_PC_NONE: no-op
  72. * @IDLE_PC_ENABLE: enable idle power-collapse
  73. * @IDLE_PC_DISABLE: disable idle power-collapse
  74. */
  75. enum sde_crtc_idle_pc_state {
  76. IDLE_PC_NONE,
  77. IDLE_PC_ENABLE,
  78. IDLE_PC_DISABLE,
  79. };
  80. /**
  81. * enum sde_crtc_vm_req: request for VM operations
  82. * @VM_REQ_NONE: no request. Normal VM operations.
  83. * @VM_REQ_RELEASE: request to release the HW resources from the current VM
  84. * @VM_REQ_ACQUIRE: request to acquire the HW resources in the current VM
  85. */
  86. enum sde_crtc_vm_req {
  87. VM_REQ_NONE,
  88. VM_REQ_RELEASE,
  89. VM_REQ_ACQUIRE,
  90. };
  91. /**
  92. * @connectors : Currently associated drm connectors for retire event
  93. * @num_connectors: Number of associated drm connectors for retire event
  94. * @list: event list
  95. */
  96. struct sde_crtc_retire_event {
  97. struct drm_connector *connectors[MAX_CONNECTORS];
  98. int num_connectors;
  99. struct list_head list;
  100. };
  101. /**
  102. * struct sde_crtc_mixer: stores the map for each virtual pipeline in the CRTC
  103. * @hw_lm: LM HW Driver context
  104. * @hw_ctl: CTL Path HW driver context
  105. * @hw_dspp: DSPP HW driver context
  106. * @hw_ds: DS HW driver context
  107. * @encoder: Encoder attached to this lm & ctl
  108. * @mixer_op_mode: mixer blending operation mode
  109. */
  110. struct sde_crtc_mixer {
  111. struct sde_hw_mixer *hw_lm;
  112. struct sde_hw_ctl *hw_ctl;
  113. struct sde_hw_dspp *hw_dspp;
  114. struct sde_hw_ds *hw_ds;
  115. struct drm_encoder *encoder;
  116. u32 mixer_op_mode;
  117. };
  118. /**
  119. * struct sde_crtc_frame_event: stores crtc frame event for crtc processing
  120. * @work: base work structure
  121. * @crtc: Pointer to crtc handling this event
  122. * @connector: pointer to drm connector which is source of frame event
  123. * @list: event list
  124. * @ts: timestamp at queue entry
  125. * @event: event identifier
  126. */
  127. struct sde_crtc_frame_event {
  128. struct kthread_work work;
  129. struct drm_crtc *crtc;
  130. struct drm_connector *connector;
  131. struct list_head list;
  132. ktime_t ts;
  133. u32 event;
  134. };
  135. /**
  136. * struct sde_crtc_vblank_event: vblank notify event
  137. * @work: base work structure
  138. * @crtc: Pointer to crtc handling this event
  139. * @list: vblank list
  140. * @ts: vblank timestamp
  141. */
  142. struct sde_crtc_vblank_event {
  143. struct kthread_work work;
  144. struct drm_crtc *crtc;
  145. struct list_head list;
  146. ktime_t ts;
  147. };
  148. /**
  149. * struct sde_crtc_event - event callback tracking structure
  150. * @list: Linked list tracking node
  151. * @kt_work: Kthread worker structure
  152. * @sde_crtc: Pointer to associated sde_crtc structure
  153. * @cb_func: Pointer to callback function
  154. * @usr: Pointer to user data to be provided to the callback
  155. */
  156. struct sde_crtc_event {
  157. struct list_head list;
  158. struct kthread_work kt_work;
  159. void *sde_crtc;
  160. void (*cb_func)(struct drm_crtc *crtc, void *usr);
  161. void *usr;
  162. };
  163. /**
  164. * struct sde_crtc_fps_info - structure for measuring fps periodicity
  165. * @frame_count : Total frames during configured periodic duration
  166. * @last_sampled_time_us: Stores the last ktime in microsecs when fps
  167. * was calculated
  168. * @measured_fps : Last measured fps value
  169. * @fps_periodic_duration : Duration in milliseconds to measure the fps.
  170. * Default value is 1 second.
  171. * @time_buf : Buffer for storing ktime of the commits
  172. * @next_time_index : index into time_buf for storing ktime for next commit
  173. */
  174. struct sde_crtc_fps_info {
  175. u32 frame_count;
  176. ktime_t last_sampled_time_us;
  177. u32 measured_fps;
  178. u32 fps_periodic_duration;
  179. ktime_t *time_buf;
  180. u32 next_time_index;
  181. };
  182. /**
  183. * struct sde_ltm_buffer - defines LTM buffer structure.
  184. * @fb: frm framebuffer for the buffer
  185. * @gem: drm gem handle for the buffer
  186. * @asapce : pointer to address space
  187. * @drm_fb_id: framebuffer id associated with this buffer
  188. * @offset: offset for alignment
  189. * @iova: device address
  190. * @kva: kernel virtual address
  191. * @node: list node for LTM buffer list;
  192. */
  193. struct sde_ltm_buffer {
  194. struct drm_framebuffer *fb;
  195. struct drm_gem_object *gem;
  196. struct msm_gem_address_space *aspace;
  197. u32 drm_fb_id;
  198. u32 offset;
  199. u64 iova;
  200. void *kva;
  201. struct list_head node;
  202. };
  203. /**
  204. * struct sde_crtc_misr_info - structure for misr information
  205. * @misr_enable : enable/disable flag
  206. * @misr_frame_count : Number of frames for misr calculation.
  207. */
  208. struct sde_crtc_misr_info {
  209. bool misr_enable;
  210. u32 misr_frame_count;
  211. };
  212. /*
  213. * Maximum number of free event structures to cache
  214. */
  215. #define SDE_CRTC_MAX_EVENT_COUNT 16
  216. /**
  217. * struct sde_frame_data_buffer - defines frame data buffer structure
  218. * @fd: framebuffer id associated with this buffer
  219. * @fb: drm framebuffer for the buffer
  220. * @gem: drm gem handle for he buffer
  221. */
  222. struct sde_frame_data_buffer {
  223. u32 fd;
  224. struct drm_framebuffer *fb;
  225. struct drm_gem_object *gem;
  226. };
  227. /**
  228. * struct sde_frame_data - defines sde frame data structure
  229. * @idx : currently used frame data buffe
  230. * @cnt : rnumber of available frame data buffers
  231. * @buf : list of frame data buffers
  232. */
  233. struct sde_frame_data {
  234. u32 idx;
  235. u32 cnt;
  236. struct sde_frame_data_buffer *buf[SDE_FRAME_DATA_BUFFER_MAX];
  237. };
  238. /**
  239. * struct sde_opr_value - defines sde opr value structure
  240. * @num_valid_opr : count of valid opr values
  241. * @opr_value : list of opr value
  242. */
  243. struct sde_opr_value {
  244. atomic_t num_valid_opr;
  245. u32 opr_value[MAX_DSI_DISPLAYS];
  246. };
  247. /**
  248. * enum sde_crtc_hw_fence_flags - flags to enable/disable hw fence features
  249. * @HW_FENCE_OUT_FENCES_ENABLE: enables creation of hw fences for crtc output fences
  250. * @HW_FENCE_IN_FENCES_ENABLE: enables hw fences for input-fences that are candidates for hw wait
  251. * (i.e. they have the dma-fence flag for dma-fences set), this allows to
  252. * selectively enable/disable input-fences, regardless of the dma-fence flags.
  253. * @HW_FENCE-IN_FENCES_NO_OVERRIDE: skip the sw-override of the input hw-fences signal.
  254. * @HW_FENCE_FEATURES_MAX: max number of features.
  255. */
  256. enum sde_crtc_hw_fence_flags {
  257. HW_FENCE_OUT_FENCES_ENABLE,
  258. HW_FENCE_IN_FENCES_ENABLE,
  259. HW_FENCE_IN_FENCES_NO_OVERRIDE,
  260. HW_FENCE_FEATURES_MAX,
  261. };
  262. /**
  263. * struct sde_crtc - virtualized CRTC data structure
  264. * @base : Base drm crtc structure
  265. * @name : ASCII description of this crtc
  266. * @num_ctls : Number of ctl paths in use
  267. * @num_mixers : Number of mixers in use
  268. * @mixers_swapped: Whether the mixers have been swapped for left/right update
  269. * especially in the case of DSC Merge.
  270. * @mixers : List of active mixers
  271. * @event : Pointer to last received drm vblank event. If there is a
  272. * pending vblank event, this will be non-null.
  273. * @vsync_count : Running count of received vsync events
  274. * @drm_requested_vblank : Whether vblanks have been enabled in the encoder
  275. * @property_info : Opaque structure for generic property support
  276. * @property_defaults : Array of default values for generic property support
  277. * @output_fence : output release fence context
  278. * @stage_cfg : H/w mixer stage configuration
  279. * @debugfs_root : Parent of debugfs node
  280. * @priv_handle : Pointer to external private handle, if present
  281. * @vblank_cb_count : count of vblank callback since last reset
  282. * @play_count : frame count between crtc enable and disable
  283. * @vblank_cb_time : ktime at vblank count reset
  284. * @vblank_last_cb_time : ktime at last vblank notification
  285. * @retire_frame_event_time : ktime at last retire frame event
  286. * @sysfs_dev : sysfs device node for crtc
  287. * @vsync_event_sf : vsync event notifier sysfs device
  288. * @retire_frame_event_sf :retire frame event notifier sysfs device
  289. * @enabled : whether the SDE CRTC is currently enabled. updated in the
  290. * commit-thread, not state-swap time which is earlier, so
  291. * safe to make decisions on during VBLANK on/off work
  292. * @cp_feature_list : list of color processing features supported on a crtc
  293. * @cp_active_list : list of color processing features are active
  294. * @cp_dirty_list : list of color processing features are dirty
  295. * @revalidate_mask : stores dirty flags to revalidate after idlepc
  296. * @ad_dirty : list containing ad properties that are dirty
  297. * @ad_active : list containing ad properties that are active
  298. * @crtc_lock : crtc lock around create, destroy and access.
  299. * @frame_pending : Whether or not an update is pending
  300. * @kickoff_in_progress : boolean entry to check if kickoff is in progress
  301. * @frame_events : static allocation of in-flight frame events
  302. * @frame_event_list : available frame event list
  303. * @vblank_events : static allocation of in-flight vblank events
  304. * @vblank_event_list : available vblank event list
  305. * @spin_lock : spin lock for transaction status, etc...
  306. * @event_spin_lock : spin lock for all the event lists
  307. * @event_thread : Pointer to event handler thread
  308. * @event_worker : Event worker queue
  309. * @event_cache : Local cache of event worker structures
  310. * @event_free_list : List of available event structures
  311. * @event_lock : Spinlock around event handling code
  312. * @misr_enable_sui : boolean entry indicates misr enable/disable status
  313. * for secure cases.
  314. * @misr_enable_debugfs : boolean entry indicates misr enable/disable status
  315. * from debugfs.
  316. * @misr_reconfigure : boolean entry indicates misr reconfigure status
  317. * @misr_frame_count : misr frame count provided by client
  318. * @misr_data : store misr data before turning off the clocks.
  319. * @power_event : registered power event handle
  320. * @cur_perf : current performance committed to clock/bandwidth driver
  321. * @plane_mask_old: keeps track of the planes used in the previous commit
  322. * @frame_trigger_mode: frame trigger mode
  323. * @cp_pu_feature_mask: mask indicating cp feature enable for partial update
  324. * @ltm_buffer_cnt : number of ltm buffers
  325. * @ltm_buffers : struct stores ltm buffer related data
  326. * @ltm_buf_free : list of LTM buffers that are available
  327. * @ltm_buf_busy : list of LTM buffers that are been used by HW
  328. * @ltm_hist_en : flag to indicate whether LTM hist is enabled or not
  329. * @ltm_merge_clear_pending : flag indicates merge mode bit needs to be cleared
  330. * @ltm_buffer_lock : muttx to protect ltm_buffers allcation and free
  331. * @ltm_lock : Spinlock to protect ltm buffer_cnt, hist_en and ltm lists
  332. * @needs_hw_reset : Initiate a hw ctl reset
  333. * @reinit_crtc_mixers : Reinitialize mixers in crtc
  334. * @hist_irq_idx : hist interrupt irq idx
  335. * @disable_pending_cp : flag tracks pending color processing features force disable
  336. * @src_bpp : source bpp used to calculate compression ratio
  337. * @target_bpp : target bpp used to calculate compression ratio
  338. * @static_cache_read_work: delayed worker to transition cache state to read
  339. * @cache_state : Current static image cache state
  340. * @cache_type : Current static image cache type to use
  341. * @dspp_blob_info : blob containing dspp hw capability information
  342. * @cached_encoder_mask : cached encoder_mask for vblank work
  343. * @valid_skip_blend_plane: flag to indicate if skip blend plane is valid
  344. * @skip_blend_plane: enabled plane that has skip blending
  345. * @skip_blend_plane_w: skip blend plane width
  346. * @skip_blend_plane_h: skip blend plane height
  347. * @line_time_in_ns : current mode line time in nano sec is needed for QOS update
  348. * @frame_data : Framedata data structure
  349. * @previous_opr_value : store previous opr values
  350. * @opr_event_notify_enabled : Flag to indicate if opr event notify is enabled or not
  351. * @hwfence_features_mask : u32 mask to enable/disable hw fence features. See enum
  352. * sde_crtc_hw_fence_flags for available fields.
  353. * @hwfence_out_fences_skip: number of frames to skip before create a new hw-fence, this can be
  354. * used to slow-down creation of output hw-fences for debugging purposes.
  355. * @input_fence_status : input fence status, negative if the fence has been completed with error.
  356. * @hanle_fence_error_bw_update: bool to indicate if it is fence error and need to avoid bw vote.
  357. * @back_light: backlight value
  358. * @back_light_max: max backlight value
  359. * @back_light_pending: flag to indicate if backlight update is pending
  360. */
  361. struct sde_crtc {
  362. struct drm_crtc base;
  363. char name[SDE_CRTC_NAME_SIZE];
  364. /* HW Resources reserved for the crtc */
  365. u32 num_ctls;
  366. u32 num_mixers;
  367. bool mixers_swapped;
  368. struct sde_crtc_mixer mixers[MAX_MIXERS_PER_CRTC];
  369. struct drm_pending_vblank_event *event;
  370. u32 vsync_count;
  371. struct msm_property_info property_info;
  372. struct msm_property_data property_data[CRTC_PROP_COUNT];
  373. struct drm_property_blob *blob_info;
  374. /* output fence support */
  375. struct sde_fence_context *output_fence;
  376. struct sde_hw_stage_cfg stage_cfg[MAX_LAYOUTS_PER_CRTC];
  377. struct dentry *debugfs_root;
  378. void *priv_handle;
  379. u32 vblank_cb_count;
  380. u64 play_count;
  381. ktime_t vblank_cb_time;
  382. ktime_t vblank_last_cb_time;
  383. ktime_t retire_frame_event_time;
  384. struct sde_crtc_fps_info fps_info;
  385. struct device *sysfs_dev;
  386. struct kernfs_node *vsync_event_sf;
  387. struct kernfs_node *retire_frame_event_sf;
  388. bool enabled;
  389. struct list_head cp_feature_list;
  390. struct list_head cp_active_list;
  391. struct list_head cp_dirty_list;
  392. struct list_head ad_dirty;
  393. struct list_head ad_active;
  394. struct list_head user_event_list;
  395. struct mutex crtc_lock;
  396. struct mutex crtc_cp_lock;
  397. atomic_t frame_pending;
  398. struct sde_crtc_frame_event frame_events[SDE_CRTC_EVENT_SIZE];
  399. struct list_head frame_event_list;
  400. struct sde_crtc_vblank_event vblank_events[SDE_CRTC_EVENT_SIZE];
  401. struct list_head vblank_event_list;
  402. spinlock_t spin_lock;
  403. spinlock_t event_spin_lock;
  404. bool kickoff_in_progress;
  405. unsigned long revalidate_mask;
  406. /* for handling internal event thread */
  407. struct sde_crtc_event event_cache[SDE_CRTC_MAX_EVENT_COUNT];
  408. struct list_head event_free_list;
  409. spinlock_t event_lock;
  410. bool misr_enable_sui;
  411. bool misr_enable_debugfs;
  412. bool misr_reconfigure;
  413. u32 misr_frame_count;
  414. struct sde_power_event *power_event;
  415. struct sde_core_perf_params cur_perf;
  416. struct sde_core_perf_params new_perf;
  417. u32 plane_mask_old;
  418. /* blob for histogram data */
  419. struct drm_property_blob *hist_blob;
  420. enum frame_trigger_mode_type frame_trigger_mode;
  421. u32 cp_pu_feature_mask;
  422. u32 ltm_buffer_cnt;
  423. struct sde_ltm_buffer *ltm_buffers[LTM_BUFFER_SIZE];
  424. struct list_head ltm_buf_free;
  425. struct list_head ltm_buf_busy;
  426. bool ltm_hist_en;
  427. bool ltm_merge_clear_pending;
  428. struct drm_msm_ltm_cfg_param ltm_cfg;
  429. struct mutex ltm_buffer_lock;
  430. spinlock_t ltm_lock;
  431. bool needs_hw_reset;
  432. bool reinit_crtc_mixers;
  433. int hist_irq_idx;
  434. bool disable_pending_cp;
  435. int src_bpp;
  436. int target_bpp;
  437. struct kthread_delayed_work static_cache_read_work;
  438. enum sde_sys_cache_state cache_state;
  439. enum sde_sys_cache_type cache_type;
  440. struct drm_property_blob *dspp_blob_info;
  441. u32 cached_encoder_mask;
  442. bool valid_skip_blend_plane;
  443. enum sde_sspp skip_blend_plane;
  444. u32 skip_blend_plane_w;
  445. u32 skip_blend_plane_h;
  446. u32 line_time_in_ns;
  447. struct sde_frame_data frame_data;
  448. struct sde_opr_value previous_opr_value;
  449. bool opr_event_notify_enabled;
  450. DECLARE_BITMAP(hwfence_features_mask, HW_FENCE_FEATURES_MAX);
  451. u32 hwfence_out_fences_skip;
  452. int input_fence_status;
  453. bool handle_fence_error_bw_update;
  454. u32 back_light;
  455. u32 back_light_max;
  456. u32 back_light_pending;
  457. };
  458. enum sde_crtc_dirty_flags {
  459. SDE_CRTC_DIRTY_DEST_SCALER,
  460. SDE_CRTC_DIRTY_DIM_LAYERS,
  461. SDE_CRTC_NOISE_LAYER,
  462. SDE_CRTC_DIRTY_MAX,
  463. };
  464. #define to_sde_crtc(x) container_of(x, struct sde_crtc, base)
  465. /**
  466. * struct sde_line_insertion_param - sde line insertion parameters
  467. * @panel_line_insertion_enable: line insertion support status
  468. * @padding_height: panel height after line padding
  469. * @padding_active: active lines in panel stacking pattern
  470. * @padding_dummy: dummy lines in panel stacking pattern
  471. */
  472. struct sde_line_insertion_param {
  473. bool panel_line_insertion_enable;
  474. u32 padding_height;
  475. u32 padding_active;
  476. u32 padding_dummy;
  477. };
  478. /**
  479. * struct sde_crtc_state - sde container for atomic crtc state
  480. * @base: Base drm crtc state structure
  481. * @connectors : Currently associated drm connectors
  482. * @num_connectors: Number of associated drm connectors
  483. * @rsc_client : sde rsc client when mode is valid
  484. * @is_ppsplit : Whether current topology requires PPSplit special handling
  485. * @bw_control : true if bw/clk controlled by core bw/clk properties
  486. * @bw_split_vote : true if bw controlled by llcc/dram bw properties
  487. * @crtc_roi : Current CRTC ROI. Possibly sub-rectangle of mode.
  488. * Origin top left of CRTC.
  489. * @lm_bounds : LM boundaries based on current mode full resolution, no ROI.
  490. * Origin top left of CRTC.
  491. * @lm_roi : Current LM ROI, possibly sub-rectangle of mode.
  492. * Origin top left of CRTC.
  493. * @user_roi_list : List of user's requested ROIs as from set property
  494. * @cached_user_roi_list : Copy of user_roi_list from previous PU frame
  495. * @property_state: Local storage for msm_prop properties
  496. * @property_values: Current crtc property values
  497. * @input_fence_timeout_ns : Cached input fence timeout, in ns
  498. * @num_dim_layers: Number of dim layers
  499. * @cwb_enc_mask : encoder mask populated during atomic_check if CWB is enabled
  500. * @cached_cwb_enc_mask : cached encoder mask populated during atomic_check if CWB is enabled
  501. * @dim_layer: Dim layer configs
  502. * @num_ds: Number of destination scalers to be configured
  503. * @num_ds_enabled: Number of destination scalers enabled
  504. * @ds_cfg: Destination scaler config
  505. * @scl3_lut_cfg: QSEED3 lut config
  506. * @new_perf: new performance state being requested
  507. * @noise_layer_en: flag to indicate if noise layer cfg is valid
  508. * @drm_msm_noise_layer_cfg: noise layer configuration
  509. * @cp_prop_cnt: number of dirty color processing features
  510. * @cp_prop_values: array of cp property values
  511. * @cp_dirty_list: array tracking features that are dirty
  512. * @cp_range_payload: array storing state user_data passed via range props
  513. * @cont_splash_populated: State was populated as part of cont. splash
  514. * @param: sde line insertion parameters
  515. * @hwfence_in_fences_set: input hw fences are configured for the commit
  516. */
  517. struct sde_crtc_state {
  518. struct drm_crtc_state base;
  519. struct drm_connector *connectors[MAX_CONNECTORS];
  520. int num_connectors;
  521. struct sde_rsc_client *rsc_client;
  522. bool rsc_update;
  523. bool bw_control;
  524. bool bw_split_vote;
  525. bool is_ppsplit;
  526. struct sde_rect crtc_roi;
  527. struct sde_rect lm_bounds[MAX_MIXERS_PER_CRTC];
  528. struct sde_rect lm_roi[MAX_MIXERS_PER_CRTC];
  529. struct msm_roi_list user_roi_list, cached_user_roi_list;
  530. struct msm_property_state property_state;
  531. struct msm_property_value property_values[CRTC_PROP_COUNT];
  532. DECLARE_BITMAP(dirty, SDE_CRTC_DIRTY_MAX);
  533. uint64_t input_fence_timeout_ns;
  534. uint32_t num_dim_layers;
  535. uint32_t cwb_enc_mask;
  536. uint32_t cached_cwb_enc_mask;
  537. struct sde_hw_dim_layer dim_layer[SDE_MAX_DIM_LAYERS];
  538. uint32_t num_ds;
  539. uint32_t num_ds_enabled;
  540. struct sde_hw_ds_cfg ds_cfg[SDE_MAX_DS_COUNT];
  541. struct sde_hw_scaler3_lut_cfg scl3_lut_cfg;
  542. struct sde_core_perf_params new_perf;
  543. bool noise_layer_en;
  544. struct drm_msm_noise_layer_cfg layer_cfg;
  545. uint32_t cp_prop_cnt;
  546. struct sde_cp_crtc_property_state
  547. cp_prop_values[SDE_CP_CRTC_MAX_FEATURES];
  548. uint32_t cp_dirty_list[SDE_CP_CRTC_MAX_FEATURES];
  549. struct sde_cp_crtc_range_prop_payload
  550. cp_range_payload[SDE_CP_CRTC_MAX_FEATURES];
  551. bool cont_splash_populated;
  552. struct sde_line_insertion_param line_insertion;
  553. bool hwfence_in_fences_set;
  554. };
  555. enum sde_crtc_irq_state {
  556. IRQ_NOINIT,
  557. IRQ_ENABLED,
  558. IRQ_DISABLING,
  559. IRQ_DISABLED,
  560. };
  561. /**
  562. * sde_crtc_irq_info - crtc interrupt info
  563. * @irq: interrupt callback
  564. * @event: event type of the interrupt
  565. * @func: function pointer to enable/disable the interrupt
  566. * @list: list of user customized event in crtc
  567. * @state: state of the interrupt
  568. * @state_lock: spin lock for interrupt state
  569. */
  570. struct sde_crtc_irq_info {
  571. struct sde_irq_callback irq;
  572. u32 event;
  573. int (*func)(struct drm_crtc *crtc, bool en,
  574. struct sde_irq_callback *irq);
  575. struct list_head list;
  576. enum sde_crtc_irq_state state;
  577. spinlock_t state_lock;
  578. };
  579. #define to_sde_crtc_state(x) \
  580. container_of(x, struct sde_crtc_state, base)
  581. /**
  582. * sde_crtc_get_property - query integer value of crtc property
  583. * @S: Pointer to crtc state
  584. * @X: Property index, from enum msm_mdp_crtc_property
  585. * Returns: Integer value of requested property
  586. */
  587. #define sde_crtc_get_property(S, X) \
  588. ((S) && ((X) < CRTC_PROP_COUNT) ? ((S)->property_values[(X)].value) : 0)
  589. /**
  590. * sde_crtc_frame_pending - retun the number of pending frames
  591. * @crtc: Pointer to drm crtc object
  592. */
  593. static inline int sde_crtc_frame_pending(struct drm_crtc *crtc)
  594. {
  595. struct sde_crtc *sde_crtc;
  596. if (!crtc)
  597. return -EINVAL;
  598. sde_crtc = to_sde_crtc(crtc);
  599. return atomic_read(&sde_crtc->frame_pending);
  600. }
  601. /**
  602. * sde_crtc_set_needs_hw_reset - set hw reset flag, to handle reset during
  603. * commit kickoff
  604. * @crtc: Pointer to DRM crtc instance
  605. */
  606. static inline void sde_crtc_set_needs_hw_reset(struct drm_crtc *crtc)
  607. {
  608. struct sde_crtc *sde_crtc;
  609. if (!crtc)
  610. return;
  611. sde_crtc = to_sde_crtc(crtc);
  612. sde_crtc->needs_hw_reset = true;
  613. }
  614. /**
  615. * sde_crtc_reset_hw - attempt hardware reset on errors
  616. * @crtc: Pointer to DRM crtc instance
  617. * @old_state: Pointer to crtc state for previous commit
  618. * @recovery_events: Whether or not recovery events are enabled
  619. * Returns: Zero if current commit should still be attempted
  620. */
  621. int sde_crtc_reset_hw(struct drm_crtc *crtc, struct drm_crtc_state *old_state,
  622. bool recovery_events);
  623. /**
  624. * sde_crtc_dump_fences - dump info for input fences of each crtc plane
  625. * @crtc: Pointer to DRM crtc instance
  626. */
  627. void sde_crtc_dump_fences(struct drm_crtc *crtc);
  628. /**
  629. * sde_crtc_is_fence_signaled - check if all fences have been signaled
  630. * @crtc: Pointer to DRM crtc instance
  631. * Returns: true if all fences are signaled, otherwise false.
  632. */
  633. bool sde_crtc_is_fence_signaled(struct drm_crtc *crtc);
  634. /**
  635. * sde_crtc_request_frame_reset - requests for next frame reset
  636. * @crtc: Pointer to drm crtc object
  637. * @encoder: Pointer to drm encoder object
  638. */
  639. static inline int sde_crtc_request_frame_reset(struct drm_crtc *crtc,
  640. struct drm_encoder *encoder)
  641. {
  642. struct sde_crtc *sde_crtc = to_sde_crtc(crtc);
  643. if (test_bit(HW_FENCE_IN_FENCES_ENABLE, sde_crtc->hwfence_features_mask))
  644. sde_crtc_dump_fences(crtc);
  645. if (sde_crtc->frame_trigger_mode == FRAME_DONE_WAIT_POSTED_START ||
  646. !sde_encoder_is_dsi_display(encoder))
  647. sde_crtc_reset_hw(crtc, crtc->state, false);
  648. return 0;
  649. }
  650. /**
  651. * sde_crtc_get_mixer_resolution - Get the mixer resolution based on the features enabled.
  652. * Mixer width will be same as panel width(/2 for split) or src_width of
  653. * destination scaler or downscale-blur.
  654. * @drm_crtc: Pointer to drm crtc object
  655. * @crtc_state: Pointer to drm crtc state object
  656. * @mode: Pointer to drm display mode object
  657. * @width: Pointer to width object populated with mixer width by this function
  658. * @height: Pointer to height object populated with mixer height by this function
  659. */
  660. void sde_crtc_get_mixer_resolution(struct drm_crtc *sde_crtc, struct drm_crtc_state *crtc_state,
  661. struct drm_display_mode *mode, u32 *width, u32 *height);
  662. /**
  663. * sde_crtc_get_resolution - Get the crtc resolution based on the features enabled.
  664. * Crtc width will be same as panel width or (src_width of
  665. * destination scaler or downscale-blur) * num_blocks.
  666. * @drm_crtc: Pointer to drm crtc object
  667. * @crtc_state: Pointer to drm crtc state object
  668. * @mode: Pointer to drm display mode object
  669. * @width: Pointer to width object populated with crtc width by this function
  670. * @height: Pointer to height object populated with crtc height by this function
  671. */
  672. void sde_crtc_get_resolution(struct drm_crtc *sde_crtc, struct drm_crtc_state *crtc_state,
  673. struct drm_display_mode *mode, u32 *width, u32 *height);
  674. /**
  675. * sde_crtc_vblank - enable or disable vblanks for this crtc
  676. * @crtc: Pointer to drm crtc object
  677. * @en: true to enable vblanks, false to disable
  678. */
  679. int sde_crtc_vblank(struct drm_crtc *crtc, bool en);
  680. /**
  681. * sde_crtc_get_msm_mode - get msm_mode for a given crtc state
  682. * @c_state: Pointer to drm crtc state object
  683. * Returns: msm_display_mode corresponding to this crtc state, or NULL if none
  684. */
  685. struct msm_display_mode *sde_crtc_get_msm_mode(struct drm_crtc_state *c_state);
  686. /**
  687. * sde_crtc_commit_kickoff - trigger kickoff of the commit for this crtc
  688. * @crtc: Pointer to drm crtc object
  689. * @old_state: Pointer to drm crtc old state object
  690. */
  691. void sde_crtc_commit_kickoff(struct drm_crtc *crtc,
  692. struct drm_crtc_state *old_state);
  693. /**
  694. * sde_crtc_prepare_commit - callback to prepare for output fences
  695. * @crtc: Pointer to drm crtc object
  696. * @old_state: Pointer to drm crtc old state object
  697. */
  698. void sde_crtc_prepare_commit(struct drm_crtc *crtc,
  699. struct drm_crtc_state *old_state);
  700. /**
  701. * sde_crtc_complete_commit - callback signalling completion of current commit
  702. * @crtc: Pointer to drm crtc object
  703. * @old_state: Pointer to drm crtc old state object
  704. */
  705. void sde_crtc_complete_commit(struct drm_crtc *crtc,
  706. struct drm_crtc_state *old_state);
  707. /**
  708. * sde_crtc_init - create a new crtc object
  709. * @dev: sde device
  710. * @plane: base plane
  711. * @Return: new crtc object or error
  712. */
  713. struct drm_crtc *sde_crtc_init(struct drm_device *dev, struct drm_plane *plane);
  714. /**
  715. * sde_crtc_post_init - update crtc object with post initialization. It
  716. * can update the debugfs, sysfs, entires.
  717. * @dev: sde device
  718. * @crtc: Pointer to drm crtc structure
  719. */
  720. int sde_crtc_post_init(struct drm_device *dev, struct drm_crtc *crtc);
  721. /**
  722. * sde_crtc_complete_flip - complete flip for clients
  723. * @crtc: Pointer to drm crtc object
  724. * @file: client to cancel's file handle
  725. */
  726. void sde_crtc_complete_flip(struct drm_crtc *crtc, struct drm_file *file);
  727. /**
  728. * sde_crtc_register_custom_event - api for enabling/disabling crtc event
  729. * @kms: Pointer to sde_kms
  730. * @crtc_drm: Pointer to crtc object
  731. * @event: Event that client is interested
  732. * @en: Flag to enable/disable the event
  733. */
  734. int sde_crtc_register_custom_event(struct sde_kms *kms,
  735. struct drm_crtc *crtc_drm, u32 event, bool en);
  736. /**
  737. * sde_crtc_get_intf_mode - get interface mode of the given crtc
  738. * @crtc: Pointert to DRM crtc
  739. * @crtc: Pointert to DRM crtc_state
  740. */
  741. enum sde_intf_mode sde_crtc_get_intf_mode(struct drm_crtc *crtc,
  742. struct drm_crtc_state *cstate);
  743. /**
  744. * sde_crtc_get_fps_mode - get frame rate of the given crtc
  745. * @crtc: Pointert to crtc
  746. */
  747. u32 sde_crtc_get_fps_mode(struct drm_crtc *crtc);
  748. /**
  749. * sde_crtc_get_dfps_maxfps - get DFPS max fps of the given crtc
  750. * @crtc: Pointert to crtc
  751. */
  752. u32 sde_crtc_get_dfps_maxfps(struct drm_crtc *crtc);
  753. /**
  754. * sde_crtc_get_wb_usage_type - get writeback usage type
  755. * @crtc: Pointert to crtc
  756. */
  757. enum sde_wb_usage_type sde_crtc_get_wb_usage_type(struct drm_crtc *crtc);
  758. /**
  759. * sde_crtc_get_client_type - check the crtc type- rt, rsc_rt, etc.
  760. * @crtc: Pointer to crtc
  761. */
  762. static inline enum sde_crtc_client_type sde_crtc_get_client_type(
  763. struct drm_crtc *crtc)
  764. {
  765. struct sde_crtc_state *cstate =
  766. crtc ? to_sde_crtc_state(crtc->state) : NULL;
  767. if (!cstate)
  768. return RT_CLIENT;
  769. return cstate->rsc_client ? RT_RSC_CLIENT : RT_CLIENT;
  770. }
  771. /**
  772. * sde_crtc_is_rt_client - check if real-time client or not
  773. * @crtc: Pointer to DRM crtc
  774. * @crtc_state: Pointer to DRM crtc_state
  775. */
  776. static inline bool sde_crtc_is_rt_client(struct drm_crtc *crtc,
  777. struct drm_crtc_state *cstate)
  778. {
  779. if (!crtc || !cstate)
  780. return true;
  781. return (sde_crtc_get_intf_mode(crtc, cstate) != INTF_MODE_WB_LINE);
  782. }
  783. /**
  784. * sde_crtc_is_enabled - check if sde crtc is enabled or not
  785. * @crtc: Pointer to crtc
  786. */
  787. static inline bool sde_crtc_is_enabled(struct drm_crtc *crtc)
  788. {
  789. return crtc ? crtc->enabled : false;
  790. }
  791. static inline u32 sde_crtc_get_line_time(struct drm_crtc *crtc)
  792. {
  793. struct sde_crtc *sde_crtc;
  794. if (!crtc)
  795. return 0;
  796. sde_crtc = to_sde_crtc(crtc);
  797. return sde_crtc->line_time_in_ns;
  798. }
  799. /**
  800. * sde_crtc_is_reset_required - validate the reset request based on the
  801. * pm_suspend and crtc's active status. crtc's are left active
  802. * on pm_suspend during LP1/LP2 states, as the display is still
  803. * left ON. Avoid reset for the subsequent pm_resume in such cases.
  804. * @crtc: Pointer to crtc
  805. * return: false if in suspend state and crtc active, true otherwise
  806. */
  807. static inline bool sde_crtc_is_reset_required(struct drm_crtc *crtc)
  808. {
  809. /*
  810. * reset is required even when there is no crtc_state as it is required
  811. * to create the initial state object
  812. */
  813. if (!crtc || !crtc->state)
  814. return true;
  815. /* reset not required if crtc is active during suspend state */
  816. if (sde_kms_is_suspend_state(crtc->dev) && crtc->state->active)
  817. return false;
  818. return true;
  819. }
  820. /**
  821. * sde_crtc_event_queue - request event callback
  822. * @crtc: Pointer to drm crtc structure
  823. * @func: Pointer to callback function
  824. * @usr: Pointer to user data to be passed to callback
  825. * @color_processing_event: True if color processing event
  826. * Returns: Zero on success
  827. */
  828. int sde_crtc_event_queue(struct drm_crtc *crtc,
  829. void (*func)(struct drm_crtc *crtc, void *usr),
  830. void *usr, bool color_processing_event);
  831. /**
  832. * sde_crtc_get_crtc_roi - retrieve the crtc_roi from the given state object
  833. * used to allow the planes to adjust their final lm out_xy value in the
  834. * case of partial update
  835. * @crtc_state: Pointer to crtc state
  836. * @crtc_roi: Output pointer to crtc roi in the given state
  837. */
  838. void sde_crtc_get_crtc_roi(struct drm_crtc_state *state,
  839. const struct sde_rect **crtc_roi);
  840. /**
  841. * sde_crtc_is_crtc_roi_dirty - retrieve whether crtc_roi was updated this frame
  842. * Note: Only use during atomic_check since dirty properties may be popped
  843. * @crtc_state: Pointer to crtc state
  844. * Return: true if roi is dirty, false otherwise
  845. */
  846. bool sde_crtc_is_crtc_roi_dirty(struct drm_crtc_state *state);
  847. /** sde_crt_get_secure_level - retrieve the secure level from the give state
  848. * object, this is used to determine the secure state of the crtc
  849. * @crtc : Pointer to drm crtc structure
  850. * @usr: Pointer to drm crtc state
  851. * return: secure_level
  852. */
  853. static inline int sde_crtc_get_secure_level(struct drm_crtc *crtc,
  854. struct drm_crtc_state *state)
  855. {
  856. if (!crtc || !state)
  857. return -EINVAL;
  858. return sde_crtc_get_property(to_sde_crtc_state(state),
  859. CRTC_PROP_SECURITY_LEVEL);
  860. }
  861. /** sde_crtc_atomic_check_has_modeset - checks if the new_crtc_state in the
  862. * drm_atomic_state has a modeset
  863. * @state : pointer to drm_atomic_state
  864. * @crtc : Pointer to drm crtc structure
  865. * Returns true if crtc has modeset
  866. */
  867. static inline bool sde_crtc_atomic_check_has_modeset(
  868. struct drm_atomic_state *state, struct drm_crtc *crtc)
  869. {
  870. struct drm_crtc_state *crtc_state;
  871. if (!state || !crtc)
  872. return false;
  873. crtc_state = drm_atomic_get_new_crtc_state(state,
  874. crtc);
  875. return (crtc_state && drm_atomic_crtc_needs_modeset(crtc_state));
  876. }
  877. static inline bool sde_crtc_state_in_clone_mode(struct drm_encoder *encoder,
  878. struct drm_crtc_state *state)
  879. {
  880. struct sde_crtc_state *cstate;
  881. if (!state || !encoder)
  882. return false;
  883. cstate = to_sde_crtc_state(state);
  884. if (sde_encoder_in_clone_mode(encoder) ||
  885. (cstate->cwb_enc_mask & drm_encoder_mask(encoder)))
  886. return true;
  887. return false;
  888. }
  889. /**
  890. * sde_crtc_get_ds_io_res - populates the destination scaler src/dst w/h
  891. * @state: pointer to drm crtc state
  892. * @res: pointer to the output struct to populate the src/dst
  893. */
  894. static inline void sde_crtc_get_ds_io_res(struct drm_crtc_state *state, struct sde_io_res *res)
  895. {
  896. struct sde_crtc_state *cstate;
  897. int i;
  898. if (!state || !res)
  899. return;
  900. cstate = to_sde_crtc_state(state);
  901. memset(res, 0, sizeof(struct sde_io_res));
  902. for (i = 0; i < cstate->num_ds; i++) {
  903. if (cstate->ds_cfg[i].scl3_cfg.enable) {
  904. res->enabled = true;
  905. res->src_w += cstate->ds_cfg[i].lm_width;
  906. res->dst_w += cstate->ds_cfg[i].scl3_cfg.dst_width;
  907. res->src_h = cstate->ds_cfg[i].lm_height;
  908. res->dst_h = cstate->ds_cfg[i].scl3_cfg.dst_height;
  909. }
  910. }
  911. }
  912. /**
  913. * sde_crtc_get_secure_transition - determines the operations to be
  914. * performed before transitioning to secure state
  915. * This function should be called after swapping the new state
  916. * @crtc: Pointer to drm crtc structure
  917. * @old_crtc_state: Poniter to previous CRTC state
  918. * Returns the bitmask of operations need to be performed, -Error in
  919. * case of error cases
  920. */
  921. int sde_crtc_get_secure_transition_ops(struct drm_crtc *crtc,
  922. struct drm_crtc_state *old_crtc_state,
  923. bool old_valid_fb);
  924. /**
  925. * sde_crtc_find_plane_fb_modes - finds the modes of all planes attached
  926. * to crtc
  927. * @crtc: Pointer to DRM crtc object
  928. * @fb_ns: number of non secure planes
  929. * @fb_sec: number of secure-playback planes
  930. * @fb_sec_dir: number of secure-ui/secure-camera planes
  931. */
  932. int sde_crtc_find_plane_fb_modes(struct drm_crtc *crtc,
  933. uint32_t *fb_ns, uint32_t *fb_sec, uint32_t *fb_sec_dir);
  934. /**
  935. * sde_crtc_state_find_plane_fb_modes - finds the modes of all planes attached
  936. * to the crtc state
  937. * @crtc_state: Pointer to DRM crtc state object
  938. * @fb_ns: number of non secure planes
  939. * @fb_sec: number of secure-playback planes
  940. * @fb_sec_dir: number of secure-ui/secure-camera planes
  941. */
  942. int sde_crtc_state_find_plane_fb_modes(struct drm_crtc_state *state,
  943. uint32_t *fb_ns, uint32_t *fb_sec, uint32_t *fb_sec_dir);
  944. /**
  945. * sde_crtc_secure_ctrl - Initiates the transition between secure and
  946. * non-secure world
  947. * @crtc: Pointer to crtc
  948. * @post_commit: if this operation is triggered after commit
  949. */
  950. int sde_crtc_secure_ctrl(struct drm_crtc *crtc, bool post_commit);
  951. /**
  952. * sde_crtc_helper_reset_properties - reset properties to default values in the
  953. * given DRM CRTC state object
  954. * @crtc: Pointer to DRM crtc object
  955. * @crtc_state: Pointer to DRM crtc state object
  956. * Returns: 0 on success, negative errno on failure
  957. */
  958. int sde_crtc_helper_reset_custom_properties(struct drm_crtc *crtc,
  959. struct drm_crtc_state *crtc_state);
  960. /**
  961. * sde_crtc_timeline_status - current buffer timeline status
  962. * @crtc: Pointer to crtc
  963. */
  964. void sde_crtc_timeline_status(struct drm_crtc *crtc);
  965. /**
  966. * sde_crtc_update_cont_splash_settings - update mixer settings
  967. * during device bootup for cont_splash use case
  968. * @crtc: Pointer to drm crtc structure
  969. */
  970. void sde_crtc_update_cont_splash_settings(
  971. struct drm_crtc *crtc);
  972. /**
  973. * sde_crtc_set_qos_dirty - update plane dirty flag to include
  974. * QoS reprogramming which is required during fps switch
  975. * @crtc: Pointer to drm crtc structure
  976. */
  977. void sde_crtc_set_qos_dirty(struct drm_crtc *crtc);
  978. /**
  979. * sde_crtc_misr_setup - to configure and enable/disable MISR
  980. * @crtc: Pointer to drm crtc structure
  981. * @enable: boolean to indicate enable/disable misr
  982. * @frame_count: frame_count to be configured
  983. */
  984. void sde_crtc_misr_setup(struct drm_crtc *crtc, bool enable, u32 frame_count);
  985. /**
  986. * sde_crtc_get_misr_info - to configure and enable/disable MISR
  987. * @crtc: Pointer to drm crtc structure
  988. * @crtc_misr_info: Pointer to crtc misr info structure
  989. */
  990. void sde_crtc_get_misr_info(struct drm_crtc *crtc,
  991. struct sde_crtc_misr_info *crtc_misr_info);
  992. /**
  993. * sde_crtc_set_bpp - set src and target bpp values
  994. * @sde_crtc: Pointer to sde crtc struct
  995. * @src_bpp: source bpp value to be stored
  996. * @target_bpp: target value to be stored
  997. */
  998. static inline void sde_crtc_set_bpp(struct sde_crtc *sde_crtc, int src_bpp,
  999. int target_bpp)
  1000. {
  1001. sde_crtc->src_bpp = src_bpp;
  1002. sde_crtc->target_bpp = target_bpp;
  1003. }
  1004. /**
  1005. * sde_crtc_static_img_control - transition static img cache state
  1006. * @crtc: Pointer to drm crtc structure
  1007. * @state: cache state to transition to
  1008. * @is_vidmode: if encoder is video mode
  1009. */
  1010. void sde_crtc_static_img_control(struct drm_crtc *crtc,
  1011. enum sde_sys_cache_state state, bool is_vidmode);
  1012. /**
  1013. * sde_crtc_static_cache_read_kickoff - kickoff cache read work
  1014. * @crtc: Pointer to drm crtc structure
  1015. */
  1016. void sde_crtc_static_cache_read_kickoff(struct drm_crtc *crtc);
  1017. /**
  1018. * sde_crtc_get_num_datapath - get the number of datapath active
  1019. * of primary connector
  1020. * @crtc: Pointer to DRM crtc object
  1021. * @connector: Pointer to DRM connector object of WB in CWB case
  1022. * @crtc_state: Pointer to DRM crtc state
  1023. */
  1024. int sde_crtc_get_num_datapath(struct drm_crtc *crtc,
  1025. struct drm_connector *connector, struct drm_crtc_state *crtc_state);
  1026. /**
  1027. * sde_crtc_reset_sw_state - reset dirty proerties on crtc and
  1028. * planes attached to the crtc
  1029. * @crtc: Pointer to DRM crtc object
  1030. */
  1031. void sde_crtc_reset_sw_state(struct drm_crtc *crtc);
  1032. /**
  1033. * sde_crtc_disable_cp_features - api to disable cp features that depend on planes being active.
  1034. * Encoder disables the planes during suspend and calls this api for the crtc to disable
  1035. * any features that require planes to be active
  1036. * @crtc: Pointer to DRM crtc object
  1037. */
  1038. void sde_crtc_disable_cp_features(struct drm_crtc *crtc);
  1039. /*
  1040. * _sde_crtc_clear_dim_layers_v1 - clear all dim layer settings
  1041. * @cstate: Pointer to drm crtc state
  1042. */
  1043. void _sde_crtc_clear_dim_layers_v1(struct drm_crtc_state *state);
  1044. /**
  1045. * sde_crtc_cancel_delayed_work - cancel any pending work items for a given crtc
  1046. * @crtc: Pointer to DRM crtc object
  1047. */
  1048. void sde_crtc_cancel_delayed_work(struct drm_crtc *crtc);
  1049. /*
  1050. * sde_crtc_get_src_encoder_of_clone- find source encoder of a clone mode encoder
  1051. * @cstate: Pointer to DRM crtc object
  1052. */
  1053. struct drm_encoder *sde_crtc_get_src_encoder_of_clone(struct drm_crtc *crtc);
  1054. /*
  1055. * _sde_crtc_vm_release_notify- send event to usermode on vm release
  1056. */
  1057. void _sde_crtc_vm_release_notify(struct drm_crtc *crtc);
  1058. /*
  1059. * sde_crtc_is_line_insertion_supported - get lineinsertion
  1060. * feature bit value from panel
  1061. * @drm_crtc: Pointer to drm crtc structure
  1062. * @Return: line insertion support status
  1063. */
  1064. bool sde_crtc_is_line_insertion_supported(struct drm_crtc *crtc);
  1065. /**
  1066. * sde_crtc_calc_vpadding_param - calculate vpadding parameters
  1067. * @state: Pointer to DRM crtc state object
  1068. * @crtc_y: Plane's CRTC_Y offset
  1069. * @crtc_h: Plane's CRTC_H size
  1070. * @padding_y: Padding Y offset
  1071. * @padding_start: Padding start offset
  1072. * @padding_height: Padding height in total
  1073. */
  1074. void sde_crtc_calc_vpadding_param(struct drm_crtc_state *state, u32 crtc_y, u32 crtc_h,
  1075. u32 *padding_y, u32 *padding_start, u32 *padding_height);
  1076. /**
  1077. * sde_crtc_backlight_notify - notify backlight
  1078. * @crtc: Pointer to drm_crtc.
  1079. * @bl_val: Backlight value.
  1080. * @bl_max: Max backlight value.
  1081. */
  1082. void sde_crtc_backlight_notify(struct drm_crtc *crtc, u32 bl_val, u32 bl_max);
  1083. #endif /* _SDE_CRTC_H_ */