sde_plane.h 10 KB

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