sde_plane.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. /*
  2. * Copyright (c) 2022-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_PLANE_H_
  20. #define _SDE_PLANE_H_
  21. #include <drm/drm_crtc.h>
  22. #include "msm_prop.h"
  23. #include "sde_kms.h"
  24. #include "sde_hw_mdss.h"
  25. #include "sde_hw_sspp.h"
  26. #include "sde_crtc.h"
  27. /* dirty bits for update function */
  28. #define SDE_PLANE_DIRTY_RECTS 0x1
  29. #define SDE_PLANE_DIRTY_FORMAT 0x2
  30. #define SDE_PLANE_DIRTY_SHARPEN 0x4
  31. #define SDE_PLANE_DIRTY_PERF 0x8
  32. #define SDE_PLANE_DIRTY_FB_TRANSLATION_MODE 0x10
  33. #define SDE_PLANE_DIRTY_VIG_GAMUT 0x20
  34. #define SDE_PLANE_DIRTY_VIG_IGC 0x40
  35. #define SDE_PLANE_DIRTY_DMA_IGC 0x80
  36. #define SDE_PLANE_DIRTY_DMA_GC 0x100
  37. #define SDE_PLANE_DIRTY_QOS 0x200
  38. #define SDE_PLANE_DIRTY_FP16_IGC 0x400
  39. #define SDE_PLANE_DIRTY_FP16_GC 0x800
  40. #define SDE_PLANE_DIRTY_FP16_CSC 0x1000
  41. #define SDE_PLANE_DIRTY_FP16_UNMULT 0x2000
  42. #define SDE_PLANE_DIRTY_UCSC_IGC 0x4000
  43. #define SDE_PLANE_DIRTY_UCSC_GC 0x8000
  44. #define SDE_PLANE_DIRTY_UCSC_CSC 0x10000
  45. #define SDE_PLANE_DIRTY_UCSC_UNMULT 0x20000
  46. #define SDE_PLANE_DIRTY_UCSC_ALPHA_DITHER 0x40000
  47. #define SDE_PLANE_DIRTY_CP (SDE_PLANE_DIRTY_VIG_GAMUT |\
  48. SDE_PLANE_DIRTY_VIG_IGC | SDE_PLANE_DIRTY_DMA_IGC |\
  49. SDE_PLANE_DIRTY_DMA_GC | SDE_PLANE_DIRTY_FP16_IGC |\
  50. SDE_PLANE_DIRTY_FP16_GC | SDE_PLANE_DIRTY_FP16_CSC |\
  51. SDE_PLANE_DIRTY_FP16_UNMULT | SDE_PLANE_DIRTY_UCSC_IGC |\
  52. SDE_PLANE_DIRTY_UCSC_GC | SDE_PLANE_DIRTY_UCSC_CSC |\
  53. SDE_PLANE_DIRTY_UCSC_UNMULT | SDE_PLANE_DIRTY_UCSC_ALPHA_DITHER)
  54. #define SDE_PLANE_DIRTY_ALL (0xFFFFFFFF & ~(SDE_PLANE_DIRTY_CP))
  55. struct sde_plane {
  56. struct drm_plane base;
  57. struct mutex lock;
  58. enum sde_sspp pipe;
  59. uint64_t features; /* capabilities from catalog */
  60. uint32_t perf_features; /* perf capabilities from catalog */
  61. uint32_t nformats;
  62. uint32_t formats[64];
  63. struct sde_hw_pipe *pipe_hw;
  64. struct sde_hw_pipe_cfg pipe_cfg;
  65. struct sde_hw_sharp_cfg sharp_cfg;
  66. struct sde_hw_pipe_qos_cfg pipe_qos_cfg;
  67. uint32_t color_fill;
  68. bool is_error;
  69. bool is_rt_pipe;
  70. enum sde_wb_usage_type wb_usage_type;
  71. bool is_virtual;
  72. struct list_head mplane_list;
  73. struct sde_mdss_cfg *catalog;
  74. bool revalidate;
  75. bool xin_halt_forced_clk;
  76. uint32_t cached_lut_flag;
  77. struct sde_hw_scaler3_cfg scaler3_cfg;
  78. struct sde_hw_pixel_ext pixel_ext;
  79. const struct sde_sspp_sub_blks *pipe_sblk;
  80. char pipe_name[SDE_NAME_SIZE];
  81. struct msm_property_info property_info;
  82. struct msm_property_data property_data[PLANE_PROP_COUNT];
  83. struct drm_property_blob *blob_info;
  84. struct drm_property_blob *blob_rot_caps;
  85. /* debugfs related stuff */
  86. struct dentry *debugfs_root;
  87. bool debugfs_default_scale;
  88. };
  89. #define to_sde_plane(x) container_of(x, struct sde_plane, base)
  90. /**
  91. * enum sde_layout
  92. * Describes SSPP to LM staging layout when using more than 1 pair of LMs
  93. * @SDE_LAYOUT_NONE : SSPPs to LMs staging layout not enabled
  94. * @SDE_LAYOUT_LEFT : SSPPs will be staged on left two LMs
  95. * @SDE_LAYOUT_RIGHT : SSPPs will be staged on right two LMs
  96. * @SDE_LAYOUT_MAX :
  97. */
  98. enum sde_layout {
  99. SDE_LAYOUT_NONE = 0,
  100. SDE_LAYOUT_LEFT,
  101. SDE_LAYOUT_RIGHT,
  102. SDE_LAYOUT_MAX,
  103. };
  104. /**
  105. * enum sde_plane_sclcheck_state - User scaler data status
  106. *
  107. * @SDE_PLANE_SCLCHECK_NONE: No user data provided
  108. * @SDE_PLANE_SCLCHECK_INVALID: Invalid user data provided
  109. * @SDE_PLANE_SCLCHECK_SCALER_V1: Valid scaler v1 data
  110. * @SDE_PLANE_SCLCHECK_SCALER_V1_CHECK: Unchecked scaler v1 data
  111. * @SDE_PLANE_SCLCHECK_SCALER_V2: Valid scaler v2 data
  112. * @SDE_PLANE_SCLCHECK_SCALER_V2_CHECK: Unchecked scaler v2 data
  113. */
  114. enum sde_plane_sclcheck_state {
  115. SDE_PLANE_SCLCHECK_NONE,
  116. SDE_PLANE_SCLCHECK_INVALID,
  117. SDE_PLANE_SCLCHECK_SCALER_V1,
  118. SDE_PLANE_SCLCHECK_SCALER_V1_CHECK,
  119. SDE_PLANE_SCLCHECK_SCALER_V2,
  120. SDE_PLANE_SCLCHECK_SCALER_V2_CHECK,
  121. };
  122. /**
  123. * struct sde_plane_state: Define sde extension of drm plane state object
  124. * @base: base drm plane state object
  125. * @property_state: Local storage for msm_prop properties
  126. * @property_values: cached plane property values
  127. * @aspace: pointer to address space for input/output buffers
  128. * @input_fence: dereferenced input fence pointer
  129. * @stage: assigned by crtc blender
  130. * @excl_rect: exclusion rect values
  131. * @dirty: bitmask for which pipe h/w config functions need to be updated
  132. * @multirect_index: index of the rectangle of SSPP
  133. * @multirect_mode: parallel or time multiplex multirect mode
  134. * @const_alpha_en: const alpha channel is enabled for this HW pipe
  135. * @pending: whether the current update is still pending
  136. * @defer_prepare_fb: indicate if prepare_fb call was deferred
  137. * @pipe_order_flags: contains pipe order flags:
  138. * SDE_SSPP_RIGHT - right pipe in source split pair
  139. * @layout_offset: horizontal layout offset for global coordinate
  140. * @layout: layout for topology requiring more than 1 lm pair.
  141. * @scaler3_cfg: configuration data for scaler3
  142. * @pixel_ext: configuration data for pixel extensions
  143. * @scaler_check_state: indicates status of user provided pixel extension data
  144. * @pre_down: pre down scale configuration
  145. * @sc_cfg: system cache configuration
  146. * @rotation: rotation cache state
  147. * @static_cache_state: plane cache state for static image
  148. * @cdp_cfg: CDP configuration
  149. * @cont_splash_populated: State was populated as part of cont. splash
  150. * @ubwc_stats_roi: cached roi for ubwc stats
  151. * @line_insertion_cfg: line insertion configuration
  152. * @lineinsertion_feature: panel line insertion feature
  153. * @csc_cfg: csc configuration for pipe
  154. * @csc_usr_ptr: valid user override configuration for csc
  155. * @csc_ptr: default csc configuration
  156. */
  157. struct sde_plane_state {
  158. struct drm_plane_state base;
  159. struct msm_property_state property_state;
  160. struct msm_property_value property_values[PLANE_PROP_COUNT];
  161. struct msm_gem_address_space *aspace;
  162. void *input_fence;
  163. enum sde_stage stage;
  164. struct sde_rect excl_rect;
  165. uint32_t dirty;
  166. uint32_t multirect_index;
  167. uint32_t multirect_mode;
  168. bool const_alpha_en;
  169. bool pending;
  170. bool defer_prepare_fb;
  171. uint32_t pipe_order_flags;
  172. int layout_offset;
  173. enum sde_layout layout;
  174. /* scaler configuration */
  175. struct sde_hw_scaler3_cfg scaler3_cfg;
  176. struct sde_hw_pixel_ext pixel_ext;
  177. enum sde_plane_sclcheck_state scaler_check_state;
  178. struct sde_hw_inline_pre_downscale_cfg pre_down;
  179. /* @sc_cfg: system_cache configuration */
  180. struct sde_hw_pipe_sc_cfg sc_cfg;
  181. uint32_t rotation;
  182. uint32_t static_cache_state;
  183. uint32_t static_cache_type;
  184. struct sde_hw_pipe_cdp_cfg cdp_cfg;
  185. bool cont_splash_populated;
  186. struct sde_drm_ubwc_stats_roi ubwc_stats_roi;
  187. struct sde_hw_pipe_line_insertion_cfg line_insertion_cfg;
  188. bool lineinsertion_feature;
  189. struct sde_csc_cfg csc_cfg;
  190. struct sde_csc_cfg *csc_usr_ptr;
  191. struct sde_csc_cfg *csc_ptr;
  192. };
  193. /**
  194. * struct sde_multirect_plane_states: Defines multirect pair of drm plane states
  195. * @r0: drm plane configured on rect 0
  196. * @r1: drm plane configured on rect 1
  197. */
  198. struct sde_multirect_plane_states {
  199. const struct drm_plane_state *r0;
  200. const struct drm_plane_state *r1;
  201. };
  202. #define to_sde_plane_state(x) \
  203. container_of(x, struct sde_plane_state, base)
  204. /**
  205. * sde_plane_get_property - Query integer value of plane property
  206. * @S: Pointer to plane state
  207. * @X: Property index, from enum msm_mdp_plane_property
  208. * Returns: Integer value of requested property
  209. */
  210. #define sde_plane_get_property(S, X) ((S) && ((X) < PLANE_PROP_COUNT) ? \
  211. ((S)->property_values[(X)].value) : 0)
  212. /**
  213. * sde_plane_destroy_fb - destroy fb object and clear fb
  214. * @state: old plane state
  215. */
  216. void sde_plane_destroy_fb(struct drm_plane_state *state);
  217. /**
  218. * sde_plane_pipe - return sspp identifier for the given plane
  219. * @plane: Pointer to DRM plane object
  220. * Returns: sspp identifier of the given plane
  221. */
  222. enum sde_sspp sde_plane_pipe(struct drm_plane *plane);
  223. /**
  224. * is_sde_plane_virtual - check for virtual plane
  225. * @plane: Pointer to DRM plane object
  226. * returns: true - if the plane is virtual
  227. * false - if the plane is primary
  228. */
  229. bool is_sde_plane_virtual(struct drm_plane *plane);
  230. /**
  231. * sde_plane_ctl_flush - set/clear control flush mask
  232. * @plane: Pointer to DRM plane object
  233. * @ctl: Pointer to control hardware
  234. * @set: set if true else clear
  235. */
  236. void sde_plane_ctl_flush(struct drm_plane *plane, struct sde_hw_ctl *ctl,
  237. bool set);
  238. /**
  239. * sde_plane_restore - restore hw state if previously power collapsed
  240. * @plane: Pointer to drm plane structure
  241. */
  242. void sde_plane_restore(struct drm_plane *plane);
  243. /**
  244. * sde_plane_flush - final plane operations before commit flush
  245. * @plane: Pointer to drm plane structure
  246. */
  247. void sde_plane_flush(struct drm_plane *plane);
  248. /**
  249. * sde_plane_halt_requests - control halting of vbif transactions for this plane
  250. * This function isn't thread safe. Plane halt enable/disable requests
  251. * should always be made from the same commit cycle.
  252. * @plane: Pointer to drm plane structure
  253. * @enable: Whether to enable/disable halting of vbif transactions
  254. */
  255. void sde_plane_halt_requests(struct drm_plane *plane, bool enable);
  256. /**
  257. * sde_plane_set_error: enable/disable error condition
  258. * @plane: pointer to drm_plane structure
  259. */
  260. void sde_plane_set_error(struct drm_plane *plane, bool error);
  261. /**
  262. * sde_plane_init - create new sde plane for the given pipe
  263. * @dev: Pointer to DRM device
  264. * @pipe: sde hardware pipe identifier
  265. * @primary_plane: true if this pipe is primary plane for crtc
  266. * @possible_crtcs: bitmask of crtc that can be attached to the given pipe
  267. * @master_plane_id: primary plane id of a multirect pipe. 0 value passed for
  268. * a regular plane initialization. A non-zero primary plane
  269. * id will be passed for a virtual pipe initialization.
  270. *
  271. */
  272. struct drm_plane *sde_plane_init(struct drm_device *dev,
  273. uint32_t pipe, bool primary_plane,
  274. unsigned long possible_crtcs, u32 master_plane_id);
  275. /**
  276. * sde_plane_validate_multirecti_v2 - validate the multirect planes
  277. * against hw limitations
  278. * @plane: drm plate states of the multirect pair
  279. */
  280. int sde_plane_validate_multirect_v2(struct sde_multirect_plane_states *plane);
  281. /**
  282. * sde_plane_clear_multirect - clear multirect bits for the given pipe
  283. * @drm_state: Pointer to DRM plane state
  284. */
  285. void sde_plane_clear_multirect(const struct drm_plane_state *drm_state);
  286. /**
  287. * sde_plane_validate_src_addr - validate if current sspp addr of given
  288. * plane is within the input address range
  289. * @drm_plane: Pointer to DRM plane object
  290. * @base_addr: Start address of the input address range
  291. * @size: Size of the input address range
  292. * @Return: Non-zero if source pipe current address is not in input range
  293. */
  294. int sde_plane_validate_src_addr(struct drm_plane *plane,
  295. unsigned long base_addr, u32 size);
  296. /**
  297. * sde_plane_wait_input_fence - wait for input fence object
  298. * @plane: Pointer to DRM plane object
  299. * @wait_ms: Wait timeout value
  300. * @error_status: Status of input fence
  301. * Returns: Zero on success
  302. */
  303. int sde_plane_wait_input_fence(struct drm_plane *plane, uint32_t wait_ms, int *error_status);
  304. /**
  305. * sde_plane_color_fill - enables color fill on plane
  306. * @plane: Pointer to DRM plane object
  307. * @color: RGB fill color value, [23..16] Blue, [15..8] Green, [7..0] Red
  308. * @alpha: 8-bit fill alpha value, 255 selects 100% alpha
  309. * Returns: 0 on success
  310. */
  311. int sde_plane_color_fill(struct drm_plane *plane,
  312. uint32_t color, uint32_t alpha);
  313. /**
  314. * sde_plane_set_revalidate - sets revalidate flag which forces a full
  315. * validation of the plane properties in the next atomic check
  316. * @plane: Pointer to DRM plane object
  317. * @enable: Boolean to set/unset the flag
  318. */
  319. void sde_plane_set_revalidate(struct drm_plane *plane, bool enable);
  320. /**
  321. * sde_plane_helper_reset_properties - reset properties to default values in the
  322. * given DRM plane state object
  323. * @plane: Pointer to DRM plane object
  324. * @plane_state: Pointer to DRM plane state object
  325. * Returns: 0 on success, negative errno on failure
  326. */
  327. int sde_plane_helper_reset_custom_properties(struct drm_plane *plane,
  328. struct drm_plane_state *plane_state);
  329. /* sde_plane_is_sec_ui_allowed - indicates if the sspp allows secure-ui layers
  330. * @plane: Pointer to DRM plane object
  331. * Returns: true if allowed; false otherwise
  332. */
  333. bool sde_plane_is_sec_ui_allowed(struct drm_plane *plane);
  334. /* sde_plane_secure_ctrl_xin_client - controls the VBIF programming of
  335. * the xin-client before the secure-ui session. Programs the QOS
  336. * and OT limits in VBIF for the sec-ui allowed xins
  337. * @plane: Pointer to DRM plane object
  338. * @crtc: Pointer to DRM CRTC state object
  339. */
  340. void sde_plane_secure_ctrl_xin_client(struct drm_plane *plane,
  341. struct drm_crtc *crtc);
  342. /*
  343. * sde_plane_get_frame_data - gets the plane frame data
  344. * @plane: Pointer to DRM plane object
  345. * @frame_data: Pointer to plane frame data structure
  346. */
  347. void sde_plane_get_frame_data(struct drm_plane *plane,
  348. struct sde_drm_plane_frame_data *frame_data);
  349. /*
  350. * sde_plane_setup_src_split_order - enable/disable pipe's src_split_order
  351. * @plane: Pointer to DRM plane object
  352. * @rect_mode: multirect mode
  353. * @enable: enable/disable flag
  354. */
  355. void sde_plane_setup_src_split_order(struct drm_plane *plane,
  356. enum sde_sspp_multirect_index rect_mode, bool enable);
  357. /*
  358. * sde_plane_set_sid - set VM SID for the plane
  359. * @plane: Pointer to DRM plane object
  360. * @vm: VM id
  361. */
  362. void sde_plane_set_sid(struct drm_plane *plane, u32 vm);
  363. /* sde_plane_is_cache_required - indicates if the system cache is
  364. * required for the plane.
  365. * @plane: Pointer to DRM plane object
  366. * @type: sys cache type
  367. * Returns: true if sys cache is required, otherwise false.
  368. */
  369. bool sde_plane_is_cache_required(struct drm_plane *plane,
  370. enum sde_sys_cache_type type);
  371. /**
  372. * sde_plane_static_img_control - Switch the static image state
  373. * @plane: Pointer to drm plane structure
  374. * @state: state to set
  375. * @type: cache type to set
  376. */
  377. void sde_plane_static_img_control(struct drm_plane *plane,
  378. enum sde_sys_cache_state state, enum sde_sys_cache_type type);
  379. void sde_plane_add_data_to_minidump_va(struct drm_plane *plane);
  380. /**
  381. * sde_plane_dump_input_fence - dumps plane input fence info
  382. * @plane: Pointer to drm plane structure with the input fence we want to dump
  383. */
  384. void sde_plane_dump_input_fence(struct drm_plane *plane);
  385. /**
  386. * sde_plane_is_sw_fence_signaled - determine if the sw input dma-fence is signaled
  387. * @plane: Pointer to drm plane structure with the input fence to check
  388. * Returns: true if the input sw fence is signaled, otherwise false.
  389. */
  390. bool sde_plane_is_sw_fence_signaled(struct drm_plane *plane);
  391. #endif /* _SDE_PLANE_H_ */