sde_crtc.h 39 KB

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