sde_drm.h 30 KB

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