sde_plane.h 10 KB

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