1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. 3 */ 4 5 #ifndef _DPU_HW_SSPP_H 6 #define _DPU_HW_SSPP_H 7 8 #include "dpu_hw_catalog.h" 9 #include "dpu_hw_mdss.h" 10 #include "dpu_hw_util.h" 11 #include "dpu_hw_blk.h" 12 #include "dpu_formats.h" 13 14 struct dpu_hw_pipe; 15 16 /** 17 * Flags 18 */ 19 #define DPU_SSPP_FLIP_LR BIT(0) 20 #define DPU_SSPP_FLIP_UD BIT(1) 21 #define DPU_SSPP_SOURCE_ROTATED_90 BIT(2) 22 #define DPU_SSPP_ROT_90 BIT(3) 23 #define DPU_SSPP_SOLID_FILL BIT(4) 24 25 /** 26 * Define all scaler feature bits in catalog 27 */ 28 #define DPU_SSPP_SCALER (BIT(DPU_SSPP_SCALER_RGB) | \ 29 BIT(DPU_SSPP_SCALER_QSEED2) | \ 30 BIT(DPU_SSPP_SCALER_QSEED3) | \ 31 BIT(DPU_SSPP_SCALER_QSEED3LITE) | \ 32 BIT(DPU_SSPP_SCALER_QSEED4)) 33 34 /* 35 * Define all CSC feature bits in catalog 36 */ 37 #define DPU_SSPP_CSC_ANY (BIT(DPU_SSPP_CSC) | \ 38 BIT(DPU_SSPP_CSC_10BIT)) 39 40 /** 41 * Component indices 42 */ 43 enum { 44 DPU_SSPP_COMP_0, 45 DPU_SSPP_COMP_1_2, 46 DPU_SSPP_COMP_2, 47 DPU_SSPP_COMP_3, 48 49 DPU_SSPP_COMP_MAX 50 }; 51 52 /** 53 * DPU_SSPP_RECT_SOLO - multirect disabled 54 * DPU_SSPP_RECT_0 - rect0 of a multirect pipe 55 * DPU_SSPP_RECT_1 - rect1 of a multirect pipe 56 * 57 * Note: HW supports multirect with either RECT0 or 58 * RECT1. Considering no benefit of such configs over 59 * SOLO mode and to keep the plane management simple, 60 * we dont support single rect multirect configs. 61 */ 62 enum dpu_sspp_multirect_index { 63 DPU_SSPP_RECT_SOLO = 0, 64 DPU_SSPP_RECT_0, 65 DPU_SSPP_RECT_1, 66 }; 67 68 enum dpu_sspp_multirect_mode { 69 DPU_SSPP_MULTIRECT_NONE = 0, 70 DPU_SSPP_MULTIRECT_PARALLEL, 71 DPU_SSPP_MULTIRECT_TIME_MX, 72 }; 73 74 enum { 75 DPU_FRAME_LINEAR, 76 DPU_FRAME_TILE_A4X, 77 DPU_FRAME_TILE_A5X, 78 }; 79 80 enum dpu_hw_filter { 81 DPU_SCALE_FILTER_NEAREST = 0, 82 DPU_SCALE_FILTER_BIL, 83 DPU_SCALE_FILTER_PCMN, 84 DPU_SCALE_FILTER_CA, 85 DPU_SCALE_FILTER_MAX 86 }; 87 88 enum dpu_hw_filter_alpa { 89 DPU_SCALE_ALPHA_PIXEL_REP, 90 DPU_SCALE_ALPHA_BIL 91 }; 92 93 enum dpu_hw_filter_yuv { 94 DPU_SCALE_2D_4X4, 95 DPU_SCALE_2D_CIR, 96 DPU_SCALE_1D_SEP, 97 DPU_SCALE_BIL 98 }; 99 100 struct dpu_hw_sharp_cfg { 101 u32 strength; 102 u32 edge_thr; 103 u32 smooth_thr; 104 u32 noise_thr; 105 }; 106 107 struct dpu_hw_pixel_ext { 108 /* scaling factors are enabled for this input layer */ 109 uint8_t enable_pxl_ext; 110 111 int init_phase_x[DPU_MAX_PLANES]; 112 int phase_step_x[DPU_MAX_PLANES]; 113 int init_phase_y[DPU_MAX_PLANES]; 114 int phase_step_y[DPU_MAX_PLANES]; 115 116 /* 117 * Number of pixels extension in left, right, top and bottom direction 118 * for all color components. This pixel value for each color component 119 * should be sum of fetch + repeat pixels. 120 */ 121 int num_ext_pxls_left[DPU_MAX_PLANES]; 122 int num_ext_pxls_right[DPU_MAX_PLANES]; 123 int num_ext_pxls_top[DPU_MAX_PLANES]; 124 int num_ext_pxls_btm[DPU_MAX_PLANES]; 125 126 /* 127 * Number of pixels needs to be overfetched in left, right, top and 128 * bottom directions from source image for scaling. 129 */ 130 int left_ftch[DPU_MAX_PLANES]; 131 int right_ftch[DPU_MAX_PLANES]; 132 int top_ftch[DPU_MAX_PLANES]; 133 int btm_ftch[DPU_MAX_PLANES]; 134 135 /* 136 * Number of pixels needs to be repeated in left, right, top and 137 * bottom directions for scaling. 138 */ 139 int left_rpt[DPU_MAX_PLANES]; 140 int right_rpt[DPU_MAX_PLANES]; 141 int top_rpt[DPU_MAX_PLANES]; 142 int btm_rpt[DPU_MAX_PLANES]; 143 144 uint32_t roi_w[DPU_MAX_PLANES]; 145 uint32_t roi_h[DPU_MAX_PLANES]; 146 147 /* 148 * Filter type to be used for scaling in horizontal and vertical 149 * directions 150 */ 151 enum dpu_hw_filter horz_filter[DPU_MAX_PLANES]; 152 enum dpu_hw_filter vert_filter[DPU_MAX_PLANES]; 153 154 }; 155 156 /** 157 * struct dpu_hw_pipe_cfg : Pipe description 158 * @layout: format layout information for programming buffer to hardware 159 * @src_rect: src ROI, caller takes into account the different operations 160 * such as decimation, flip etc to program this field 161 * @dest_rect: destination ROI. 162 * @index: index of the rectangle of SSPP 163 * @mode: parallel or time multiplex multirect mode 164 */ 165 struct dpu_hw_pipe_cfg { 166 struct dpu_hw_fmt_layout layout; 167 struct drm_rect src_rect; 168 struct drm_rect dst_rect; 169 enum dpu_sspp_multirect_index index; 170 enum dpu_sspp_multirect_mode mode; 171 }; 172 173 /** 174 * struct dpu_hw_pipe_qos_cfg : Source pipe QoS configuration 175 * @creq_vblank: creq value generated to vbif during vertical blanking 176 * @danger_vblank: danger value generated during vertical blanking 177 * @vblank_en: enable creq_vblank and danger_vblank during vblank 178 * @danger_safe_en: enable danger safe generation 179 */ 180 struct dpu_hw_pipe_qos_cfg { 181 u32 creq_vblank; 182 u32 danger_vblank; 183 bool vblank_en; 184 bool danger_safe_en; 185 }; 186 187 /** 188 * enum CDP preload ahead address size 189 */ 190 enum { 191 DPU_SSPP_CDP_PRELOAD_AHEAD_32, 192 DPU_SSPP_CDP_PRELOAD_AHEAD_64 193 }; 194 195 /** 196 * struct dpu_hw_pipe_ts_cfg - traffic shaper configuration 197 * @size: size to prefill in bytes, or zero to disable 198 * @time: time to prefill in usec, or zero to disable 199 */ 200 struct dpu_hw_pipe_ts_cfg { 201 u64 size; 202 u64 time; 203 }; 204 205 /** 206 * struct dpu_hw_sspp_ops - interface to the SSPP Hw driver functions 207 * Caller must call the init function to get the pipe context for each pipe 208 * Assumption is these functions will be called after clocks are enabled 209 */ 210 struct dpu_hw_sspp_ops { 211 /** 212 * setup_format - setup pixel format cropping rectangle, flip 213 * @ctx: Pointer to pipe context 214 * @cfg: Pointer to pipe config structure 215 * @flags: Extra flags for format config 216 * @index: rectangle index in multirect 217 */ 218 void (*setup_format)(struct dpu_hw_pipe *ctx, 219 const struct dpu_format *fmt, u32 flags, 220 enum dpu_sspp_multirect_index index); 221 222 /** 223 * setup_rects - setup pipe ROI rectangles 224 * @ctx: Pointer to pipe context 225 * @cfg: Pointer to pipe config structure 226 * @index: rectangle index in multirect 227 */ 228 void (*setup_rects)(struct dpu_hw_pipe *ctx, 229 struct dpu_hw_pipe_cfg *cfg, 230 enum dpu_sspp_multirect_index index); 231 232 /** 233 * setup_pe - setup pipe pixel extension 234 * @ctx: Pointer to pipe context 235 * @pe_ext: Pointer to pixel ext settings 236 */ 237 void (*setup_pe)(struct dpu_hw_pipe *ctx, 238 struct dpu_hw_pixel_ext *pe_ext); 239 240 /** 241 * setup_sourceaddress - setup pipe source addresses 242 * @ctx: Pointer to pipe context 243 * @cfg: Pointer to pipe config structure 244 * @index: rectangle index in multirect 245 */ 246 void (*setup_sourceaddress)(struct dpu_hw_pipe *ctx, 247 struct dpu_hw_pipe_cfg *cfg, 248 enum dpu_sspp_multirect_index index); 249 250 /** 251 * setup_csc - setup color space coversion 252 * @ctx: Pointer to pipe context 253 * @data: Pointer to config structure 254 */ 255 void (*setup_csc)(struct dpu_hw_pipe *ctx, const struct dpu_csc_cfg *data); 256 257 /** 258 * setup_solidfill - enable/disable colorfill 259 * @ctx: Pointer to pipe context 260 * @const_color: Fill color value 261 * @flags: Pipe flags 262 * @index: rectangle index in multirect 263 */ 264 void (*setup_solidfill)(struct dpu_hw_pipe *ctx, u32 color, 265 enum dpu_sspp_multirect_index index); 266 267 /** 268 * setup_multirect - setup multirect configuration 269 * @ctx: Pointer to pipe context 270 * @index: rectangle index in multirect 271 * @mode: parallel fetch / time multiplex multirect mode 272 */ 273 274 void (*setup_multirect)(struct dpu_hw_pipe *ctx, 275 enum dpu_sspp_multirect_index index, 276 enum dpu_sspp_multirect_mode mode); 277 278 /** 279 * setup_sharpening - setup sharpening 280 * @ctx: Pointer to pipe context 281 * @cfg: Pointer to config structure 282 */ 283 void (*setup_sharpening)(struct dpu_hw_pipe *ctx, 284 struct dpu_hw_sharp_cfg *cfg); 285 286 /** 287 * setup_danger_safe_lut - setup danger safe LUTs 288 * @ctx: Pointer to pipe context 289 * @danger_lut: LUT for generate danger level based on fill level 290 * @safe_lut: LUT for generate safe level based on fill level 291 * 292 */ 293 void (*setup_danger_safe_lut)(struct dpu_hw_pipe *ctx, 294 u32 danger_lut, 295 u32 safe_lut); 296 297 /** 298 * setup_creq_lut - setup CREQ LUT 299 * @ctx: Pointer to pipe context 300 * @creq_lut: LUT for generate creq level based on fill level 301 * 302 */ 303 void (*setup_creq_lut)(struct dpu_hw_pipe *ctx, 304 u64 creq_lut); 305 306 /** 307 * setup_qos_ctrl - setup QoS control 308 * @ctx: Pointer to pipe context 309 * @cfg: Pointer to pipe QoS configuration 310 * 311 */ 312 void (*setup_qos_ctrl)(struct dpu_hw_pipe *ctx, 313 struct dpu_hw_pipe_qos_cfg *cfg); 314 315 /** 316 * setup_histogram - setup histograms 317 * @ctx: Pointer to pipe context 318 * @cfg: Pointer to histogram configuration 319 */ 320 void (*setup_histogram)(struct dpu_hw_pipe *ctx, 321 void *cfg); 322 323 /** 324 * setup_scaler - setup scaler 325 * @ctx: Pointer to pipe context 326 * @pipe_cfg: Pointer to pipe configuration 327 * @scaler_cfg: Pointer to scaler configuration 328 */ 329 void (*setup_scaler)(struct dpu_hw_pipe *ctx, 330 struct dpu_hw_pipe_cfg *pipe_cfg, 331 void *scaler_cfg); 332 333 /** 334 * get_scaler_ver - get scaler h/w version 335 * @ctx: Pointer to pipe context 336 */ 337 u32 (*get_scaler_ver)(struct dpu_hw_pipe *ctx); 338 339 /** 340 * setup_cdp - setup client driven prefetch 341 * @ctx: Pointer to pipe context 342 * @cfg: Pointer to cdp configuration 343 * @index: rectangle index in multirect 344 */ 345 void (*setup_cdp)(struct dpu_hw_pipe *ctx, 346 struct dpu_hw_cdp_cfg *cfg, 347 enum dpu_sspp_multirect_index index); 348 }; 349 350 /** 351 * struct dpu_hw_pipe - pipe description 352 * @base: hardware block base structure 353 * @hw: block hardware details 354 * @catalog: back pointer to catalog 355 * @mdp: pointer to associated mdp portion of the catalog 356 * @idx: pipe index 357 * @cap: pointer to layer_cfg 358 * @ops: pointer to operations possible for this pipe 359 */ 360 struct dpu_hw_pipe { 361 struct dpu_hw_blk base; 362 struct dpu_hw_blk_reg_map hw; 363 struct dpu_mdss_cfg *catalog; 364 const struct dpu_mdp_cfg *mdp; 365 366 /* Pipe */ 367 enum dpu_sspp idx; 368 const struct dpu_sspp_cfg *cap; 369 370 /* Ops */ 371 struct dpu_hw_sspp_ops ops; 372 }; 373 374 struct dpu_kms; 375 /** 376 * dpu_hw_sspp_init - initializes the sspp hw driver object. 377 * Should be called once before accessing every pipe. 378 * @idx: Pipe index for which driver object is required 379 * @addr: Mapped register io address of MDP 380 * @catalog : Pointer to mdss catalog data 381 * @is_virtual_pipe: is this pipe virtual pipe 382 */ 383 struct dpu_hw_pipe *dpu_hw_sspp_init(enum dpu_sspp idx, 384 void __iomem *addr, struct dpu_mdss_cfg *catalog, 385 bool is_virtual_pipe); 386 387 /** 388 * dpu_hw_sspp_destroy(): Destroys SSPP driver context 389 * should be called during Hw pipe cleanup. 390 * @ctx: Pointer to SSPP driver context returned by dpu_hw_sspp_init 391 */ 392 void dpu_hw_sspp_destroy(struct dpu_hw_pipe *ctx); 393 394 void dpu_debugfs_sspp_init(struct dpu_kms *dpu_kms, struct dentry *debugfs_root); 395 int _dpu_hw_sspp_init_debugfs(struct dpu_hw_pipe *hw_pipe, struct dpu_kms *kms, struct dentry *entry); 396 397 #endif /*_DPU_HW_SSPP_H */ 398 399