sde_drm.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. #ifndef _SDE_DRM_H_
  2. #define _SDE_DRM_H_
  3. #include "drm.h"
  4. /* Total number of supported color planes */
  5. #define SDE_MAX_PLANES 4
  6. /* Total number of parameterized detail enhancer mapping curves */
  7. #define SDE_MAX_DE_CURVES 3
  8. /* Y/RGB and UV filter configuration */
  9. #define FILTER_EDGE_DIRECTED_2D 0x0
  10. #define FILTER_CIRCULAR_2D 0x1
  11. #define FILTER_SEPARABLE_1D 0x2
  12. #define FILTER_BILINEAR 0x3
  13. /* Alpha filters */
  14. #define FILTER_ALPHA_DROP_REPEAT 0x0
  15. #define FILTER_ALPHA_BILINEAR 0x1
  16. #define FILTER_ALPHA_2D 0x3
  17. /* Blend filters */
  18. #define FILTER_BLEND_CIRCULAR_2D 0x0
  19. #define FILTER_BLEND_SEPARABLE_1D 0x1
  20. /* LUT configuration flags */
  21. #define SCALER_LUT_SWAP 0x1
  22. #define SCALER_LUT_DIR_WR 0x2
  23. #define SCALER_LUT_Y_CIR_WR 0x4
  24. #define SCALER_LUT_UV_CIR_WR 0x8
  25. #define SCALER_LUT_Y_SEP_WR 0x10
  26. #define SCALER_LUT_UV_SEP_WR 0x20
  27. /**
  28. * Blend operations for "blend_op" property
  29. *
  30. * @SDE_DRM_BLEND_OP_NOT_DEFINED: No blend operation defined for the layer.
  31. * @SDE_DRM_BLEND_OP_OPAQUE: Apply a constant blend operation. The layer
  32. * would appear opaque in case fg plane alpha
  33. * is 0xff.
  34. * @SDE_DRM_BLEND_OP_PREMULTIPLIED: Apply source over blend rule. Layer already
  35. * has alpha pre-multiplication done. If the fg
  36. * plane alpha is less than 0xff, apply
  37. * modulation as well. This operation is
  38. * intended on layers having alpha channel.
  39. * @SDE_DRM_BLEND_OP_COVERAGE: Apply source over blend rule. Layer is not
  40. * alpha pre-multiplied. Apply
  41. * pre-multiplication. If fg plane alpha is
  42. * less than 0xff, apply modulation as well.
  43. * @SDE_DRM_BLEND_OP_MAX: Used to track maximum blend operation
  44. * possible by mdp.
  45. */
  46. #define SDE_DRM_BLEND_OP_NOT_DEFINED 0
  47. #define SDE_DRM_BLEND_OP_OPAQUE 1
  48. #define SDE_DRM_BLEND_OP_PREMULTIPLIED 2
  49. #define SDE_DRM_BLEND_OP_COVERAGE 3
  50. #define SDE_DRM_BLEND_OP_MAX 4
  51. /**
  52. * Bit masks for "src_config" property
  53. * construct bitmask via (1UL << SDE_DRM_<flag>)
  54. */
  55. #define SDE_DRM_DEINTERLACE 0 /* Specifies interlaced input */
  56. /* DRM bitmasks are restricted to 0..63 */
  57. #define SDE_DRM_BITMASK_COUNT 64
  58. /**
  59. * Framebuffer modes for "fb_translation_mode" PLANE and CONNECTOR property
  60. *
  61. * @SDE_DRM_FB_NON_SEC: IOMMU configuration for this framebuffer mode
  62. * is non-secure domain and requires
  63. * both stage I and stage II translations when
  64. * this buffer is accessed by the display HW.
  65. * This is the default mode of all frambuffers.
  66. * @SDE_DRM_FB_SEC: IOMMU configuration for this framebuffer mode
  67. * is secure domain and requires
  68. * both stage I and stage II translations when
  69. * this buffer is accessed by the display HW.
  70. * @SDE_DRM_FB_NON_SEC_DIR_TRANS: IOMMU configuration for this framebuffer mode
  71. * is non-secure domain and requires
  72. * only stage II translation when
  73. * this buffer is accessed by the display HW.
  74. * @SDE_DRM_FB_SEC_DIR_TRANS: IOMMU configuration for this framebuffer mode
  75. * is secure domain and requires
  76. * only stage II translation when
  77. * this buffer is accessed by the display HW.
  78. */
  79. #define SDE_DRM_FB_NON_SEC 0
  80. #define SDE_DRM_FB_SEC 1
  81. #define SDE_DRM_FB_NON_SEC_DIR_TRANS 2
  82. #define SDE_DRM_FB_SEC_DIR_TRANS 3
  83. /**
  84. * Secure levels for "security_level" CRTC property.
  85. * CRTC property which specifies what plane types
  86. * can be attached to this CRTC. Plane component
  87. * derives the plane type based on the FB_MODE.
  88. * @ SDE_DRM_SEC_NON_SEC: Both Secure and non-secure plane types can be
  89. * attached to this CRTC. This is the default state of
  90. * the CRTC.
  91. * @ SDE_DRM_SEC_ONLY: Only secure planes can be added to this CRTC. If a
  92. * CRTC is instructed to be in this mode it follows the
  93. * platform dependent restrictions.
  94. */
  95. #define SDE_DRM_SEC_NON_SEC 0
  96. #define SDE_DRM_SEC_ONLY 1
  97. /**
  98. * struct sde_drm_pix_ext_v1 - version 1 of pixel ext structure
  99. * @num_ext_pxls_lr: Number of total horizontal pixels
  100. * @num_ext_pxls_tb: Number of total vertical lines
  101. * @left_ftch: Number of extra pixels to overfetch from left
  102. * @right_ftch: Number of extra pixels to overfetch from right
  103. * @top_ftch: Number of extra lines to overfetch from top
  104. * @btm_ftch: Number of extra lines to overfetch from bottom
  105. * @left_rpt: Number of extra pixels to repeat from left
  106. * @right_rpt: Number of extra pixels to repeat from right
  107. * @top_rpt: Number of extra lines to repeat from top
  108. * @btm_rpt: Number of extra lines to repeat from bottom
  109. */
  110. struct sde_drm_pix_ext_v1 {
  111. /*
  112. * Number of pixels ext in left, right, top and bottom direction
  113. * for all color components.
  114. */
  115. int32_t num_ext_pxls_lr[SDE_MAX_PLANES];
  116. int32_t num_ext_pxls_tb[SDE_MAX_PLANES];
  117. /*
  118. * Number of pixels needs to be overfetched in left, right, top
  119. * and bottom directions from source image for scaling.
  120. */
  121. int32_t left_ftch[SDE_MAX_PLANES];
  122. int32_t right_ftch[SDE_MAX_PLANES];
  123. int32_t top_ftch[SDE_MAX_PLANES];
  124. int32_t btm_ftch[SDE_MAX_PLANES];
  125. /*
  126. * Number of pixels needs to be repeated in left, right, top and
  127. * bottom directions for scaling.
  128. */
  129. int32_t left_rpt[SDE_MAX_PLANES];
  130. int32_t right_rpt[SDE_MAX_PLANES];
  131. int32_t top_rpt[SDE_MAX_PLANES];
  132. int32_t btm_rpt[SDE_MAX_PLANES];
  133. };
  134. /**
  135. * struct sde_drm_scaler_v1 - version 1 of struct sde_drm_scaler
  136. * @lr: Pixel extension settings for left/right
  137. * @tb: Pixel extension settings for top/botton
  138. * @init_phase_x: Initial scaler phase values for x
  139. * @phase_step_x: Phase step values for x
  140. * @init_phase_y: Initial scaler phase values for y
  141. * @phase_step_y: Phase step values for y
  142. * @horz_filter: Horizontal filter array
  143. * @vert_filter: Vertical filter array
  144. */
  145. struct sde_drm_scaler_v1 {
  146. /*
  147. * Pix ext settings
  148. */
  149. struct sde_drm_pix_ext_v1 pe;
  150. /*
  151. * Phase settings
  152. */
  153. int32_t init_phase_x[SDE_MAX_PLANES];
  154. int32_t phase_step_x[SDE_MAX_PLANES];
  155. int32_t init_phase_y[SDE_MAX_PLANES];
  156. int32_t phase_step_y[SDE_MAX_PLANES];
  157. /*
  158. * Filter type to be used for scaling in horizontal and vertical
  159. * directions
  160. */
  161. uint32_t horz_filter[SDE_MAX_PLANES];
  162. uint32_t vert_filter[SDE_MAX_PLANES];
  163. };
  164. /**
  165. * struct sde_drm_de_v1 - version 1 of detail enhancer structure
  166. * @enable: Enables/disables detail enhancer
  167. * @sharpen_level1: Sharpening strength for noise
  168. * @sharpen_level2: Sharpening strength for context
  169. * @clip: Clip coefficient
  170. * @limit: Detail enhancer limit factor
  171. * @thr_quiet: Quite zone threshold
  172. * @thr_dieout: Die-out zone threshold
  173. * @thr_low: Linear zone left threshold
  174. * @thr_high: Linear zone right threshold
  175. * @prec_shift: Detail enhancer precision
  176. * @adjust_a: Mapping curves A coefficients
  177. * @adjust_b: Mapping curves B coefficients
  178. * @adjust_c: Mapping curves C coefficients
  179. */
  180. struct sde_drm_de_v1 {
  181. uint32_t enable;
  182. int16_t sharpen_level1;
  183. int16_t sharpen_level2;
  184. uint16_t clip;
  185. uint16_t limit;
  186. uint16_t thr_quiet;
  187. uint16_t thr_dieout;
  188. uint16_t thr_low;
  189. uint16_t thr_high;
  190. uint16_t prec_shift;
  191. int16_t adjust_a[SDE_MAX_DE_CURVES];
  192. int16_t adjust_b[SDE_MAX_DE_CURVES];
  193. int16_t adjust_c[SDE_MAX_DE_CURVES];
  194. };
  195. /**
  196. * struct sde_drm_scaler_v2 - version 2 of struct sde_drm_scaler
  197. * @enable: Scaler enable
  198. * @dir_en: Detail enhancer enable
  199. * @pe: Pixel extension settings
  200. * @horz_decimate: Horizontal decimation factor
  201. * @vert_decimate: Vertical decimation factor
  202. * @init_phase_x: Initial scaler phase values for x
  203. * @phase_step_x: Phase step values for x
  204. * @init_phase_y: Initial scaler phase values for y
  205. * @phase_step_y: Phase step values for y
  206. * @preload_x: Horizontal preload value
  207. * @preload_y: Vertical preload value
  208. * @src_width: Source width
  209. * @src_height: Source height
  210. * @dst_width: Destination width
  211. * @dst_height: Destination height
  212. * @y_rgb_filter_cfg: Y/RGB plane filter configuration
  213. * @uv_filter_cfg: UV plane filter configuration
  214. * @alpha_filter_cfg: Alpha filter configuration
  215. * @blend_cfg: Selection of blend coefficients
  216. * @lut_flag: LUT configuration flags
  217. * @dir_lut_idx: 2d 4x4 LUT index
  218. * @y_rgb_cir_lut_idx: Y/RGB circular LUT index
  219. * @uv_cir_lut_idx: UV circular LUT index
  220. * @y_rgb_sep_lut_idx: Y/RGB separable LUT index
  221. * @uv_sep_lut_idx: UV separable LUT index
  222. * @de: Detail enhancer settings
  223. */
  224. struct sde_drm_scaler_v2 {
  225. /*
  226. * General definitions
  227. */
  228. uint32_t enable;
  229. uint32_t dir_en;
  230. /*
  231. * Pix ext settings
  232. */
  233. struct sde_drm_pix_ext_v1 pe;
  234. /*
  235. * Decimation settings
  236. */
  237. uint32_t horz_decimate;
  238. uint32_t vert_decimate;
  239. /*
  240. * Phase settings
  241. */
  242. int32_t init_phase_x[SDE_MAX_PLANES];
  243. int32_t phase_step_x[SDE_MAX_PLANES];
  244. int32_t init_phase_y[SDE_MAX_PLANES];
  245. int32_t phase_step_y[SDE_MAX_PLANES];
  246. uint32_t preload_x[SDE_MAX_PLANES];
  247. uint32_t preload_y[SDE_MAX_PLANES];
  248. uint32_t src_width[SDE_MAX_PLANES];
  249. uint32_t src_height[SDE_MAX_PLANES];
  250. uint32_t dst_width;
  251. uint32_t dst_height;
  252. uint32_t y_rgb_filter_cfg;
  253. uint32_t uv_filter_cfg;
  254. uint32_t alpha_filter_cfg;
  255. uint32_t blend_cfg;
  256. uint32_t lut_flag;
  257. uint32_t dir_lut_idx;
  258. /* for Y(RGB) and UV planes*/
  259. uint32_t y_rgb_cir_lut_idx;
  260. uint32_t uv_cir_lut_idx;
  261. uint32_t y_rgb_sep_lut_idx;
  262. uint32_t uv_sep_lut_idx;
  263. /*
  264. * Detail enhancer settings
  265. */
  266. struct sde_drm_de_v1 de;
  267. };
  268. /* Number of dest scalers supported */
  269. #define SDE_MAX_DS_COUNT 2
  270. /*
  271. * Destination scaler flag config
  272. */
  273. #define SDE_DRM_DESTSCALER_ENABLE 0x1
  274. #define SDE_DRM_DESTSCALER_SCALE_UPDATE 0x2
  275. #define SDE_DRM_DESTSCALER_ENHANCER_UPDATE 0x4
  276. #define SDE_DRM_DESTSCALER_PU_ENABLE 0x8
  277. /**
  278. * struct sde_drm_dest_scaler_cfg - destination scaler config structure
  279. * @flags: Flag to switch between mode for destination scaler
  280. * refer to destination scaler flag config
  281. * @index: Destination scaler selection index
  282. * @lm_width: Layer mixer width configuration
  283. * @lm_height: Layer mixer height configuration
  284. * @scaler_cfg: The scaling parameters for all the mode except disable
  285. * Userspace pointer to struct sde_drm_scaler_v2
  286. */
  287. struct sde_drm_dest_scaler_cfg {
  288. uint32_t flags;
  289. uint32_t index;
  290. uint32_t lm_width;
  291. uint32_t lm_height;
  292. uint64_t scaler_cfg;
  293. };
  294. /**
  295. * struct sde_drm_dest_scaler_data - destination scaler data struct
  296. * @num_dest_scaler: Number of dest scalers to be configured
  297. * @ds_cfg: Destination scaler block configuration
  298. */
  299. struct sde_drm_dest_scaler_data {
  300. uint32_t num_dest_scaler;
  301. struct sde_drm_dest_scaler_cfg ds_cfg[SDE_MAX_DS_COUNT];
  302. };
  303. /*
  304. * Define constants for struct sde_drm_csc
  305. */
  306. #define SDE_CSC_MATRIX_COEFF_SIZE 9
  307. #define SDE_CSC_CLAMP_SIZE 6
  308. #define SDE_CSC_BIAS_SIZE 3
  309. /**
  310. * struct sde_drm_csc_v1 - version 1 of struct sde_drm_csc
  311. * @ctm_coeff: Matrix coefficients, in S31.32 format
  312. * @pre_bias: Pre-bias array values
  313. * @post_bias: Post-bias array values
  314. * @pre_clamp: Pre-clamp array values
  315. * @post_clamp: Post-clamp array values
  316. */
  317. struct sde_drm_csc_v1 {
  318. int64_t ctm_coeff[SDE_CSC_MATRIX_COEFF_SIZE];
  319. uint32_t pre_bias[SDE_CSC_BIAS_SIZE];
  320. uint32_t post_bias[SDE_CSC_BIAS_SIZE];
  321. uint32_t pre_clamp[SDE_CSC_CLAMP_SIZE];
  322. uint32_t post_clamp[SDE_CSC_CLAMP_SIZE];
  323. };
  324. /**
  325. * struct sde_drm_color - struct to store the color and alpha values
  326. * @color_0: Color 0 value
  327. * @color_1: Color 1 value
  328. * @color_2: Color 2 value
  329. * @color_3: Color 3 value
  330. */
  331. struct sde_drm_color {
  332. uint32_t color_0;
  333. uint32_t color_1;
  334. uint32_t color_2;
  335. uint32_t color_3;
  336. };
  337. /* Total number of supported dim layers */
  338. #define SDE_MAX_DIM_LAYERS 7
  339. /* SDE_DRM_DIM_LAYER_CONFIG_FLAG - flags for Dim Layer */
  340. /* Color fill inside of the rect, including border */
  341. #define SDE_DRM_DIM_LAYER_INCLUSIVE 0x1
  342. /* Color fill outside of the rect, excluding border */
  343. #define SDE_DRM_DIM_LAYER_EXCLUSIVE 0x2
  344. /**
  345. * struct sde_drm_dim_layer - dim layer cfg struct
  346. * @flags: Refer SDE_DRM_DIM_LAYER_CONFIG_FLAG for possible values
  347. * @stage: Blending stage of the dim layer
  348. * @color_fill: Color fill for dim layer
  349. * @rect: Dim layer coordinates
  350. */
  351. struct sde_drm_dim_layer_cfg {
  352. uint32_t flags;
  353. uint32_t stage;
  354. struct sde_drm_color color_fill;
  355. struct drm_clip_rect rect;
  356. };
  357. /**
  358. * struct sde_drm_dim_layer_v1 - version 1 of dim layer struct
  359. * @num_layers: Numer of Dim Layers
  360. * @layer: Dim layer user cfgs ptr for the num_layers
  361. */
  362. struct sde_drm_dim_layer_v1 {
  363. uint32_t num_layers;
  364. struct sde_drm_dim_layer_cfg layer_cfg[SDE_MAX_DIM_LAYERS];
  365. };
  366. /* Writeback Config version definition */
  367. #define SDE_DRM_WB_CFG 0x1
  368. /* SDE_DRM_WB_CONFIG_FLAGS - Writeback configuration flags */
  369. #define SDE_DRM_WB_CFG_FLAGS_CONNECTED (1<<0)
  370. /**
  371. * struct sde_drm_wb_cfg - Writeback configuration structure
  372. * @flags: see DRM_MSM_WB_CONFIG_FLAGS
  373. * @connector_id: writeback connector identifier
  374. * @count_modes: Count of modes in modes_ptr
  375. * @modes: Pointer to struct drm_mode_modeinfo
  376. */
  377. struct sde_drm_wb_cfg {
  378. uint32_t flags;
  379. uint32_t connector_id;
  380. uint32_t count_modes;
  381. uint64_t modes;
  382. };
  383. #define SDE_MAX_ROI_V1 4
  384. /**
  385. * struct sde_drm_roi_v1 - list of regions of interest for a drm object
  386. * @num_rects: number of valid rectangles in the roi array
  387. * @roi: list of roi rectangles
  388. */
  389. struct sde_drm_roi_v1 {
  390. uint32_t num_rects;
  391. struct drm_clip_rect roi[SDE_MAX_ROI_V1];
  392. };
  393. /**
  394. * Define extended power modes supported by the SDE connectors.
  395. */
  396. #define SDE_MODE_DPMS_ON 0
  397. #define SDE_MODE_DPMS_LP1 1
  398. #define SDE_MODE_DPMS_LP2 2
  399. #define SDE_MODE_DPMS_STANDBY 3
  400. #define SDE_MODE_DPMS_SUSPEND 4
  401. #define SDE_MODE_DPMS_OFF 5
  402. #endif /* _SDE_DRM_H_ */