sde_plane.h 12 KB

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