sde_plane.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. /*
  2. * Copyright (c) 2015-2019, 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. /* @sc_cfg: system_cache configuration */
  99. struct sde_hw_pipe_sc_cfg sc_cfg;
  100. uint32_t rotation;
  101. struct sde_hw_pipe_cdp_cfg cdp_cfg;
  102. };
  103. /**
  104. * struct sde_multirect_plane_states: Defines multirect pair of drm plane states
  105. * @r0: drm plane configured on rect 0
  106. * @r1: drm plane configured on rect 1
  107. */
  108. struct sde_multirect_plane_states {
  109. const struct drm_plane_state *r0;
  110. const struct drm_plane_state *r1;
  111. };
  112. #define to_sde_plane_state(x) \
  113. container_of(x, struct sde_plane_state, base)
  114. /**
  115. * sde_plane_get_property - Query integer value of plane property
  116. * @S: Pointer to plane state
  117. * @X: Property index, from enum msm_mdp_plane_property
  118. * Returns: Integer value of requested property
  119. */
  120. #define sde_plane_get_property(S, X) ((S) && ((X) < PLANE_PROP_COUNT) ? \
  121. ((S)->property_values[(X)].value) : 0)
  122. /**
  123. * sde_plane_pipe - return sspp identifier for the given plane
  124. * @plane: Pointer to DRM plane object
  125. * Returns: sspp identifier of the given plane
  126. */
  127. enum sde_sspp sde_plane_pipe(struct drm_plane *plane);
  128. /**
  129. * is_sde_plane_virtual - check for virtual plane
  130. * @plane: Pointer to DRM plane object
  131. * returns: true - if the plane is virtual
  132. * false - if the plane is primary
  133. */
  134. bool is_sde_plane_virtual(struct drm_plane *plane);
  135. /**
  136. * sde_plane_ctl_flush - set/clear control flush mask
  137. * @plane: Pointer to DRM plane object
  138. * @ctl: Pointer to control hardware
  139. * @set: set if true else clear
  140. */
  141. void sde_plane_ctl_flush(struct drm_plane *plane, struct sde_hw_ctl *ctl,
  142. bool set);
  143. /**
  144. * sde_plane_restore - restore hw state if previously power collapsed
  145. * @plane: Pointer to drm plane structure
  146. */
  147. void sde_plane_restore(struct drm_plane *plane);
  148. /**
  149. * sde_plane_flush - final plane operations before commit flush
  150. * @plane: Pointer to drm plane structure
  151. */
  152. void sde_plane_flush(struct drm_plane *plane);
  153. /**
  154. * sde_plane_halt_requests - control halting of vbif transactions for this plane
  155. * This function isn't thread safe. Plane halt enable/disable requests
  156. * should always be made from the same commit cycle.
  157. * @plane: Pointer to drm plane structure
  158. * @enable: Whether to enable/disable halting of vbif transactions
  159. */
  160. void sde_plane_halt_requests(struct drm_plane *plane, bool enable);
  161. /**
  162. * sde_plane_set_error: enable/disable error condition
  163. * @plane: pointer to drm_plane structure
  164. */
  165. void sde_plane_set_error(struct drm_plane *plane, bool error);
  166. /**
  167. * sde_plane_init - create new sde plane for the given pipe
  168. * @dev: Pointer to DRM device
  169. * @pipe: sde hardware pipe identifier
  170. * @primary_plane: true if this pipe is primary plane for crtc
  171. * @possible_crtcs: bitmask of crtc that can be attached to the given pipe
  172. * @master_plane_id: primary plane id of a multirect pipe. 0 value passed for
  173. * a regular plane initialization. A non-zero primary plane
  174. * id will be passed for a virtual pipe initialization.
  175. *
  176. */
  177. struct drm_plane *sde_plane_init(struct drm_device *dev,
  178. uint32_t pipe, bool primary_plane,
  179. unsigned long possible_crtcs, u32 master_plane_id);
  180. /**
  181. * sde_plane_validate_multirecti_v2 - validate the multirect planes
  182. * against hw limitations
  183. * @plane: drm plate states of the multirect pair
  184. */
  185. int sde_plane_validate_multirect_v2(struct sde_multirect_plane_states *plane);
  186. /**
  187. * sde_plane_clear_multirect - clear multirect bits for the given pipe
  188. * @drm_state: Pointer to DRM plane state
  189. */
  190. void sde_plane_clear_multirect(const struct drm_plane_state *drm_state);
  191. /**
  192. * sde_plane_validate_src_addr - validate if current sspp addr of given
  193. * plane is within the input address range
  194. * @drm_plane: Pointer to DRM plane object
  195. * @base_addr: Start address of the input address range
  196. * @size: Size of the input address range
  197. * @Return: Non-zero if source pipe current address is not in input range
  198. */
  199. int sde_plane_validate_src_addr(struct drm_plane *plane,
  200. unsigned long base_addr, u32 size);
  201. /**
  202. * sde_plane_wait_input_fence - wait for input fence object
  203. * @plane: Pointer to DRM plane object
  204. * @wait_ms: Wait timeout value
  205. * Returns: Zero on success
  206. */
  207. int sde_plane_wait_input_fence(struct drm_plane *plane, uint32_t wait_ms);
  208. /**
  209. * sde_plane_color_fill - enables color fill on plane
  210. * @plane: Pointer to DRM plane object
  211. * @color: RGB fill color value, [23..16] Blue, [15..8] Green, [7..0] Red
  212. * @alpha: 8-bit fill alpha value, 255 selects 100% alpha
  213. * Returns: 0 on success
  214. */
  215. int sde_plane_color_fill(struct drm_plane *plane,
  216. uint32_t color, uint32_t alpha);
  217. /**
  218. * sde_plane_set_revalidate - sets revalidate flag which forces a full
  219. * validation of the plane properties in the next atomic check
  220. * @plane: Pointer to DRM plane object
  221. * @enable: Boolean to set/unset the flag
  222. */
  223. void sde_plane_set_revalidate(struct drm_plane *plane, bool enable);
  224. /**
  225. * sde_plane_helper_reset_properties - reset properties to default values in the
  226. * given DRM plane state object
  227. * @plane: Pointer to DRM plane object
  228. * @plane_state: Pointer to DRM plane state object
  229. * Returns: 0 on success, negative errno on failure
  230. */
  231. int sde_plane_helper_reset_custom_properties(struct drm_plane *plane,
  232. struct drm_plane_state *plane_state);
  233. /* sde_plane_is_sec_ui_allowed - indicates if the sspp allows secure-ui layers
  234. * @plane: Pointer to DRM plane object
  235. * Returns: true if allowed; false otherwise
  236. */
  237. bool sde_plane_is_sec_ui_allowed(struct drm_plane *plane);
  238. /* sde_plane_secure_ctrl_xin_client - controls the VBIF programming of
  239. * the xin-client before the secure-ui session. Programs the QOS
  240. * and OT limits in VBIF for the sec-ui allowed xins
  241. * @plane: Pointer to DRM plane object
  242. * @crtc: Pointer to DRM CRTC state object
  243. */
  244. void sde_plane_secure_ctrl_xin_client(struct drm_plane *plane,
  245. struct drm_crtc *crtc);
  246. /*
  247. * sde_plane_get_ubwc_error - gets the ubwc error code
  248. * @plane: Pointer to DRM plane object
  249. */
  250. u32 sde_plane_get_ubwc_error(struct drm_plane *plane);
  251. /*
  252. * sde_plane_clear_ubwc_error - clears the ubwc error code
  253. * @plane: Pointer to DRM plane object
  254. */
  255. void sde_plane_clear_ubwc_error(struct drm_plane *plane);
  256. /*
  257. * sde_plane_setup_src_split_order - enable/disable pipe's src_split_order
  258. * @plane: Pointer to DRM plane object
  259. * @rect_mode: multirect mode
  260. * @enable: enable/disable flag
  261. */
  262. void sde_plane_setup_src_split_order(struct drm_plane *plane,
  263. enum sde_sspp_multirect_index rect_mode, bool enable);
  264. /* sde_plane_is_cache_required - indicates if the system cache is
  265. * required for the plane.
  266. * @plane: Pointer to DRM plane object
  267. * Returns: true if sys cache is required, otherwise false.
  268. */
  269. bool sde_plane_is_cache_required(struct drm_plane *plane);
  270. #endif /* _SDE_PLANE_H_ */