sde_hw_util.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2015-2020, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _SDE_HW_UTIL_H
  6. #define _SDE_HW_UTIL_H
  7. #include <linux/io.h>
  8. #include <linux/slab.h>
  9. #include "sde_hw_mdss.h"
  10. #include "sde_hw_catalog.h"
  11. #define REG_MASK(n) ((BIT(n)) - 1)
  12. #define REG_MASK_SHIFT(n, shift) ((REG_MASK(n)) << (shift))
  13. #define LP_DDR4_TYPE 0x7
  14. struct sde_format_extended;
  15. /*
  16. * This is the common struct maintained by each sub block
  17. * for mapping the register offsets in this block to the
  18. * absoulute IO address
  19. * @base_off: mdp register mapped offset
  20. * @blk_off: pipe offset relative to mdss offset
  21. * @length length of register block offset
  22. * @xin_id xin id
  23. * @hwversion mdss hw version number
  24. */
  25. struct sde_hw_blk_reg_map {
  26. void __iomem *base_off;
  27. u32 blk_off;
  28. u32 length;
  29. u32 xin_id;
  30. u32 hwversion;
  31. u32 log_mask;
  32. };
  33. /**
  34. * struct sde_hw_scaler3_de_cfg : QSEEDv3 detail enhancer configuration
  35. * @enable: detail enhancer enable/disable
  36. * @sharpen_level1: sharpening strength for noise
  37. * @sharpen_level2: sharpening strength for signal
  38. * @ clip: clip shift
  39. * @ limit: limit value
  40. * @ thr_quiet: quiet threshold
  41. * @ thr_dieout: dieout threshold
  42. * @ thr_high: low threshold
  43. * @ thr_high: high threshold
  44. * @ prec_shift: precision shift
  45. * @ adjust_a: A-coefficients for mapping curve
  46. * @ adjust_b: B-coefficients for mapping curve
  47. * @ adjust_c: C-coefficients for mapping curve
  48. * @ blend: Unsharp Blend Filter Ratio
  49. */
  50. struct sde_hw_scaler3_de_cfg {
  51. u32 enable;
  52. int16_t sharpen_level1;
  53. int16_t sharpen_level2;
  54. uint16_t clip;
  55. uint16_t limit;
  56. uint16_t thr_quiet;
  57. uint16_t thr_dieout;
  58. uint16_t thr_low;
  59. uint16_t thr_high;
  60. uint16_t prec_shift;
  61. int16_t adjust_a[SDE_MAX_DE_CURVES];
  62. int16_t adjust_b[SDE_MAX_DE_CURVES];
  63. int16_t adjust_c[SDE_MAX_DE_CURVES];
  64. uint32_t blend;
  65. };
  66. /**
  67. * struct sde_hw_scaler3_cfg : QSEEDv3 configuration
  68. * @enable: scaler enable
  69. * @dir_en: direction detection block enable
  70. * @ init_phase_x: horizontal initial phase
  71. * @ phase_step_x: horizontal phase step
  72. * @ init_phase_y: vertical initial phase
  73. * @ phase_step_y: vertical phase step
  74. * @ preload_x: horizontal preload value
  75. * @ preload_y: vertical preload value
  76. * @ src_width: source width
  77. * @ src_height: source height
  78. * @ dst_width: destination width
  79. * @ dst_height: destination height
  80. * @ y_rgb_filter_cfg: y/rgb plane filter configuration
  81. * @ uv_filter_cfg: uv plane filter configuration
  82. * @ alpha_filter_cfg: alpha filter configuration
  83. * @ blend_cfg: blend coefficients configuration
  84. * @ lut_flag: scaler LUT update flags
  85. * 0x1 swap LUT bank
  86. * 0x2 update 2D filter LUT
  87. * 0x4 update y circular filter LUT
  88. * 0x8 update uv circular filter LUT
  89. * 0x10 update y separable filter LUT
  90. * 0x20 update uv separable filter LUT
  91. * @ dir_lut_idx: 2D filter LUT index
  92. * @ y_rgb_cir_lut_idx: y circular filter LUT index
  93. * @ uv_cir_lut_idx: uv circular filter LUT index
  94. * @ y_rgb_sep_lut_idx: y circular filter LUT index
  95. * @ uv_sep_lut_idx: uv separable filter LUT index
  96. * @ dir_lut: pointer to 2D LUT
  97. * @ cir_lut: pointer to circular filter LUT
  98. * @ sep_lut: pointer to separable filter LUT
  99. * @ de: detail enhancer configuration
  100. * @ dir_weight: Directional Weight
  101. * @dyn_exp_disabled: Dynamic expansion disabled
  102. */
  103. struct sde_hw_scaler3_cfg {
  104. u32 enable;
  105. u32 dir_en;
  106. int32_t init_phase_x[SDE_MAX_PLANES];
  107. int32_t phase_step_x[SDE_MAX_PLANES];
  108. int32_t init_phase_y[SDE_MAX_PLANES];
  109. int32_t phase_step_y[SDE_MAX_PLANES];
  110. u32 preload_x[SDE_MAX_PLANES];
  111. u32 preload_y[SDE_MAX_PLANES];
  112. u32 src_width[SDE_MAX_PLANES];
  113. u32 src_height[SDE_MAX_PLANES];
  114. u32 dst_width;
  115. u32 dst_height;
  116. u32 y_rgb_filter_cfg;
  117. u32 uv_filter_cfg;
  118. u32 alpha_filter_cfg;
  119. u32 blend_cfg;
  120. u32 lut_flag;
  121. u32 dir_lut_idx;
  122. u32 y_rgb_cir_lut_idx;
  123. u32 uv_cir_lut_idx;
  124. u32 y_rgb_sep_lut_idx;
  125. u32 uv_sep_lut_idx;
  126. u32 *dir_lut;
  127. size_t dir_len;
  128. u32 *cir_lut;
  129. size_t cir_len;
  130. u32 *sep_lut;
  131. size_t sep_len;
  132. /*
  133. * Detail enhancer settings
  134. */
  135. struct sde_hw_scaler3_de_cfg de;
  136. uint32_t dir_weight;
  137. uint32_t dyn_exp_disabled;
  138. };
  139. struct sde_hw_scaler3_lut_cfg {
  140. bool is_configured;
  141. u32 *dir_lut;
  142. size_t dir_len;
  143. u32 *cir_lut;
  144. size_t cir_len;
  145. u32 *sep_lut;
  146. size_t sep_len;
  147. };
  148. struct sde_hw_inline_pre_downscale_cfg {
  149. u32 pre_downscale_x_0;
  150. u32 pre_downscale_x_1;
  151. u32 pre_downscale_y_0;
  152. u32 pre_downscale_y_1;
  153. };
  154. u32 *sde_hw_util_get_log_mask_ptr(void);
  155. void sde_reg_write(struct sde_hw_blk_reg_map *c,
  156. u32 reg_off,
  157. u32 val,
  158. const char *name);
  159. int sde_reg_read(struct sde_hw_blk_reg_map *c, u32 reg_off);
  160. #define SDE_REG_WRITE(c, off, val) sde_reg_write(c, off, val, #off)
  161. #define SDE_REG_READ(c, off) sde_reg_read(c, off)
  162. #define MISR_FRAME_COUNT_MASK 0xFF
  163. #define MISR_CTRL_ENABLE BIT(8)
  164. #define MISR_CTRL_STATUS BIT(9)
  165. #define MISR_CTRL_STATUS_CLEAR BIT(10)
  166. #define INTF_MISR_CTRL_FREE_RUN_MASK BIT(31)
  167. #define INTF_MISR_CTRL_INPUT_SEL_DATA BIT(24)
  168. void *sde_hw_util_get_dir(void);
  169. void sde_init_scaler_blk(struct sde_scaler_blk *blk, u32 version);
  170. void sde_set_scaler_v2(struct sde_hw_scaler3_cfg *cfg,
  171. const struct sde_drm_scaler_v2 *scale_v2);
  172. void sde_hw_setup_scaler3(struct sde_hw_blk_reg_map *c,
  173. struct sde_hw_scaler3_cfg *scaler3_cfg, u32 scaler_version,
  174. u32 scaler_offset, const struct sde_format *format);
  175. u32 sde_hw_get_scaler3_ver(struct sde_hw_blk_reg_map *c,
  176. u32 scaler_offset);
  177. void sde_hw_csc_matrix_coeff_setup(struct sde_hw_blk_reg_map *c,
  178. u32 csc_reg_off, struct sde_csc_cfg *data,
  179. u32 shift_bit);
  180. void sde_hw_csc_setup(struct sde_hw_blk_reg_map *c,
  181. u32 csc_reg_off,
  182. struct sde_csc_cfg *data, bool csc10);
  183. uint32_t sde_copy_formats(
  184. struct sde_format_extended *dst_list,
  185. uint32_t dst_list_size,
  186. uint32_t dst_list_pos,
  187. const struct sde_format_extended *src_list,
  188. uint32_t src_list_size);
  189. uint32_t sde_get_linetime(struct drm_display_mode *mode,
  190. int src_bpp, int target_bpp);
  191. static inline bool is_qseed3_rev_qseed3lite(struct sde_mdss_cfg *sde_cfg)
  192. {
  193. return ((sde_cfg->qseed_type == SDE_SSPP_SCALER_QSEED3LITE) ?
  194. true : false);
  195. }
  196. #endif /* _SDE_HW_UTIL_H */