0001
0002
0003
0004
0005
0006
0007 #ifndef _DPU_HW_UTIL_H
0008 #define _DPU_HW_UTIL_H
0009
0010 #include <linux/io.h>
0011 #include <linux/slab.h>
0012 #include "dpu_hw_mdss.h"
0013 #include "dpu_hw_catalog.h"
0014
0015 #define REG_MASK(n) ((BIT(n)) - 1)
0016 #define MISR_FRAME_COUNT_MASK 0xFF
0017 #define MISR_CTRL_ENABLE BIT(8)
0018 #define MISR_CTRL_STATUS BIT(9)
0019 #define MISR_CTRL_STATUS_CLEAR BIT(10)
0020 #define MISR_CTRL_FREE_RUN_MASK BIT(31)
0021
0022
0023
0024
0025
0026
0027
0028
0029 struct dpu_hw_blk_reg_map {
0030 void __iomem *blk_addr;
0031 u32 log_mask;
0032 };
0033
0034
0035
0036
0037 struct dpu_hw_blk {
0038
0039 };
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057 struct dpu_hw_scaler3_de_cfg {
0058 u32 enable;
0059 int16_t sharpen_level1;
0060 int16_t sharpen_level2;
0061 uint16_t clip;
0062 uint16_t limit;
0063 uint16_t thr_quiet;
0064 uint16_t thr_dieout;
0065 uint16_t thr_low;
0066 uint16_t thr_high;
0067 uint16_t prec_shift;
0068 int16_t adjust_a[DPU_MAX_DE_CURVES];
0069 int16_t adjust_b[DPU_MAX_DE_CURVES];
0070 int16_t adjust_c[DPU_MAX_DE_CURVES];
0071 };
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110 struct dpu_hw_scaler3_cfg {
0111 u32 enable;
0112 u32 dir_en;
0113 int32_t init_phase_x[DPU_MAX_PLANES];
0114 int32_t phase_step_x[DPU_MAX_PLANES];
0115 int32_t init_phase_y[DPU_MAX_PLANES];
0116 int32_t phase_step_y[DPU_MAX_PLANES];
0117
0118 u32 preload_x[DPU_MAX_PLANES];
0119 u32 preload_y[DPU_MAX_PLANES];
0120 u32 src_width[DPU_MAX_PLANES];
0121 u32 src_height[DPU_MAX_PLANES];
0122
0123 u32 dst_width;
0124 u32 dst_height;
0125
0126 u32 y_rgb_filter_cfg;
0127 u32 uv_filter_cfg;
0128 u32 alpha_filter_cfg;
0129 u32 blend_cfg;
0130
0131 u32 lut_flag;
0132 u32 dir_lut_idx;
0133
0134 u32 y_rgb_cir_lut_idx;
0135 u32 uv_cir_lut_idx;
0136 u32 y_rgb_sep_lut_idx;
0137 u32 uv_sep_lut_idx;
0138 u32 *dir_lut;
0139 size_t dir_len;
0140 u32 *cir_lut;
0141 size_t cir_len;
0142 u32 *sep_lut;
0143 size_t sep_len;
0144
0145
0146
0147
0148 struct dpu_hw_scaler3_de_cfg de;
0149
0150 u32 dir_weight;
0151 };
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166 struct dpu_drm_pix_ext_v1 {
0167
0168
0169
0170
0171 int32_t num_ext_pxls_lr[DPU_MAX_PLANES];
0172 int32_t num_ext_pxls_tb[DPU_MAX_PLANES];
0173
0174
0175
0176
0177
0178 int32_t left_ftch[DPU_MAX_PLANES];
0179 int32_t right_ftch[DPU_MAX_PLANES];
0180 int32_t top_ftch[DPU_MAX_PLANES];
0181 int32_t btm_ftch[DPU_MAX_PLANES];
0182
0183
0184
0185
0186 int32_t left_rpt[DPU_MAX_PLANES];
0187 int32_t right_rpt[DPU_MAX_PLANES];
0188 int32_t top_rpt[DPU_MAX_PLANES];
0189 int32_t btm_rpt[DPU_MAX_PLANES];
0190
0191 };
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209 struct dpu_drm_de_v1 {
0210 uint32_t enable;
0211 int16_t sharpen_level1;
0212 int16_t sharpen_level2;
0213 uint16_t clip;
0214 uint16_t limit;
0215 uint16_t thr_quiet;
0216 uint16_t thr_dieout;
0217 uint16_t thr_low;
0218 uint16_t thr_high;
0219 uint16_t prec_shift;
0220 int16_t adjust_a[DPU_MAX_DE_CURVES];
0221 int16_t adjust_b[DPU_MAX_DE_CURVES];
0222 int16_t adjust_c[DPU_MAX_DE_CURVES];
0223 };
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252
0253
0254 struct dpu_drm_scaler_v2 {
0255
0256
0257
0258 uint32_t enable;
0259 uint32_t dir_en;
0260
0261
0262
0263
0264 struct dpu_drm_pix_ext_v1 pe;
0265
0266
0267
0268
0269 uint32_t horz_decimate;
0270 uint32_t vert_decimate;
0271
0272
0273
0274
0275 int32_t init_phase_x[DPU_MAX_PLANES];
0276 int32_t phase_step_x[DPU_MAX_PLANES];
0277 int32_t init_phase_y[DPU_MAX_PLANES];
0278 int32_t phase_step_y[DPU_MAX_PLANES];
0279
0280 uint32_t preload_x[DPU_MAX_PLANES];
0281 uint32_t preload_y[DPU_MAX_PLANES];
0282 uint32_t src_width[DPU_MAX_PLANES];
0283 uint32_t src_height[DPU_MAX_PLANES];
0284
0285 uint32_t dst_width;
0286 uint32_t dst_height;
0287
0288 uint32_t y_rgb_filter_cfg;
0289 uint32_t uv_filter_cfg;
0290 uint32_t alpha_filter_cfg;
0291 uint32_t blend_cfg;
0292
0293 uint32_t lut_flag;
0294 uint32_t dir_lut_idx;
0295
0296
0297 uint32_t y_rgb_cir_lut_idx;
0298 uint32_t uv_cir_lut_idx;
0299 uint32_t y_rgb_sep_lut_idx;
0300 uint32_t uv_sep_lut_idx;
0301
0302
0303
0304
0305 struct dpu_drm_de_v1 de;
0306 };
0307
0308
0309
0310
0311
0312
0313
0314
0315
0316
0317 struct dpu_hw_cdp_cfg {
0318 bool enable;
0319 bool ubwc_meta_enable;
0320 bool tile_amortize_enable;
0321 u32 preload_ahead;
0322 };
0323
0324 u32 *dpu_hw_util_get_log_mask_ptr(void);
0325
0326 void dpu_reg_write(struct dpu_hw_blk_reg_map *c,
0327 u32 reg_off,
0328 u32 val,
0329 const char *name);
0330 int dpu_reg_read(struct dpu_hw_blk_reg_map *c, u32 reg_off);
0331
0332 #define DPU_REG_WRITE(c, off, val) dpu_reg_write(c, off, val, #off)
0333 #define DPU_REG_READ(c, off) dpu_reg_read(c, off)
0334
0335 void *dpu_hw_util_get_dir(void);
0336
0337 void dpu_hw_setup_scaler3(struct dpu_hw_blk_reg_map *c,
0338 struct dpu_hw_scaler3_cfg *scaler3_cfg,
0339 u32 scaler_offset, u32 scaler_version,
0340 const struct dpu_format *format);
0341
0342 u32 dpu_hw_get_scaler3_ver(struct dpu_hw_blk_reg_map *c,
0343 u32 scaler_offset);
0344
0345 void dpu_hw_csc_setup(struct dpu_hw_blk_reg_map *c,
0346 u32 csc_reg_off,
0347 const struct dpu_csc_cfg *data, bool csc10);
0348
0349 u64 _dpu_hw_get_qos_lut(const struct dpu_qos_lut_tbl *tbl,
0350 u32 total_fl);
0351
0352 void dpu_hw_setup_misr(struct dpu_hw_blk_reg_map *c,
0353 u32 misr_ctrl_offset,
0354 bool enable,
0355 u32 frame_count);
0356
0357 int dpu_hw_collect_misr(struct dpu_hw_blk_reg_map *c,
0358 u32 misr_ctrl_offset,
0359 u32 misr_signature_offset,
0360 u32 *misr_value);
0361
0362 #endif