sde_drm.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851
  1. /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
  2. /*
  3. * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _SDE_DRM_H_
  6. #define _SDE_DRM_H_
  7. #include <drm/drm.h>
  8. #if defined(__cplusplus)
  9. extern "C" {
  10. #endif
  11. /* Total number of supported color planes */
  12. #define SDE_MAX_PLANES 4
  13. /* Total number of parameterized detail enhancer mapping curves */
  14. #define SDE_MAX_DE_CURVES 3
  15. /* Y/RGB and UV filter configuration */
  16. #define FILTER_EDGE_DIRECTED_2D 0x0
  17. #define FILTER_CIRCULAR_2D 0x1
  18. #define FILTER_SEPARABLE_1D 0x2
  19. #define FILTER_BILINEAR 0x3
  20. /* Alpha filters */
  21. #define FILTER_ALPHA_DROP_REPEAT 0x0
  22. #define FILTER_ALPHA_BILINEAR 0x1
  23. #define FILTER_ALPHA_2D 0x3
  24. /* Blend filters */
  25. #define FILTER_BLEND_CIRCULAR_2D 0x0
  26. #define FILTER_BLEND_SEPARABLE_1D 0x1
  27. /* LUT configuration flags */
  28. #define SCALER_LUT_SWAP 0x1
  29. #define SCALER_LUT_DIR_WR 0x2
  30. #define SCALER_LUT_Y_CIR_WR 0x4
  31. #define SCALER_LUT_UV_CIR_WR 0x8
  32. #define SCALER_LUT_Y_SEP_WR 0x10
  33. #define SCALER_LUT_UV_SEP_WR 0x20
  34. /**
  35. * DRM format modifier tokens
  36. *
  37. * @DRM_FORMAT_MOD_QCOM_DX: Refers to a DX variant of the base format.
  38. * Implementation may be platform and
  39. * base-format specific.
  40. */
  41. #define DRM_FORMAT_MOD_QCOM_DX fourcc_mod_code(QCOM, 0x2)
  42. /**
  43. * @DRM_FORMAT_MOD_QCOM_TIGHT: Refers to a tightly packed variant of the
  44. * base variant. Implementation may be
  45. * platform and base-format specific.
  46. */
  47. #define DRM_FORMAT_MOD_QCOM_TIGHT fourcc_mod_code(QCOM, 0x4)
  48. /**
  49. * @DRM_FORMAT_MOD_QCOM_TILE: Refers to a tile variant of the base format.
  50. * Implementation may be platform and
  51. * base-format specific.
  52. */
  53. #define DRM_FORMAT_MOD_QCOM_TILE fourcc_mod_code(QCOM, 0x8)
  54. /**
  55. * @DRM_FORMAT_MOD_QCOM_ALPHA_SWAP: Refers to a pixel format for which
  56. * its alpha ordering has been reversed.
  57. * Implementation may be platform and
  58. * base-format specific.
  59. */
  60. #define DRM_FORMAT_MOD_QCOM_ALPHA_SWAP fourcc_mod_code(QCOM, 0x10)
  61. /**
  62. * Blend operations for "blend_op" property
  63. *
  64. * @SDE_DRM_BLEND_OP_NOT_DEFINED: No blend operation defined for the layer.
  65. * @SDE_DRM_BLEND_OP_OPAQUE: Apply a constant blend operation. The layer
  66. * would appear opaque in case fg plane alpha
  67. * is 0xff.
  68. * @SDE_DRM_BLEND_OP_PREMULTIPLIED: Apply source over blend rule. Layer already
  69. * has alpha pre-multiplication done. If the fg
  70. * plane alpha is less than 0xff, apply
  71. * modulation as well. This operation is
  72. * intended on layers having alpha channel.
  73. * @SDE_DRM_BLEND_OP_COVERAGE: Apply source over blend rule. Layer is not
  74. * alpha pre-multiplied. Apply
  75. * pre-multiplication. If fg plane alpha is
  76. * less than 0xff, apply modulation as well.
  77. * @SDE_DRM_BLEND_OP_MAX: Used to track maximum blend operation
  78. * possible by mdp.
  79. * @SDE_DRM_BLEND_OP_SKIP: Skip staging the layer in the layer mixer.
  80. */
  81. #define SDE_DRM_BLEND_OP_NOT_DEFINED 0
  82. #define SDE_DRM_BLEND_OP_OPAQUE 1
  83. #define SDE_DRM_BLEND_OP_PREMULTIPLIED 2
  84. #define SDE_DRM_BLEND_OP_COVERAGE 3
  85. #define SDE_DRM_BLEND_OP_MAX 4
  86. #define SDE_DRM_BLEND_OP_SKIP 5
  87. /**
  88. * Bit masks for "src_config" property
  89. * construct bitmask via (1UL << SDE_DRM_<flag>)
  90. */
  91. #define SDE_DRM_DEINTERLACE 0 /* Specifies interlaced input */
  92. /* DRM bitmasks are restricted to 0..63 */
  93. #define SDE_DRM_BITMASK_COUNT 64
  94. /**
  95. * Framebuffer modes for "fb_translation_mode" PLANE and CONNECTOR property
  96. *
  97. * @SDE_DRM_FB_NON_SEC: IOMMU configuration for this framebuffer mode
  98. * is non-secure domain and requires
  99. * both stage I and stage II translations when
  100. * this buffer is accessed by the display HW.
  101. * This is the default mode of all frambuffers.
  102. * @SDE_DRM_FB_SEC: IOMMU configuration for this framebuffer mode
  103. * is secure domain and requires
  104. * both stage I and stage II translations when
  105. * this buffer is accessed by the display HW.
  106. * @SDE_DRM_FB_NON_SEC_DIR_TRANS: IOMMU configuration for this framebuffer mode
  107. * is non-secure domain and requires
  108. * only stage II translation when
  109. * this buffer is accessed by the display HW.
  110. * @SDE_DRM_FB_SEC_DIR_TRANS: IOMMU configuration for this framebuffer mode
  111. * is secure domain and requires
  112. * only stage II translation when
  113. * this buffer is accessed by the display HW.
  114. */
  115. #define SDE_DRM_FB_NON_SEC 0
  116. #define SDE_DRM_FB_SEC 1
  117. #define SDE_DRM_FB_NON_SEC_DIR_TRANS 2
  118. #define SDE_DRM_FB_SEC_DIR_TRANS 3
  119. /**
  120. * Secure levels for "security_level" CRTC property.
  121. * CRTC property which specifies what plane types
  122. * can be attached to this CRTC. Plane component
  123. * derives the plane type based on the FB_MODE.
  124. * @ SDE_DRM_SEC_NON_SEC: Both Secure and non-secure plane types can be
  125. * attached to this CRTC. This is the default state of
  126. * the CRTC.
  127. * @ SDE_DRM_SEC_ONLY: Only secure planes can be added to this CRTC. If a
  128. * CRTC is instructed to be in this mode it follows the
  129. * platform dependent restrictions.
  130. */
  131. #define SDE_DRM_SEC_NON_SEC 0
  132. #define SDE_DRM_SEC_ONLY 1
  133. /**
  134. * struct sde_drm_pix_ext_v1 - version 1 of pixel ext structure
  135. * @num_ext_pxls_lr: Number of total horizontal pixels
  136. * @num_ext_pxls_tb: Number of total vertical lines
  137. * @left_ftch: Number of extra pixels to overfetch from left
  138. * @right_ftch: Number of extra pixels to overfetch from right
  139. * @top_ftch: Number of extra lines to overfetch from top
  140. * @btm_ftch: Number of extra lines to overfetch from bottom
  141. * @left_rpt: Number of extra pixels to repeat from left
  142. * @right_rpt: Number of extra pixels to repeat from right
  143. * @top_rpt: Number of extra lines to repeat from top
  144. * @btm_rpt: Number of extra lines to repeat from bottom
  145. */
  146. struct sde_drm_pix_ext_v1 {
  147. /*
  148. * Number of pixels ext in left, right, top and bottom direction
  149. * for all color components.
  150. */
  151. __s32 num_ext_pxls_lr[SDE_MAX_PLANES];
  152. __s32 num_ext_pxls_tb[SDE_MAX_PLANES];
  153. /*
  154. * Number of pixels needs to be overfetched in left, right, top
  155. * and bottom directions from source image for scaling.
  156. */
  157. __s32 left_ftch[SDE_MAX_PLANES];
  158. __s32 right_ftch[SDE_MAX_PLANES];
  159. __s32 top_ftch[SDE_MAX_PLANES];
  160. __s32 btm_ftch[SDE_MAX_PLANES];
  161. /*
  162. * Number of pixels needs to be repeated in left, right, top and
  163. * bottom directions for scaling.
  164. */
  165. __s32 left_rpt[SDE_MAX_PLANES];
  166. __s32 right_rpt[SDE_MAX_PLANES];
  167. __s32 top_rpt[SDE_MAX_PLANES];
  168. __s32 btm_rpt[SDE_MAX_PLANES];
  169. };
  170. /**
  171. * struct sde_drm_scaler_v1 - version 1 of struct sde_drm_scaler
  172. * @lr: Pixel extension settings for left/right
  173. * @tb: Pixel extension settings for top/botton
  174. * @init_phase_x: Initial scaler phase values for x
  175. * @phase_step_x: Phase step values for x
  176. * @init_phase_y: Initial scaler phase values for y
  177. * @phase_step_y: Phase step values for y
  178. * @horz_filter: Horizontal filter array
  179. * @vert_filter: Vertical filter array
  180. */
  181. struct sde_drm_scaler_v1 {
  182. /*
  183. * Pix ext settings
  184. */
  185. struct sde_drm_pix_ext_v1 pe;
  186. /*
  187. * Phase settings
  188. */
  189. __s32 init_phase_x[SDE_MAX_PLANES];
  190. __s32 phase_step_x[SDE_MAX_PLANES];
  191. __s32 init_phase_y[SDE_MAX_PLANES];
  192. __s32 phase_step_y[SDE_MAX_PLANES];
  193. /*
  194. * Filter type to be used for scaling in horizontal and vertical
  195. * directions
  196. */
  197. __u32 horz_filter[SDE_MAX_PLANES];
  198. __u32 vert_filter[SDE_MAX_PLANES];
  199. };
  200. /**
  201. * struct sde_drm_de_v1 - version 1 of detail enhancer structure
  202. * @enable: Enables/disables detail enhancer
  203. * @sharpen_level1: Sharpening strength for noise
  204. * @sharpen_level2: Sharpening strength for context
  205. * @clip: Clip coefficient
  206. * @limit: Detail enhancer limit factor
  207. * @thr_quiet: Quite zone threshold
  208. * @thr_dieout: Die-out zone threshold
  209. * @thr_low: Linear zone left threshold
  210. * @thr_high: Linear zone right threshold
  211. * @prec_shift: Detail enhancer precision
  212. * @adjust_a: Mapping curves A coefficients
  213. * @adjust_b: Mapping curves B coefficients
  214. * @adjust_c: Mapping curves C coefficients
  215. */
  216. struct sde_drm_de_v1 {
  217. __u32 enable;
  218. __s16 sharpen_level1;
  219. __s16 sharpen_level2;
  220. __u16 clip;
  221. __u16 limit;
  222. __u16 thr_quiet;
  223. __u16 thr_dieout;
  224. __u16 thr_low;
  225. __u16 thr_high;
  226. __u16 prec_shift;
  227. __s16 adjust_a[SDE_MAX_DE_CURVES];
  228. __s16 adjust_b[SDE_MAX_DE_CURVES];
  229. __s16 adjust_c[SDE_MAX_DE_CURVES];
  230. };
  231. /*
  232. * Scaler configuration flags
  233. */
  234. /* Disable dynamic expansion */
  235. #define SDE_DYN_EXP_DISABLE 0x1
  236. #define SDE_DRM_QSEED3LITE
  237. #define SDE_DRM_QSEED4
  238. #define SDE_DRM_INLINE_PREDOWNSCALE
  239. /**
  240. * struct sde_drm_scaler_v2 - version 2 of struct sde_drm_scaler
  241. * @enable: Scaler enable
  242. * @dir_en: Detail enhancer enable
  243. * @pe: Pixel extension settings
  244. * @horz_decimate: Horizontal decimation factor
  245. * @vert_decimate: Vertical decimation factor
  246. * @init_phase_x: Initial scaler phase values for x
  247. * @phase_step_x: Phase step values for x
  248. * @init_phase_y: Initial scaler phase values for y
  249. * @phase_step_y: Phase step values for y
  250. * @preload_x: Horizontal preload value
  251. * @preload_y: Vertical preload value
  252. * @src_width: Source width
  253. * @src_height: Source height
  254. * @dst_width: Destination width
  255. * @dst_height: Destination height
  256. * @y_rgb_filter_cfg: Y/RGB plane filter configuration
  257. * @uv_filter_cfg: UV plane filter configuration
  258. * @alpha_filter_cfg: Alpha filter configuration
  259. * @blend_cfg: Selection of blend coefficients
  260. * @lut_flag: LUT configuration flags
  261. * @dir_lut_idx: 2d 4x4 LUT index
  262. * @y_rgb_cir_lut_idx: Y/RGB circular LUT index
  263. * @uv_cir_lut_idx: UV circular LUT index
  264. * @y_rgb_sep_lut_idx: Y/RGB separable LUT index
  265. * @uv_sep_lut_idx: UV separable LUT index
  266. * @de: Detail enhancer settings
  267. * @dir_weight: Directional Weight
  268. * @unsharp_mask_blend: Unsharp Blend Filter Ratio
  269. * @de_blend: Ratio of two unsharp mask filters
  270. * @flags: Scaler configuration flags
  271. * @pre_downscale_x_0 Pre-downscale ratio, x-direction, plane 0(Y/RGB)
  272. * @pre_downscale_x_1 Pre-downscale ratio, x-direction, plane 1(UV)
  273. * @pre_downscale_y_0 Pre-downscale ratio, y-direction, plane 0(Y/RGB)
  274. * @pre_downscale_y_1 Pre-downscale ratio, y-direction, plane 1(UV)
  275. */
  276. struct sde_drm_scaler_v2 {
  277. /*
  278. * General definitions
  279. */
  280. __u32 enable;
  281. __u32 dir_en;
  282. /*
  283. * Pix ext settings
  284. */
  285. struct sde_drm_pix_ext_v1 pe;
  286. /*
  287. * Decimation settings
  288. */
  289. __u32 horz_decimate;
  290. __u32 vert_decimate;
  291. /*
  292. * Phase settings
  293. */
  294. __s32 init_phase_x[SDE_MAX_PLANES];
  295. __s32 phase_step_x[SDE_MAX_PLANES];
  296. __s32 init_phase_y[SDE_MAX_PLANES];
  297. __s32 phase_step_y[SDE_MAX_PLANES];
  298. __u32 preload_x[SDE_MAX_PLANES];
  299. __u32 preload_y[SDE_MAX_PLANES];
  300. __u32 src_width[SDE_MAX_PLANES];
  301. __u32 src_height[SDE_MAX_PLANES];
  302. __u32 dst_width;
  303. __u32 dst_height;
  304. __u32 y_rgb_filter_cfg;
  305. __u32 uv_filter_cfg;
  306. __u32 alpha_filter_cfg;
  307. __u32 blend_cfg;
  308. __u32 lut_flag;
  309. __u32 dir_lut_idx;
  310. /* for Y(RGB) and UV planes*/
  311. __u32 y_rgb_cir_lut_idx;
  312. __u32 uv_cir_lut_idx;
  313. __u32 y_rgb_sep_lut_idx;
  314. __u32 uv_sep_lut_idx;
  315. /*
  316. * Detail enhancer settings
  317. */
  318. struct sde_drm_de_v1 de;
  319. __u32 dir_weight;
  320. __u32 unsharp_mask_blend;
  321. __u32 de_blend;
  322. __u32 flags;
  323. /*
  324. * Inline pre-downscale settings
  325. */
  326. __u32 pre_downscale_x_0;
  327. __u32 pre_downscale_x_1;
  328. __u32 pre_downscale_y_0;
  329. __u32 pre_downscale_y_1;
  330. };
  331. /* Number of dest scalers supported */
  332. #define SDE_MAX_DS_COUNT 2
  333. /*
  334. * Destination scaler flag config
  335. */
  336. #define SDE_DRM_DESTSCALER_ENABLE 0x1
  337. #define SDE_DRM_DESTSCALER_SCALE_UPDATE 0x2
  338. #define SDE_DRM_DESTSCALER_ENHANCER_UPDATE 0x4
  339. #define SDE_DRM_DESTSCALER_PU_ENABLE 0x8
  340. /**
  341. * struct sde_drm_dest_scaler_cfg - destination scaler config structure
  342. * @flags: Flag to switch between mode for destination scaler
  343. * refer to destination scaler flag config
  344. * @index: Destination scaler selection index
  345. * @lm_width: Layer mixer width configuration
  346. * @lm_height: Layer mixer height configuration
  347. * @scaler_cfg: The scaling parameters for all the mode except disable
  348. * Userspace pointer to struct sde_drm_scaler_v2
  349. */
  350. struct sde_drm_dest_scaler_cfg {
  351. __u32 flags;
  352. __u32 index;
  353. __u32 lm_width;
  354. __u32 lm_height;
  355. __u64 scaler_cfg;
  356. };
  357. /**
  358. * struct sde_drm_dest_scaler_data - destination scaler data struct
  359. * @num_dest_scaler: Number of dest scalers to be configured
  360. * @ds_cfg: Destination scaler block configuration
  361. */
  362. struct sde_drm_dest_scaler_data {
  363. __u32 num_dest_scaler;
  364. struct sde_drm_dest_scaler_cfg ds_cfg[SDE_MAX_DS_COUNT];
  365. };
  366. /*
  367. * Define constants for struct sde_drm_csc
  368. */
  369. #define SDE_CSC_MATRIX_COEFF_SIZE 9
  370. #define SDE_CSC_CLAMP_SIZE 6
  371. #define SDE_CSC_BIAS_SIZE 3
  372. /**
  373. * struct sde_drm_csc_v1 - version 1 of struct sde_drm_csc
  374. * @ctm_coeff: Matrix coefficients, in S31.32 format
  375. * @pre_bias: Pre-bias array values
  376. * @post_bias: Post-bias array values
  377. * @pre_clamp: Pre-clamp array values
  378. * @post_clamp: Post-clamp array values
  379. */
  380. struct sde_drm_csc_v1 {
  381. __s64 ctm_coeff[SDE_CSC_MATRIX_COEFF_SIZE];
  382. __u32 pre_bias[SDE_CSC_BIAS_SIZE];
  383. __u32 post_bias[SDE_CSC_BIAS_SIZE];
  384. __u32 pre_clamp[SDE_CSC_CLAMP_SIZE];
  385. __u32 post_clamp[SDE_CSC_CLAMP_SIZE];
  386. };
  387. /**
  388. * struct sde_drm_color - struct to store the color and alpha values
  389. * @color_0: Color 0 value
  390. * @color_1: Color 1 value
  391. * @color_2: Color 2 value
  392. * @color_3: Color 3 value
  393. */
  394. struct sde_drm_color {
  395. __u32 color_0;
  396. __u32 color_1;
  397. __u32 color_2;
  398. __u32 color_3;
  399. };
  400. /* Total number of supported dim layers */
  401. #define SDE_MAX_DIM_LAYERS 7
  402. /* SDE_DRM_DIM_LAYER_CONFIG_FLAG - flags for Dim Layer */
  403. /* Color fill inside of the rect, including border */
  404. #define SDE_DRM_DIM_LAYER_INCLUSIVE 0x1
  405. /* Color fill outside of the rect, excluding border */
  406. #define SDE_DRM_DIM_LAYER_EXCLUSIVE 0x2
  407. /* bitmask for allowed_dsc_reservation_switch property */
  408. #define SDE_DP_DSC_RESERVATION_SWITCH (1 << 0)
  409. /**
  410. * struct sde_drm_dim_layer - dim layer cfg struct
  411. * @flags: Refer SDE_DRM_DIM_LAYER_CONFIG_FLAG for possible values
  412. * @stage: Blending stage of the dim layer
  413. * @color_fill: Color fill for dim layer
  414. * @rect: Dim layer coordinates
  415. */
  416. struct sde_drm_dim_layer_cfg {
  417. __u32 flags;
  418. __u32 stage;
  419. struct sde_drm_color color_fill;
  420. struct drm_clip_rect rect;
  421. };
  422. /**
  423. * struct sde_drm_dim_layer_v1 - version 1 of dim layer struct
  424. * @num_layers: Numer of Dim Layers
  425. * @layer: Dim layer user cfgs ptr for the num_layers
  426. */
  427. struct sde_drm_dim_layer_v1 {
  428. __u32 num_layers;
  429. struct sde_drm_dim_layer_cfg layer_cfg[SDE_MAX_DIM_LAYERS];
  430. };
  431. /* Writeback Config version definition */
  432. #define SDE_DRM_WB_CFG 0x1
  433. /* SDE_DRM_WB_CONFIG_FLAGS - Writeback configuration flags */
  434. #define SDE_DRM_WB_CFG_FLAGS_CONNECTED (1<<0)
  435. /**
  436. * struct sde_drm_wb_cfg - Writeback configuration structure
  437. * @flags: see DRM_MSM_WB_CONFIG_FLAGS
  438. * @connector_id: writeback connector identifier
  439. * @count_modes: Count of modes in modes_ptr
  440. * @modes: Pointer to struct drm_mode_modeinfo
  441. */
  442. struct sde_drm_wb_cfg {
  443. __u32 flags;
  444. __u32 connector_id;
  445. __u32 count_modes;
  446. __u64 modes;
  447. };
  448. #define SDE_MAX_ROI_V1 4
  449. /**
  450. * struct sde_drm_roi_v1 - list of regions of interest for a drm object
  451. * @num_rects: number of valid rectangles in the roi array
  452. * @roi: list of roi rectangles
  453. */
  454. struct sde_drm_roi_v1 {
  455. __u32 num_rects;
  456. struct drm_clip_rect roi[SDE_MAX_ROI_V1];
  457. };
  458. /**
  459. * Define extended power modes supported by the SDE connectors.
  460. */
  461. #define SDE_MODE_DPMS_ON 0
  462. #define SDE_MODE_DPMS_LP1 1
  463. #define SDE_MODE_DPMS_LP2 2
  464. #define SDE_MODE_DPMS_STANDBY 3
  465. #define SDE_MODE_DPMS_SUSPEND 4
  466. #define SDE_MODE_DPMS_OFF 5
  467. /**
  468. * sde recovery events for notifying client
  469. */
  470. #define SDE_RECOVERY_SUCCESS 0
  471. #define SDE_RECOVERY_CAPTURE 1
  472. #define SDE_RECOVERY_HARD_RESET 2
  473. /**
  474. * Define UBWC statistics config
  475. */
  476. #define UBWC_STATS_MAX_ROI 0x3
  477. /**
  478. * struct sde_drm_ubwc_stats_roi - region of interest for ubwc stats
  479. * y_coord0: first y offset from top of display
  480. * y_coord1: second y offset from top of display
  481. */
  482. struct sde_drm_ubwc_stats_roi {
  483. __u16 y_coord0;
  484. __u16 y_coord1;
  485. };
  486. /**
  487. * struct sde_drm_ubwc_stats_data: ubwc statistics
  488. * roi: region of interest
  489. * worst_bw: worst bandwidth, per roi
  490. * worst_bw_y_coord: y offset (row) location of worst bandwidth, per roi
  491. * total_bw: total bandwidth, per roi
  492. * error: error status
  493. * meta_error: meta error data
  494. */
  495. struct sde_drm_ubwc_stats_data {
  496. struct sde_drm_ubwc_stats_roi roi;
  497. __u16 worst_bw[UBWC_STATS_MAX_ROI];
  498. __u16 worst_bw_y_coord[UBWC_STATS_MAX_ROI];
  499. __u32 total_bw[UBWC_STATS_MAX_ROI];
  500. __u32 error;
  501. __u32 meta_error;
  502. };
  503. /**
  504. * Define frame data config
  505. */
  506. #define SDE_FRAME_DATA_BUFFER_MAX 0x3
  507. #define SDE_FRAME_DATA_GUARD_BYTES 0xFF
  508. #define SDE_FRAME_DATA_MAX_PLANES 0x10
  509. /**
  510. * struct sde_drm_frame_data_buffers_ctrl - control frame data buffers
  511. * num_buffers: number of allocated buffers
  512. * fds: fd list for allocated buffers
  513. */
  514. struct sde_drm_frame_data_buffers_ctrl {
  515. __u32 num_buffers;
  516. __u32 fds[SDE_FRAME_DATA_BUFFER_MAX];
  517. };
  518. /**
  519. * struct sde_drm_frame_data_buf - frame data buffer info sent to userspace
  520. * fd: buffer fd
  521. * offset: offset from buffer address
  522. * status: status flag
  523. */
  524. struct sde_drm_frame_data_buf {
  525. __u32 fd;
  526. __u32 offset;
  527. __u32 status;
  528. };
  529. /**
  530. * struct sde_drm_plane_frame_data - definition of plane frame data struct
  531. * plane_id: drm plane id
  532. * ubwc_stats: ubwc statistics
  533. */
  534. struct sde_drm_plane_frame_data {
  535. __u32 plane_id;
  536. struct sde_drm_ubwc_stats_data ubwc_stats;
  537. };
  538. /**
  539. * struct sde_drm_frame_data_packet - definition of frame data struct
  540. * frame_count: interface frame count
  541. * commit_count: sw commit count
  542. * plane_frame_data: data available per plane
  543. */
  544. struct sde_drm_frame_data_packet {
  545. __u32 frame_count;
  546. __u64 commit_count;
  547. struct sde_drm_plane_frame_data plane_frame_data[SDE_FRAME_DATA_MAX_PLANES];
  548. };
  549. /*
  550. * Colorimetry Data Block values
  551. * These bit nums are defined as per the CTA spec
  552. * and indicate the colorspaces supported by the sink
  553. */
  554. #define DRM_EDID_CLRMETRY_xvYCC_601 (1 << 0)
  555. #define DRM_EDID_CLRMETRY_xvYCC_709 (1 << 1)
  556. #define DRM_EDID_CLRMETRY_sYCC_601 (1 << 2)
  557. #define DRM_EDID_CLRMETRY_ADOBE_YCC_601 (1 << 3)
  558. #define DRM_EDID_CLRMETRY_ADOBE_RGB (1 << 4)
  559. #define DRM_EDID_CLRMETRY_BT2020_CYCC (1 << 5)
  560. #define DRM_EDID_CLRMETRY_BT2020_YCC (1 << 6)
  561. #define DRM_EDID_CLRMETRY_BT2020_RGB (1 << 7)
  562. #define DRM_EDID_CLRMETRY_DCI_P3 (1 << 15)
  563. /*
  564. * HDR Metadata
  565. * These are defined as per EDID spec and shall be used by the sink
  566. * to set the HDR metadata for playback from userspace.
  567. */
  568. #define HDR_PRIMARIES_COUNT 3
  569. /* HDR EOTF */
  570. #define HDR_EOTF_SDR_LUM_RANGE 0x0
  571. #define HDR_EOTF_HDR_LUM_RANGE 0x1
  572. #define HDR_EOTF_SMTPE_ST2084 0x2
  573. #define HDR_EOTF_HLG 0x3
  574. #define DRM_MSM_EXT_HDR_METADATA
  575. #define DRM_MSM_EXT_HDR_PLUS_METADATA
  576. struct drm_msm_ext_hdr_metadata {
  577. __u32 hdr_state; /* HDR state */
  578. __u32 eotf; /* electro optical transfer function */
  579. __u32 hdr_supported; /* HDR supported */
  580. __u32 display_primaries_x[HDR_PRIMARIES_COUNT]; /* Primaries x */
  581. __u32 display_primaries_y[HDR_PRIMARIES_COUNT]; /* Primaries y */
  582. __u32 white_point_x; /* white_point_x */
  583. __u32 white_point_y; /* white_point_y */
  584. __u32 max_luminance; /* Max luminance */
  585. __u32 min_luminance; /* Min Luminance */
  586. __u32 max_content_light_level; /* max content light level */
  587. __u32 max_average_light_level; /* max average light level */
  588. __u64 hdr_plus_payload; /* user pointer to dynamic HDR payload */
  589. __u32 hdr_plus_payload_size;/* size of dynamic HDR payload data */
  590. };
  591. /**
  592. * HDR sink properties
  593. * These are defined as per EDID spec and shall be used by the userspace
  594. * to determine the HDR properties to be set to the sink.
  595. */
  596. #define DRM_MSM_EXT_HDR_PROPERTIES
  597. #define DRM_MSM_EXT_HDR_PLUS_PROPERTIES
  598. struct drm_msm_ext_hdr_properties {
  599. __u8 hdr_metadata_type_one; /* static metadata type one */
  600. __u32 hdr_supported; /* HDR supported */
  601. __u32 hdr_eotf; /* electro optical transfer function */
  602. __u32 hdr_max_luminance; /* Max luminance */
  603. __u32 hdr_avg_luminance; /* Avg luminance */
  604. __u32 hdr_min_luminance; /* Min Luminance */
  605. __u32 hdr_plus_supported; /* HDR10+ supported */
  606. };
  607. /* HDR WRGB x and y index */
  608. #define DISPLAY_PRIMARIES_WX 0
  609. #define DISPLAY_PRIMARIES_WY 1
  610. #define DISPLAY_PRIMARIES_RX 2
  611. #define DISPLAY_PRIMARIES_RY 3
  612. #define DISPLAY_PRIMARIES_GX 4
  613. #define DISPLAY_PRIMARIES_GY 5
  614. #define DISPLAY_PRIMARIES_BX 6
  615. #define DISPLAY_PRIMARIES_BY 7
  616. #define DISPLAY_PRIMARIES_MAX 8
  617. struct drm_panel_hdr_properties {
  618. __u32 hdr_enabled;
  619. /* WRGB X and y values arrayed in format */
  620. /* [WX, WY, RX, RY, GX, GY, BX, BY] */
  621. __u32 display_primaries[DISPLAY_PRIMARIES_MAX];
  622. /* peak brightness supported by panel */
  623. __u32 peak_brightness;
  624. /* Blackness level supported by panel */
  625. __u32 blackness_level;
  626. };
  627. /**
  628. * struct drm_msm_event_req - Payload to event enable/disable ioctls.
  629. * @object_id: DRM object id. e.g.: for crtc pass crtc id.
  630. * @object_type: DRM object type. e.g.: for crtc set it to DRM_MODE_OBJECT_CRTC.
  631. * @event: Event for which notification is being enabled/disabled.
  632. * e.g.: for Histogram set - DRM_EVENT_HISTOGRAM.
  633. * @client_context: Opaque pointer that will be returned during event response
  634. * notification.
  635. * @index: Object index(e.g.: crtc index), optional for user-space to set.
  636. * Driver will override value based on object_id and object_type.
  637. */
  638. struct drm_msm_event_req {
  639. __u32 object_id;
  640. __u32 object_type;
  641. __u32 event;
  642. __u64 client_context;
  643. __u32 index;
  644. };
  645. /**
  646. * struct drm_msm_event_resp - payload returned when read is called for
  647. * custom notifications.
  648. * @base: Event type and length of complete notification payload.
  649. * @info: Contains information about DRM that which raised this event.
  650. * @data: Custom payload that driver returns for event type.
  651. * size of data = base.length - (sizeof(base) + sizeof(info))
  652. */
  653. struct drm_msm_event_resp {
  654. struct drm_event base;
  655. struct drm_msm_event_req info;
  656. __u8 data[];
  657. };
  658. /**
  659. * struct drm_msm_power_ctrl: Payload to enable/disable the power vote
  660. * @enable: enable/disable the power vote
  661. * @flags: operation control flags, for future use
  662. */
  663. struct drm_msm_power_ctrl {
  664. __u32 enable;
  665. __u32 flags;
  666. };
  667. /**
  668. * struct drm_msm_early_wakeup: Payload to early wake up display
  669. * @wakeup_hint: early wakeup hint.
  670. * @connector_id: connector id. e.g.: for connector pass connector id.
  671. */
  672. struct drm_msm_early_wakeup {
  673. __u32 wakeup_hint;
  674. __u32 connector_id;
  675. };
  676. /**
  677. * struct drm_msm_display_hint: Payload for display hint
  678. * @hint_flags: display hint flags.
  679. * @data: data struct. e.g.: for display hint parameter.
  680. * Userspace pointer to struct base on hint flags.
  681. */
  682. struct drm_msm_display_hint {
  683. __u64 data;
  684. __u32 hint_flags;
  685. };
  686. #define DRM_NOISE_LAYER_CFG
  687. #define DRM_NOISE_TEMPORAL_FLAG (1 << 0)
  688. #define DRM_NOISE_ATTN_MAX 255
  689. #define DRM_NOISE_STREN_MAX 6
  690. /**
  691. * struct drm_msm_noise_layer_cfg: Payload to enable/disable noise blend
  692. * @flags: operation control flags, for future use
  693. * @zposn: noise zorder
  694. * @zposattn: attenuation zorder
  695. * @attn_factor: attenuation factor in range of 1 to 255
  696. * @stength: strength in range of 0 to 6
  697. * @alpha_noise: attenuation in range of 1 to 255
  698. */
  699. struct drm_msm_noise_layer_cfg {
  700. __u64 flags;
  701. __u32 zposn;
  702. __u32 zposattn;
  703. __u32 attn_factor;
  704. __u32 strength;
  705. __u32 alpha_noise;
  706. };
  707. #define DRM_SDE_WB_CONFIG 0x40
  708. #define DRM_MSM_REGISTER_EVENT 0x41
  709. #define DRM_MSM_DEREGISTER_EVENT 0x42
  710. #define DRM_MSM_RMFB2 0x43
  711. #define DRM_MSM_POWER_CTRL 0x44
  712. #define DRM_MSM_DISPLAY_HINT 0x45
  713. /* sde custom events */
  714. #define DRM_EVENT_HISTOGRAM 0x80000000
  715. #define DRM_EVENT_AD_BACKLIGHT 0x80000001
  716. #define DRM_EVENT_CRTC_POWER 0x80000002
  717. #define DRM_EVENT_SYS_BACKLIGHT 0x80000003
  718. #define DRM_EVENT_SDE_POWER 0x80000004
  719. #define DRM_EVENT_IDLE_NOTIFY 0x80000005
  720. #define DRM_EVENT_PANEL_DEAD 0x80000006 /* ESD event */
  721. #define DRM_EVENT_SDE_HW_RECOVERY 0X80000007
  722. #define DRM_EVENT_LTM_HIST 0X80000008
  723. #define DRM_EVENT_LTM_WB_PB 0X80000009
  724. #define DRM_EVENT_LTM_OFF 0X8000000A
  725. #define DRM_EVENT_MMRM_CB 0X8000000B
  726. #define DRM_EVENT_FRAME_DATA 0x8000000C
  727. #define DRM_EVENT_DIMMING_BL 0X8000000D
  728. #define DRM_EVENT_VM_RELEASE 0X8000000E
  729. #ifndef DRM_MODE_FLAG_VID_MODE_PANEL
  730. #define DRM_MODE_FLAG_VID_MODE_PANEL 0x01
  731. #endif
  732. #ifndef DRM_MODE_FLAG_CMD_MODE_PANEL
  733. #define DRM_MODE_FLAG_CMD_MODE_PANEL 0x02
  734. #endif
  735. /* display hint flags*/
  736. #define DRM_MSM_DISPLAY_EARLY_WAKEUP_HINT 0x01
  737. #define DRM_MSM_DISPLAY_POWER_COLLAPSE_HINT 0x02
  738. #define DRM_MSM_DISPLAY_IDLE_TIMEOUT_HINT 0x04
  739. #define DRM_MSM_DISPLAY_MODE_CHANGE_HINT 0x08
  740. #define DRM_MSM_WAKE_UP_ALL_DISPLAYS 0xFFFFFFFF
  741. #define DRM_IOCTL_SDE_WB_CONFIG \
  742. DRM_IOW((DRM_COMMAND_BASE + DRM_SDE_WB_CONFIG), struct sde_drm_wb_cfg)
  743. #define DRM_IOCTL_MSM_REGISTER_EVENT DRM_IOW((DRM_COMMAND_BASE + \
  744. DRM_MSM_REGISTER_EVENT), struct drm_msm_event_req)
  745. #define DRM_IOCTL_MSM_DEREGISTER_EVENT DRM_IOW((DRM_COMMAND_BASE + \
  746. DRM_MSM_DEREGISTER_EVENT), struct drm_msm_event_req)
  747. #define DRM_IOCTL_MSM_RMFB2 DRM_IOW((DRM_COMMAND_BASE + \
  748. DRM_MSM_RMFB2), unsigned int)
  749. #define DRM_IOCTL_MSM_POWER_CTRL DRM_IOW((DRM_COMMAND_BASE + \
  750. DRM_MSM_POWER_CTRL), struct drm_msm_power_ctrl)
  751. #define DRM_IOCTL_MSM_DISPLAY_HINT DRM_IOW((DRM_COMMAND_BASE + \
  752. DRM_MSM_DISPLAY_HINT), struct drm_msm_display_hint)
  753. #if defined(__cplusplus)
  754. }
  755. #endif
  756. #endif /* _SDE_DRM_H_ */