sde_plane.h 14 KB

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