1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
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"
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)
26 * Define all scaler feature bits in catalog
28 #define DPU_SSPP_SCALER ((1UL << DPU_SSPP_SCALER_RGB) | \
29 (1UL << DPU_SSPP_SCALER_QSEED2) | \
30 (1UL << DPU_SSPP_SCALER_QSEED3))
45 * DPU_SSPP_RECT_SOLO - multirect disabled
46 * DPU_SSPP_RECT_0 - rect0 of a multirect pipe
47 * DPU_SSPP_RECT_1 - rect1 of a multirect pipe
49 * Note: HW supports multirect with either RECT0 or
50 * RECT1. Considering no benefit of such configs over
51 * SOLO mode and to keep the plane management simple,
52 * we dont support single rect multirect configs.
54 enum dpu_sspp_multirect_index {
55 DPU_SSPP_RECT_SOLO = 0,
60 enum dpu_sspp_multirect_mode {
61 DPU_SSPP_MULTIRECT_NONE = 0,
62 DPU_SSPP_MULTIRECT_PARALLEL,
63 DPU_SSPP_MULTIRECT_TIME_MX,
73 DPU_SCALE_FILTER_NEAREST = 0,
75 DPU_SCALE_FILTER_PCMN,
80 enum dpu_hw_filter_alpa {
81 DPU_SCALE_ALPHA_PIXEL_REP,
85 enum dpu_hw_filter_yuv {
92 struct dpu_hw_sharp_cfg {
99 struct dpu_hw_pixel_ext {
100 /* scaling factors are enabled for this input layer */
101 uint8_t enable_pxl_ext;
103 int init_phase_x[DPU_MAX_PLANES];
104 int phase_step_x[DPU_MAX_PLANES];
105 int init_phase_y[DPU_MAX_PLANES];
106 int phase_step_y[DPU_MAX_PLANES];
109 * Number of pixels extension in left, right, top and bottom direction
110 * for all color components. This pixel value for each color component
111 * should be sum of fetch + repeat pixels.
113 int num_ext_pxls_left[DPU_MAX_PLANES];
114 int num_ext_pxls_right[DPU_MAX_PLANES];
115 int num_ext_pxls_top[DPU_MAX_PLANES];
116 int num_ext_pxls_btm[DPU_MAX_PLANES];
119 * Number of pixels needs to be overfetched in left, right, top and
120 * bottom directions from source image for scaling.
122 int left_ftch[DPU_MAX_PLANES];
123 int right_ftch[DPU_MAX_PLANES];
124 int top_ftch[DPU_MAX_PLANES];
125 int btm_ftch[DPU_MAX_PLANES];
128 * Number of pixels needs to be repeated in left, right, top and
129 * bottom directions for scaling.
131 int left_rpt[DPU_MAX_PLANES];
132 int right_rpt[DPU_MAX_PLANES];
133 int top_rpt[DPU_MAX_PLANES];
134 int btm_rpt[DPU_MAX_PLANES];
136 uint32_t roi_w[DPU_MAX_PLANES];
137 uint32_t roi_h[DPU_MAX_PLANES];
140 * Filter type to be used for scaling in horizontal and vertical
143 enum dpu_hw_filter horz_filter[DPU_MAX_PLANES];
144 enum dpu_hw_filter vert_filter[DPU_MAX_PLANES];
149 * struct dpu_hw_pipe_cfg : Pipe description
150 * @layout: format layout information for programming buffer to hardware
151 * @src_rect: src ROI, caller takes into account the different operations
152 * such as decimation, flip etc to program this field
153 * @dest_rect: destination ROI.
154 * @index: index of the rectangle of SSPP
155 * @mode: parallel or time multiplex multirect mode
157 struct dpu_hw_pipe_cfg {
158 struct dpu_hw_fmt_layout layout;
159 struct drm_rect src_rect;
160 struct drm_rect dst_rect;
161 enum dpu_sspp_multirect_index index;
162 enum dpu_sspp_multirect_mode mode;
166 * struct dpu_hw_pipe_qos_cfg : Source pipe QoS configuration
167 * @danger_lut: LUT for generate danger level based on fill level
168 * @safe_lut: LUT for generate safe level based on fill level
169 * @creq_lut: LUT for generate creq level based on fill level
170 * @creq_vblank: creq value generated to vbif during vertical blanking
171 * @danger_vblank: danger value generated during vertical blanking
172 * @vblank_en: enable creq_vblank and danger_vblank during vblank
173 * @danger_safe_en: enable danger safe generation
175 struct dpu_hw_pipe_qos_cfg {
186 * enum CDP preload ahead address size
189 DPU_SSPP_CDP_PRELOAD_AHEAD_32,
190 DPU_SSPP_CDP_PRELOAD_AHEAD_64
194 * struct dpu_hw_pipe_cdp_cfg : CDP configuration
195 * @enable: true to enable CDP
196 * @ubwc_meta_enable: true to enable ubwc metadata preload
197 * @tile_amortize_enable: true to enable amortization control for tile format
198 * @preload_ahead: number of request to preload ahead
199 * DPU_SSPP_CDP_PRELOAD_AHEAD_32,
200 * DPU_SSPP_CDP_PRELOAD_AHEAD_64
202 struct dpu_hw_pipe_cdp_cfg {
204 bool ubwc_meta_enable;
205 bool tile_amortize_enable;
210 * struct dpu_hw_pipe_ts_cfg - traffic shaper configuration
211 * @size: size to prefill in bytes, or zero to disable
212 * @time: time to prefill in usec, or zero to disable
214 struct dpu_hw_pipe_ts_cfg {
220 * struct dpu_hw_sspp_ops - interface to the SSPP Hw driver functions
221 * Caller must call the init function to get the pipe context for each pipe
222 * Assumption is these functions will be called after clocks are enabled
224 struct dpu_hw_sspp_ops {
226 * setup_format - setup pixel format cropping rectangle, flip
227 * @ctx: Pointer to pipe context
228 * @cfg: Pointer to pipe config structure
229 * @flags: Extra flags for format config
230 * @index: rectangle index in multirect
232 void (*setup_format)(struct dpu_hw_pipe *ctx,
233 const struct dpu_format *fmt, u32 flags,
234 enum dpu_sspp_multirect_index index);
237 * setup_rects - setup pipe ROI rectangles
238 * @ctx: Pointer to pipe context
239 * @cfg: Pointer to pipe config structure
240 * @index: rectangle index in multirect
242 void (*setup_rects)(struct dpu_hw_pipe *ctx,
243 struct dpu_hw_pipe_cfg *cfg,
244 enum dpu_sspp_multirect_index index);
247 * setup_pe - setup pipe pixel extension
248 * @ctx: Pointer to pipe context
249 * @pe_ext: Pointer to pixel ext settings
251 void (*setup_pe)(struct dpu_hw_pipe *ctx,
252 struct dpu_hw_pixel_ext *pe_ext);
255 * setup_sourceaddress - setup pipe source addresses
256 * @ctx: Pointer to pipe context
257 * @cfg: Pointer to pipe config structure
258 * @index: rectangle index in multirect
260 void (*setup_sourceaddress)(struct dpu_hw_pipe *ctx,
261 struct dpu_hw_pipe_cfg *cfg,
262 enum dpu_sspp_multirect_index index);
265 * setup_csc - setup color space coversion
266 * @ctx: Pointer to pipe context
267 * @data: Pointer to config structure
269 void (*setup_csc)(struct dpu_hw_pipe *ctx, struct dpu_csc_cfg *data);
272 * setup_solidfill - enable/disable colorfill
273 * @ctx: Pointer to pipe context
274 * @const_color: Fill color value
276 * @index: rectangle index in multirect
278 void (*setup_solidfill)(struct dpu_hw_pipe *ctx, u32 color,
279 enum dpu_sspp_multirect_index index);
282 * setup_multirect - setup multirect configuration
283 * @ctx: Pointer to pipe context
284 * @index: rectangle index in multirect
285 * @mode: parallel fetch / time multiplex multirect mode
288 void (*setup_multirect)(struct dpu_hw_pipe *ctx,
289 enum dpu_sspp_multirect_index index,
290 enum dpu_sspp_multirect_mode mode);
293 * setup_sharpening - setup sharpening
294 * @ctx: Pointer to pipe context
295 * @cfg: Pointer to config structure
297 void (*setup_sharpening)(struct dpu_hw_pipe *ctx,
298 struct dpu_hw_sharp_cfg *cfg);
301 * setup_danger_safe_lut - setup danger safe LUTs
302 * @ctx: Pointer to pipe context
303 * @cfg: Pointer to pipe QoS configuration
306 void (*setup_danger_safe_lut)(struct dpu_hw_pipe *ctx,
307 struct dpu_hw_pipe_qos_cfg *cfg);
310 * setup_creq_lut - setup CREQ LUT
311 * @ctx: Pointer to pipe context
312 * @cfg: Pointer to pipe QoS configuration
315 void (*setup_creq_lut)(struct dpu_hw_pipe *ctx,
316 struct dpu_hw_pipe_qos_cfg *cfg);
319 * setup_qos_ctrl - setup QoS control
320 * @ctx: Pointer to pipe context
321 * @cfg: Pointer to pipe QoS configuration
324 void (*setup_qos_ctrl)(struct dpu_hw_pipe *ctx,
325 struct dpu_hw_pipe_qos_cfg *cfg);
328 * setup_histogram - setup histograms
329 * @ctx: Pointer to pipe context
330 * @cfg: Pointer to histogram configuration
332 void (*setup_histogram)(struct dpu_hw_pipe *ctx,
336 * setup_scaler - setup scaler
337 * @ctx: Pointer to pipe context
338 * @pipe_cfg: Pointer to pipe configuration
339 * @pe_cfg: Pointer to pixel extension configuration
340 * @scaler_cfg: Pointer to scaler configuration
342 void (*setup_scaler)(struct dpu_hw_pipe *ctx,
343 struct dpu_hw_pipe_cfg *pipe_cfg,
344 struct dpu_hw_pixel_ext *pe_cfg,
348 * get_scaler_ver - get scaler h/w version
349 * @ctx: Pointer to pipe context
351 u32 (*get_scaler_ver)(struct dpu_hw_pipe *ctx);
354 * setup_cdp - setup client driven prefetch
355 * @ctx: Pointer to pipe context
356 * @cfg: Pointer to cdp configuration
358 void (*setup_cdp)(struct dpu_hw_pipe *ctx,
359 struct dpu_hw_pipe_cdp_cfg *cfg);
363 * struct dpu_hw_pipe - pipe description
364 * @base: hardware block base structure
365 * @hw: block hardware details
366 * @catalog: back pointer to catalog
367 * @mdp: pointer to associated mdp portion of the catalog
369 * @cap: pointer to layer_cfg
370 * @ops: pointer to operations possible for this pipe
373 struct dpu_hw_blk base;
374 struct dpu_hw_blk_reg_map hw;
375 struct dpu_mdss_cfg *catalog;
376 struct dpu_mdp_cfg *mdp;
380 const struct dpu_sspp_cfg *cap;
383 struct dpu_hw_sspp_ops ops;
387 * dpu_hw_sspp_init - initializes the sspp hw driver object.
388 * Should be called once before accessing every pipe.
389 * @idx: Pipe index for which driver object is required
390 * @addr: Mapped register io address of MDP
391 * @catalog : Pointer to mdss catalog data
392 * @is_virtual_pipe: is this pipe virtual pipe
394 struct dpu_hw_pipe *dpu_hw_sspp_init(enum dpu_sspp idx,
395 void __iomem *addr, struct dpu_mdss_cfg *catalog,
396 bool is_virtual_pipe);
399 * dpu_hw_sspp_destroy(): Destroys SSPP driver context
400 * should be called during Hw pipe cleanup.
401 * @ctx: Pointer to SSPP driver context returned by dpu_hw_sspp_init
403 void dpu_hw_sspp_destroy(struct dpu_hw_pipe *ctx);
405 #endif /*_DPU_HW_SSPP_H */