1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#include "dm_services.h"
27
28#include "core_types.h"
29
30#include "reg_helper.h"
31#include "dcn10_dpp.h"
32#include "basics/conversion.h"
33
34
35#define NUM_PHASES 64
36#define HORZ_MAX_TAPS 8
37#define VERT_MAX_TAPS 8
38
39#define BLACK_OFFSET_RGB_Y 0x0
40#define BLACK_OFFSET_CBCR 0x8000
41
42#define REG(reg)\
43 dpp->tf_regs->reg
44
45#define CTX \
46 dpp->base.ctx
47
48#undef FN
49#define FN(reg_name, field_name) \
50 dpp->tf_shift->field_name, dpp->tf_mask->field_name
51
52enum dcn10_coef_filter_type_sel {
53 SCL_COEF_LUMA_VERT_FILTER = 0,
54 SCL_COEF_LUMA_HORZ_FILTER = 1,
55 SCL_COEF_CHROMA_VERT_FILTER = 2,
56 SCL_COEF_CHROMA_HORZ_FILTER = 3,
57 SCL_COEF_ALPHA_VERT_FILTER = 4,
58 SCL_COEF_ALPHA_HORZ_FILTER = 5
59};
60
61enum dscl_autocal_mode {
62 AUTOCAL_MODE_OFF = 0,
63
64
65
66
67 AUTOCAL_MODE_AUTOSCALE = 1,
68
69
70
71 AUTOCAL_MODE_AUTOCENTER = 2,
72
73
74
75 AUTOCAL_MODE_AUTOREPLICATE = 3
76};
77
78enum dscl_mode_sel {
79 DSCL_MODE_SCALING_444_BYPASS = 0,
80 DSCL_MODE_SCALING_444_RGB_ENABLE = 1,
81 DSCL_MODE_SCALING_444_YCBCR_ENABLE = 2,
82 DSCL_MODE_SCALING_420_YCBCR_ENABLE = 3,
83 DSCL_MODE_SCALING_420_LUMA_BYPASS = 4,
84 DSCL_MODE_SCALING_420_CHROMA_BYPASS = 5,
85 DSCL_MODE_DSCL_BYPASS = 6
86};
87
88static void dpp1_dscl_set_overscan(
89 struct dcn10_dpp *dpp,
90 const struct scaler_data *data)
91{
92 uint32_t left = data->recout.x;
93 uint32_t top = data->recout.y;
94
95 int right = data->h_active - data->recout.x - data->recout.width;
96 int bottom = data->v_active - data->recout.y - data->recout.height;
97
98 if (right < 0) {
99 BREAK_TO_DEBUGGER();
100 right = 0;
101 }
102 if (bottom < 0) {
103 BREAK_TO_DEBUGGER();
104 bottom = 0;
105 }
106
107 REG_SET_2(DSCL_EXT_OVERSCAN_LEFT_RIGHT, 0,
108 EXT_OVERSCAN_LEFT, left,
109 EXT_OVERSCAN_RIGHT, right);
110
111 REG_SET_2(DSCL_EXT_OVERSCAN_TOP_BOTTOM, 0,
112 EXT_OVERSCAN_BOTTOM, bottom,
113 EXT_OVERSCAN_TOP, top);
114}
115
116static void dpp1_dscl_set_otg_blank(
117 struct dcn10_dpp *dpp, const struct scaler_data *data)
118{
119 uint32_t h_blank_start = data->h_active;
120 uint32_t h_blank_end = 0;
121 uint32_t v_blank_start = data->v_active;
122 uint32_t v_blank_end = 0;
123
124 REG_SET_2(OTG_H_BLANK, 0,
125 OTG_H_BLANK_START, h_blank_start,
126 OTG_H_BLANK_END, h_blank_end);
127
128 REG_SET_2(OTG_V_BLANK, 0,
129 OTG_V_BLANK_START, v_blank_start,
130 OTG_V_BLANK_END, v_blank_end);
131}
132
133static int dpp1_dscl_get_pixel_depth_val(enum lb_pixel_depth depth)
134{
135 if (depth == LB_PIXEL_DEPTH_30BPP)
136 return 0;
137 else if (depth == LB_PIXEL_DEPTH_24BPP)
138 return 1;
139 else if (depth == LB_PIXEL_DEPTH_18BPP)
140 return 2;
141 else if (depth == LB_PIXEL_DEPTH_36BPP)
142 return 3;
143 else {
144 ASSERT(0);
145 return -1;
146 }
147}
148
149static bool dpp1_dscl_is_video_format(enum pixel_format format)
150{
151 if (format >= PIXEL_FORMAT_VIDEO_BEGIN
152 && format <= PIXEL_FORMAT_VIDEO_END)
153 return true;
154 else
155 return false;
156}
157
158static bool dpp1_dscl_is_420_format(enum pixel_format format)
159{
160 if (format == PIXEL_FORMAT_420BPP8 ||
161 format == PIXEL_FORMAT_420BPP10)
162 return true;
163 else
164 return false;
165}
166
167static enum dscl_mode_sel dpp1_dscl_get_dscl_mode(
168 struct dpp *dpp_base,
169 const struct scaler_data *data,
170 bool dbg_always_scale)
171{
172 const long long one = dc_fixpt_one.value;
173
174 if (dpp_base->caps->dscl_data_proc_format == DSCL_DATA_PRCESSING_FIXED_FORMAT) {
175
176 if (data->format == PIXEL_FORMAT_FP16)
177 return DSCL_MODE_DSCL_BYPASS;
178 }
179
180 if (data->ratios.horz.value == one
181 && data->ratios.vert.value == one
182 && data->ratios.horz_c.value == one
183 && data->ratios.vert_c.value == one
184 && !dbg_always_scale)
185 return DSCL_MODE_SCALING_444_BYPASS;
186
187 if (!dpp1_dscl_is_420_format(data->format)) {
188 if (dpp1_dscl_is_video_format(data->format))
189 return DSCL_MODE_SCALING_444_YCBCR_ENABLE;
190 else
191 return DSCL_MODE_SCALING_444_RGB_ENABLE;
192 }
193 if (data->ratios.horz.value == one && data->ratios.vert.value == one)
194 return DSCL_MODE_SCALING_420_LUMA_BYPASS;
195 if (data->ratios.horz_c.value == one && data->ratios.vert_c.value == one)
196 return DSCL_MODE_SCALING_420_CHROMA_BYPASS;
197
198 return DSCL_MODE_SCALING_420_YCBCR_ENABLE;
199}
200
201static void dpp1_dscl_set_lb(
202 struct dcn10_dpp *dpp,
203 const struct line_buffer_params *lb_params,
204 enum lb_memory_config mem_size_config)
205{
206
207 if (dpp->base.caps->dscl_data_proc_format == DSCL_DATA_PRCESSING_FIXED_FORMAT) {
208
209 uint32_t pixel_depth = dpp1_dscl_get_pixel_depth_val(lb_params->depth);
210 uint32_t dyn_pix_depth = lb_params->dynamic_pixel_depth;
211
212 REG_SET_7(LB_DATA_FORMAT, 0,
213 PIXEL_DEPTH, pixel_depth,
214 PIXEL_EXPAN_MODE, lb_params->pixel_expan_mode,
215 PIXEL_REDUCE_MODE, 1,
216 DYNAMIC_PIXEL_DEPTH, dyn_pix_depth,
217 DITHER_EN, 0,
218 INTERLEAVE_EN, lb_params->interleave_en,
219 LB_DATA_FORMAT__ALPHA_EN, lb_params->alpha_en);
220 }
221
222 REG_SET_2(LB_MEMORY_CTRL, 0,
223 MEMORY_CONFIG, mem_size_config,
224 LB_MAX_PARTITIONS, 63);
225}
226
227static const uint16_t *dpp1_dscl_get_filter_coeffs_64p(int taps, struct fixed31_32 ratio)
228{
229 if (taps == 8)
230 return get_filter_8tap_64p(ratio);
231 else if (taps == 7)
232 return get_filter_7tap_64p(ratio);
233 else if (taps == 6)
234 return get_filter_6tap_64p(ratio);
235 else if (taps == 5)
236 return get_filter_5tap_64p(ratio);
237 else if (taps == 4)
238 return get_filter_4tap_64p(ratio);
239 else if (taps == 3)
240 return get_filter_3tap_64p(ratio);
241 else if (taps == 2)
242 return get_filter_2tap_64p();
243 else if (taps == 1)
244 return NULL;
245 else {
246
247 BREAK_TO_DEBUGGER();
248 return NULL;
249 }
250}
251
252static void dpp1_dscl_set_scaler_filter(
253 struct dcn10_dpp *dpp,
254 uint32_t taps,
255 enum dcn10_coef_filter_type_sel filter_type,
256 const uint16_t *filter)
257{
258 const int tap_pairs = (taps + 1) / 2;
259 int phase;
260 int pair;
261 uint16_t odd_coef, even_coef;
262
263 REG_SET_3(SCL_COEF_RAM_TAP_SELECT, 0,
264 SCL_COEF_RAM_TAP_PAIR_IDX, 0,
265 SCL_COEF_RAM_PHASE, 0,
266 SCL_COEF_RAM_FILTER_TYPE, filter_type);
267
268 for (phase = 0; phase < (NUM_PHASES / 2 + 1); phase++) {
269 for (pair = 0; pair < tap_pairs; pair++) {
270 even_coef = filter[phase * taps + 2 * pair];
271 if ((pair * 2 + 1) < taps)
272 odd_coef = filter[phase * taps + 2 * pair + 1];
273 else
274 odd_coef = 0;
275
276 REG_SET_4(SCL_COEF_RAM_TAP_DATA, 0,
277
278 SCL_COEF_RAM_EVEN_TAP_COEF, even_coef,
279
280 SCL_COEF_RAM_EVEN_TAP_COEF_EN, 1,
281
282 SCL_COEF_RAM_ODD_TAP_COEF, odd_coef,
283
284 SCL_COEF_RAM_ODD_TAP_COEF_EN, 1);
285 }
286 }
287
288}
289
290static void dpp1_dscl_set_scl_filter(
291 struct dcn10_dpp *dpp,
292 const struct scaler_data *scl_data,
293 bool chroma_coef_mode)
294{
295 bool h_2tap_hardcode_coef_en = false;
296 bool v_2tap_hardcode_coef_en = false;
297 bool h_2tap_sharp_en = false;
298 bool v_2tap_sharp_en = false;
299 uint32_t h_2tap_sharp_factor = scl_data->sharpness.horz;
300 uint32_t v_2tap_sharp_factor = scl_data->sharpness.vert;
301 bool coef_ram_current;
302 const uint16_t *filter_h = NULL;
303 const uint16_t *filter_v = NULL;
304 const uint16_t *filter_h_c = NULL;
305 const uint16_t *filter_v_c = NULL;
306
307 h_2tap_hardcode_coef_en = scl_data->taps.h_taps < 3
308 && scl_data->taps.h_taps_c < 3
309 && (scl_data->taps.h_taps > 1 && scl_data->taps.h_taps_c > 1);
310 v_2tap_hardcode_coef_en = scl_data->taps.v_taps < 3
311 && scl_data->taps.v_taps_c < 3
312 && (scl_data->taps.v_taps > 1 && scl_data->taps.v_taps_c > 1);
313
314 h_2tap_sharp_en = h_2tap_hardcode_coef_en && h_2tap_sharp_factor != 0;
315 v_2tap_sharp_en = v_2tap_hardcode_coef_en && v_2tap_sharp_factor != 0;
316
317 REG_UPDATE_6(DSCL_2TAP_CONTROL,
318 SCL_H_2TAP_HARDCODE_COEF_EN, h_2tap_hardcode_coef_en,
319 SCL_H_2TAP_SHARP_EN, h_2tap_sharp_en,
320 SCL_H_2TAP_SHARP_FACTOR, h_2tap_sharp_factor,
321 SCL_V_2TAP_HARDCODE_COEF_EN, v_2tap_hardcode_coef_en,
322 SCL_V_2TAP_SHARP_EN, v_2tap_sharp_en,
323 SCL_V_2TAP_SHARP_FACTOR, v_2tap_sharp_factor);
324
325 if (!v_2tap_hardcode_coef_en || !h_2tap_hardcode_coef_en) {
326 bool filter_updated = false;
327
328 filter_h = dpp1_dscl_get_filter_coeffs_64p(
329 scl_data->taps.h_taps, scl_data->ratios.horz);
330 filter_v = dpp1_dscl_get_filter_coeffs_64p(
331 scl_data->taps.v_taps, scl_data->ratios.vert);
332
333 filter_updated = (filter_h && (filter_h != dpp->filter_h))
334 || (filter_v && (filter_v != dpp->filter_v));
335
336 if (chroma_coef_mode) {
337 filter_h_c = dpp1_dscl_get_filter_coeffs_64p(
338 scl_data->taps.h_taps_c, scl_data->ratios.horz_c);
339 filter_v_c = dpp1_dscl_get_filter_coeffs_64p(
340 scl_data->taps.v_taps_c, scl_data->ratios.vert_c);
341 filter_updated = filter_updated || (filter_h_c && (filter_h_c != dpp->filter_h_c))
342 || (filter_v_c && (filter_v_c != dpp->filter_v_c));
343 }
344
345 if (filter_updated) {
346 uint32_t scl_mode = REG_READ(SCL_MODE);
347
348 if (!h_2tap_hardcode_coef_en && filter_h) {
349 dpp1_dscl_set_scaler_filter(
350 dpp, scl_data->taps.h_taps,
351 SCL_COEF_LUMA_HORZ_FILTER, filter_h);
352 }
353 dpp->filter_h = filter_h;
354 if (!v_2tap_hardcode_coef_en && filter_v) {
355 dpp1_dscl_set_scaler_filter(
356 dpp, scl_data->taps.v_taps,
357 SCL_COEF_LUMA_VERT_FILTER, filter_v);
358 }
359 dpp->filter_v = filter_v;
360 if (chroma_coef_mode) {
361 if (!h_2tap_hardcode_coef_en && filter_h_c) {
362 dpp1_dscl_set_scaler_filter(
363 dpp, scl_data->taps.h_taps_c,
364 SCL_COEF_CHROMA_HORZ_FILTER, filter_h_c);
365 }
366 if (!v_2tap_hardcode_coef_en && filter_v_c) {
367 dpp1_dscl_set_scaler_filter(
368 dpp, scl_data->taps.v_taps_c,
369 SCL_COEF_CHROMA_VERT_FILTER, filter_v_c);
370 }
371 }
372 dpp->filter_h_c = filter_h_c;
373 dpp->filter_v_c = filter_v_c;
374
375 coef_ram_current = get_reg_field_value_ex(
376 scl_mode, dpp->tf_mask->SCL_COEF_RAM_SELECT_CURRENT,
377 dpp->tf_shift->SCL_COEF_RAM_SELECT_CURRENT);
378
379
380 REG_SET_2(SCL_MODE, scl_mode,
381 SCL_COEF_RAM_SELECT, !coef_ram_current,
382 SCL_CHROMA_COEF_MODE, chroma_coef_mode);
383 }
384 }
385}
386
387static int dpp1_dscl_get_lb_depth_bpc(enum lb_pixel_depth depth)
388{
389 if (depth == LB_PIXEL_DEPTH_30BPP)
390 return 10;
391 else if (depth == LB_PIXEL_DEPTH_24BPP)
392 return 8;
393 else if (depth == LB_PIXEL_DEPTH_18BPP)
394 return 6;
395 else if (depth == LB_PIXEL_DEPTH_36BPP)
396 return 12;
397 else {
398 BREAK_TO_DEBUGGER();
399 return -1;
400 }
401}
402
403void dpp1_dscl_calc_lb_num_partitions(
404 const struct scaler_data *scl_data,
405 enum lb_memory_config lb_config,
406 int *num_part_y,
407 int *num_part_c)
408{
409 int lb_memory_size, lb_memory_size_c, lb_memory_size_a, num_partitions_a,
410 lb_bpc, memory_line_size_y, memory_line_size_c, memory_line_size_a;
411
412 int line_size = scl_data->viewport.width < scl_data->recout.width ?
413 scl_data->viewport.width : scl_data->recout.width;
414 int line_size_c = scl_data->viewport_c.width < scl_data->recout.width ?
415 scl_data->viewport_c.width : scl_data->recout.width;
416
417 if (line_size == 0)
418 line_size = 1;
419
420 if (line_size_c == 0)
421 line_size_c = 1;
422
423
424 lb_bpc = dpp1_dscl_get_lb_depth_bpc(scl_data->lb_params.depth);
425 memory_line_size_y = (line_size * lb_bpc + 71) / 72;
426 memory_line_size_c = (line_size_c * lb_bpc + 71) / 72;
427 memory_line_size_a = (line_size + 5) / 6;
428
429 if (lb_config == LB_MEMORY_CONFIG_1) {
430 lb_memory_size = 816;
431 lb_memory_size_c = 816;
432 lb_memory_size_a = 984;
433 } else if (lb_config == LB_MEMORY_CONFIG_2) {
434 lb_memory_size = 1088;
435 lb_memory_size_c = 1088;
436 lb_memory_size_a = 1312;
437 } else if (lb_config == LB_MEMORY_CONFIG_3) {
438
439 lb_memory_size = 816 + 1088 + 848 + 848 + 848;
440 lb_memory_size_c = 816 + 1088;
441 lb_memory_size_a = 984 + 1312 + 456;
442 } else {
443 lb_memory_size = 816 + 1088 + 848;
444 lb_memory_size_c = 816 + 1088 + 848;
445 lb_memory_size_a = 984 + 1312 + 456;
446 }
447 *num_part_y = lb_memory_size / memory_line_size_y;
448 *num_part_c = lb_memory_size_c / memory_line_size_c;
449 num_partitions_a = lb_memory_size_a / memory_line_size_a;
450
451 if (scl_data->lb_params.alpha_en
452 && (num_partitions_a < *num_part_y))
453 *num_part_y = num_partitions_a;
454
455 if (*num_part_y > 64)
456 *num_part_y = 64;
457 if (*num_part_c > 64)
458 *num_part_c = 64;
459
460}
461
462bool dpp1_dscl_is_lb_conf_valid(int ceil_vratio, int num_partitions, int vtaps)
463{
464 if (ceil_vratio > 2)
465 return vtaps <= (num_partitions - ceil_vratio + 2);
466 else
467 return vtaps <= num_partitions;
468}
469
470
471static enum lb_memory_config dpp1_dscl_find_lb_memory_config(struct dcn10_dpp *dpp,
472 const struct scaler_data *scl_data)
473{
474 int num_part_y, num_part_c;
475 int vtaps = scl_data->taps.v_taps;
476 int vtaps_c = scl_data->taps.v_taps_c;
477 int ceil_vratio = dc_fixpt_ceil(scl_data->ratios.vert);
478 int ceil_vratio_c = dc_fixpt_ceil(scl_data->ratios.vert_c);
479 enum lb_memory_config mem_cfg = LB_MEMORY_CONFIG_0;
480
481 if (dpp->base.ctx->dc->debug.use_max_lb)
482 return mem_cfg;
483
484 dpp->base.caps->dscl_calc_lb_num_partitions(
485 scl_data, LB_MEMORY_CONFIG_1, &num_part_y, &num_part_c);
486
487 if (dpp1_dscl_is_lb_conf_valid(ceil_vratio, num_part_y, vtaps)
488 && dpp1_dscl_is_lb_conf_valid(ceil_vratio_c, num_part_c, vtaps_c))
489 return LB_MEMORY_CONFIG_1;
490
491 dpp->base.caps->dscl_calc_lb_num_partitions(
492 scl_data, LB_MEMORY_CONFIG_2, &num_part_y, &num_part_c);
493
494 if (dpp1_dscl_is_lb_conf_valid(ceil_vratio, num_part_y, vtaps)
495 && dpp1_dscl_is_lb_conf_valid(ceil_vratio_c, num_part_c, vtaps_c))
496 return LB_MEMORY_CONFIG_2;
497
498 if (scl_data->format == PIXEL_FORMAT_420BPP8
499 || scl_data->format == PIXEL_FORMAT_420BPP10) {
500 dpp->base.caps->dscl_calc_lb_num_partitions(
501 scl_data, LB_MEMORY_CONFIG_3, &num_part_y, &num_part_c);
502
503 if (dpp1_dscl_is_lb_conf_valid(ceil_vratio, num_part_y, vtaps)
504 && dpp1_dscl_is_lb_conf_valid(ceil_vratio_c, num_part_c, vtaps_c))
505 return LB_MEMORY_CONFIG_3;
506 }
507
508 dpp->base.caps->dscl_calc_lb_num_partitions(
509 scl_data, LB_MEMORY_CONFIG_0, &num_part_y, &num_part_c);
510
511
512 ASSERT(dpp1_dscl_is_lb_conf_valid(ceil_vratio, num_part_y, vtaps)
513 && dpp1_dscl_is_lb_conf_valid(ceil_vratio_c, num_part_c, vtaps_c));
514
515 return LB_MEMORY_CONFIG_0;
516}
517
518void dpp1_dscl_set_scaler_auto_scale(
519 struct dpp *dpp_base,
520 const struct scaler_data *scl_data)
521{
522 enum lb_memory_config lb_config;
523 struct dcn10_dpp *dpp = TO_DCN10_DPP(dpp_base);
524 enum dscl_mode_sel dscl_mode = dpp1_dscl_get_dscl_mode(
525 dpp_base, scl_data, dpp_base->ctx->dc->debug.always_scale);
526 bool ycbcr = scl_data->format >= PIXEL_FORMAT_VIDEO_BEGIN
527 && scl_data->format <= PIXEL_FORMAT_VIDEO_END;
528
529 dpp1_dscl_set_overscan(dpp, scl_data);
530
531 dpp1_dscl_set_otg_blank(dpp, scl_data);
532
533 REG_UPDATE(SCL_MODE, DSCL_MODE, dscl_mode);
534
535 if (dscl_mode == DSCL_MODE_DSCL_BYPASS)
536 return;
537
538 lb_config = dpp1_dscl_find_lb_memory_config(dpp, scl_data);
539 dpp1_dscl_set_lb(dpp, &scl_data->lb_params, lb_config);
540
541 if (dscl_mode == DSCL_MODE_SCALING_444_BYPASS)
542 return;
543
544
545 REG_SET_3(DSCL_AUTOCAL, 0,
546 AUTOCAL_MODE, AUTOCAL_MODE_AUTOSCALE,
547 AUTOCAL_NUM_PIPE, 0,
548 AUTOCAL_PIPE_ID, 0);
549
550
551 if (ycbcr)
552 REG_SET_2(SCL_BLACK_OFFSET, 0,
553 SCL_BLACK_OFFSET_RGB_Y, BLACK_OFFSET_RGB_Y,
554 SCL_BLACK_OFFSET_CBCR, BLACK_OFFSET_CBCR);
555 else
556
557 REG_SET_2(SCL_BLACK_OFFSET, 0,
558 SCL_BLACK_OFFSET_RGB_Y, BLACK_OFFSET_RGB_Y,
559 SCL_BLACK_OFFSET_CBCR, BLACK_OFFSET_RGB_Y);
560
561 REG_SET_4(SCL_TAP_CONTROL, 0,
562 SCL_V_NUM_TAPS, scl_data->taps.v_taps - 1,
563 SCL_H_NUM_TAPS, scl_data->taps.h_taps - 1,
564 SCL_V_NUM_TAPS_C, scl_data->taps.v_taps_c - 1,
565 SCL_H_NUM_TAPS_C, scl_data->taps.h_taps_c - 1);
566
567 dpp1_dscl_set_scl_filter(dpp, scl_data, ycbcr);
568}
569
570
571static void dpp1_dscl_set_manual_ratio_init(
572 struct dcn10_dpp *dpp, const struct scaler_data *data)
573{
574 uint32_t init_frac = 0;
575 uint32_t init_int = 0;
576
577 REG_SET(SCL_HORZ_FILTER_SCALE_RATIO, 0,
578 SCL_H_SCALE_RATIO, dc_fixpt_u3d19(data->ratios.horz) << 5);
579
580 REG_SET(SCL_VERT_FILTER_SCALE_RATIO, 0,
581 SCL_V_SCALE_RATIO, dc_fixpt_u3d19(data->ratios.vert) << 5);
582
583 REG_SET(SCL_HORZ_FILTER_SCALE_RATIO_C, 0,
584 SCL_H_SCALE_RATIO_C, dc_fixpt_u3d19(data->ratios.horz_c) << 5);
585
586 REG_SET(SCL_VERT_FILTER_SCALE_RATIO_C, 0,
587 SCL_V_SCALE_RATIO_C, dc_fixpt_u3d19(data->ratios.vert_c) << 5);
588
589
590
591
592 init_frac = dc_fixpt_u0d19(data->inits.h) << 5;
593 init_int = dc_fixpt_floor(data->inits.h);
594 REG_SET_2(SCL_HORZ_FILTER_INIT, 0,
595 SCL_H_INIT_FRAC, init_frac,
596 SCL_H_INIT_INT, init_int);
597
598 init_frac = dc_fixpt_u0d19(data->inits.h_c) << 5;
599 init_int = dc_fixpt_floor(data->inits.h_c);
600 REG_SET_2(SCL_HORZ_FILTER_INIT_C, 0,
601 SCL_H_INIT_FRAC_C, init_frac,
602 SCL_H_INIT_INT_C, init_int);
603
604 init_frac = dc_fixpt_u0d19(data->inits.v) << 5;
605 init_int = dc_fixpt_floor(data->inits.v);
606 REG_SET_2(SCL_VERT_FILTER_INIT, 0,
607 SCL_V_INIT_FRAC, init_frac,
608 SCL_V_INIT_INT, init_int);
609
610 if (REG(SCL_VERT_FILTER_INIT_BOT)) {
611 init_frac = dc_fixpt_u0d19(data->inits.v_bot) << 5;
612 init_int = dc_fixpt_floor(data->inits.v_bot);
613 REG_SET_2(SCL_VERT_FILTER_INIT_BOT, 0,
614 SCL_V_INIT_FRAC_BOT, init_frac,
615 SCL_V_INIT_INT_BOT, init_int);
616 }
617
618 init_frac = dc_fixpt_u0d19(data->inits.v_c) << 5;
619 init_int = dc_fixpt_floor(data->inits.v_c);
620 REG_SET_2(SCL_VERT_FILTER_INIT_C, 0,
621 SCL_V_INIT_FRAC_C, init_frac,
622 SCL_V_INIT_INT_C, init_int);
623
624 if (REG(SCL_VERT_FILTER_INIT_BOT_C)) {
625 init_frac = dc_fixpt_u0d19(data->inits.v_c_bot) << 5;
626 init_int = dc_fixpt_floor(data->inits.v_c_bot);
627 REG_SET_2(SCL_VERT_FILTER_INIT_BOT_C, 0,
628 SCL_V_INIT_FRAC_BOT_C, init_frac,
629 SCL_V_INIT_INT_BOT_C, init_int);
630 }
631}
632
633
634
635static void dpp1_dscl_set_recout(
636 struct dcn10_dpp *dpp, const struct rect *recout)
637{
638 int visual_confirm_on = 0;
639 if (dpp->base.ctx->dc->debug.visual_confirm != VISUAL_CONFIRM_DISABLE)
640 visual_confirm_on = 1;
641
642 REG_SET_2(RECOUT_START, 0,
643
644 RECOUT_START_X, recout->x,
645
646 RECOUT_START_Y, recout->y);
647
648 REG_SET_2(RECOUT_SIZE, 0,
649
650 RECOUT_WIDTH, recout->width,
651
652 RECOUT_HEIGHT, recout->height
653 - visual_confirm_on * 4 * (dpp->base.inst + 1));
654}
655
656
657void dpp1_dscl_set_scaler_manual_scale(
658 struct dpp *dpp_base,
659 const struct scaler_data *scl_data)
660{
661 enum lb_memory_config lb_config;
662 struct dcn10_dpp *dpp = TO_DCN10_DPP(dpp_base);
663 enum dscl_mode_sel dscl_mode = dpp1_dscl_get_dscl_mode(
664 dpp_base, scl_data, dpp_base->ctx->dc->debug.always_scale);
665 bool ycbcr = scl_data->format >= PIXEL_FORMAT_VIDEO_BEGIN
666 && scl_data->format <= PIXEL_FORMAT_VIDEO_END;
667
668 if (memcmp(&dpp->scl_data, scl_data, sizeof(*scl_data)) == 0)
669 return;
670
671 PERF_TRACE();
672
673 dpp->scl_data = *scl_data;
674
675
676 REG_SET_3(DSCL_AUTOCAL, 0,
677 AUTOCAL_MODE, AUTOCAL_MODE_OFF,
678 AUTOCAL_NUM_PIPE, 0,
679 AUTOCAL_PIPE_ID, 0);
680
681
682 dpp1_dscl_set_recout(dpp, &scl_data->recout);
683
684
685 REG_SET_2(MPC_SIZE, 0,
686
687 MPC_WIDTH, scl_data->h_active,
688
689 MPC_HEIGHT, scl_data->v_active);
690
691
692 REG_UPDATE(SCL_MODE, DSCL_MODE, dscl_mode);
693
694 if (dscl_mode == DSCL_MODE_DSCL_BYPASS)
695 return;
696
697
698 lb_config = dpp1_dscl_find_lb_memory_config(dpp, scl_data);
699 dpp1_dscl_set_lb(dpp, &scl_data->lb_params, lb_config);
700
701 if (dscl_mode == DSCL_MODE_SCALING_444_BYPASS)
702 return;
703
704
705 if (REG(SCL_BLACK_OFFSET)) {
706 if (ycbcr)
707 REG_SET_2(SCL_BLACK_OFFSET, 0,
708 SCL_BLACK_OFFSET_RGB_Y, BLACK_OFFSET_RGB_Y,
709 SCL_BLACK_OFFSET_CBCR, BLACK_OFFSET_CBCR);
710 else
711
712 REG_SET_2(SCL_BLACK_OFFSET, 0,
713 SCL_BLACK_OFFSET_RGB_Y, BLACK_OFFSET_RGB_Y,
714 SCL_BLACK_OFFSET_CBCR, BLACK_OFFSET_RGB_Y);
715 }
716
717
718 dpp1_dscl_set_manual_ratio_init(dpp, scl_data);
719
720
721 REG_SET_4(SCL_TAP_CONTROL, 0,
722 SCL_V_NUM_TAPS, scl_data->taps.v_taps - 1,
723 SCL_H_NUM_TAPS, scl_data->taps.h_taps - 1,
724 SCL_V_NUM_TAPS_C, scl_data->taps.v_taps_c - 1,
725 SCL_H_NUM_TAPS_C, scl_data->taps.h_taps_c - 1);
726
727 dpp1_dscl_set_scl_filter(dpp, scl_data, ycbcr);
728 PERF_TRACE();
729}
730