sde_plane.h 11 KB

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