sde_plane.h 13 KB

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