Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amd/display: remove dc dependencies from SPL library

[Why]
Make SPL library dc-independent so it can be reused by other
components

[How]
Create separate set of fixed31_32 calls in SPL
Make all inputs and outputs to SPL use primitive types
For ratios and inits, return as uint32 from SPL. So
add conversion from uint32 back to fixed point in
SPL-to-dc translate function

Reviewed-by: Relja Vojvodic <relja.vojvodic@amd.com>
Signed-off-by: Jerry Zuo <jerry.zuo@amd.com>
Signed-off-by: Samson Tam <samson.tam@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Samson Tam and committed by
Alex Deucher
f8220070 a41d58fb

+1645 -431
+27
drivers/gpu/drm/amd/display/dc/basics/fixpt31_32.c
··· 486 486 else 487 487 return ux_dy(arg.value, 4, 19); 488 488 } 489 + 490 + struct fixed31_32 dc_fixpt_from_ux_dy(unsigned int value, 491 + unsigned int integer_bits, 492 + unsigned int fractional_bits) 493 + { 494 + struct fixed31_32 fixpt_value = dc_fixpt_zero; 495 + struct fixed31_32 fixpt_int_value = dc_fixpt_zero; 496 + long long frac_mask = ((long long)1 << (long long)integer_bits) - 1; 497 + 498 + fixpt_value.value = (long long)value << (FIXED31_32_BITS_PER_FRACTIONAL_PART - fractional_bits); 499 + frac_mask = frac_mask << fractional_bits; 500 + fixpt_int_value.value = value & frac_mask; 501 + fixpt_int_value.value <<= (FIXED31_32_BITS_PER_FRACTIONAL_PART - fractional_bits); 502 + fixpt_value.value |= fixpt_int_value.value; 503 + return fixpt_value; 504 + } 505 + 506 + struct fixed31_32 dc_fixpt_from_int_dy(unsigned int int_value, 507 + unsigned int frac_value, 508 + unsigned int integer_bits, 509 + unsigned int fractional_bits) 510 + { 511 + struct fixed31_32 fixpt_value = dc_fixpt_from_int(int_value); 512 + 513 + fixpt_value.value |= (long long)frac_value << (FIXED31_32_BITS_PER_FRACTIONAL_PART - fractional_bits); 514 + return fixpt_value; 515 + }
-2
drivers/gpu/drm/amd/display/dc/core/dc_resource.c
··· 1511 1511 pipe_ctx->plane_res.scl_data.lb_params.depth = LB_PIXEL_DEPTH_30BPP; 1512 1512 1513 1513 pipe_ctx->plane_res.scl_data.lb_params.alpha_en = plane_state->per_pixel_alpha; 1514 - spl_out->scl_data.h_active = pipe_ctx->plane_res.scl_data.h_active; 1515 - spl_out->scl_data.v_active = pipe_ctx->plane_res.scl_data.v_active; 1516 1514 1517 1515 // Convert pipe_ctx to respective input params for SPL 1518 1516 translate_SPL_in_params_from_pipe_ctx(pipe_ctx, spl_in);
+23 -20
drivers/gpu/drm/amd/display/dc/dc_spl_translate.c
··· 42 42 static void populate_taps_from_spltaps(struct scaling_taps *scaling_quality, 43 43 const struct spl_taps *spl_scaling_quality) 44 44 { 45 - scaling_quality->h_taps_c = spl_scaling_quality->h_taps_c; 46 - scaling_quality->h_taps = spl_scaling_quality->h_taps; 47 - scaling_quality->v_taps_c = spl_scaling_quality->v_taps_c; 48 - scaling_quality->v_taps = spl_scaling_quality->v_taps; 45 + scaling_quality->h_taps_c = spl_scaling_quality->h_taps_c + 1; 46 + scaling_quality->h_taps = spl_scaling_quality->h_taps + 1; 47 + scaling_quality->v_taps_c = spl_scaling_quality->v_taps_c + 1; 48 + scaling_quality->v_taps = spl_scaling_quality->v_taps + 1; 49 49 } 50 50 static void populate_ratios_from_splratios(struct scaling_ratios *ratios, 51 - const struct spl_ratios *spl_ratios) 51 + const struct ratio *spl_ratios) 52 52 { 53 - ratios->horz = spl_ratios->horz; 54 - ratios->vert = spl_ratios->vert; 55 - ratios->horz_c = spl_ratios->horz_c; 56 - ratios->vert_c = spl_ratios->vert_c; 53 + ratios->horz = dc_fixpt_from_ux_dy(spl_ratios->h_scale_ratio >> 5, 3, 19); 54 + ratios->vert = dc_fixpt_from_ux_dy(spl_ratios->v_scale_ratio >> 5, 3, 19); 55 + ratios->horz_c = dc_fixpt_from_ux_dy(spl_ratios->h_scale_ratio_c >> 5, 3, 19); 56 + ratios->vert_c = dc_fixpt_from_ux_dy(spl_ratios->v_scale_ratio_c >> 5, 3, 19); 57 57 } 58 58 static void populate_inits_from_splinits(struct scl_inits *inits, 59 - const struct spl_inits *spl_inits) 59 + const struct init *spl_inits) 60 60 { 61 - inits->h = spl_inits->h; 62 - inits->v = spl_inits->v; 63 - inits->h_c = spl_inits->h_c; 64 - inits->v_c = spl_inits->v_c; 61 + inits->h = dc_fixpt_from_int_dy(spl_inits->h_filter_init_int, spl_inits->h_filter_init_frac >> 5, 0, 19); 62 + inits->v = dc_fixpt_from_int_dy(spl_inits->v_filter_init_int, spl_inits->v_filter_init_frac >> 5, 0, 19); 63 + inits->h_c = dc_fixpt_from_int_dy(spl_inits->h_filter_init_int_c, spl_inits->h_filter_init_frac_c >> 5, 0, 19); 64 + inits->v_c = dc_fixpt_from_int_dy(spl_inits->v_filter_init_int_c, spl_inits->v_filter_init_frac_c >> 5, 0, 19); 65 65 } 66 66 /// @brief Translate SPL input parameters from pipe context 67 67 /// @param pipe_ctx ··· 170 170 /* Translate transfer function */ 171 171 spl_in->basic_in.tf_type = (enum spl_transfer_func_type) plane_state->in_transfer_func.type; 172 172 spl_in->basic_in.tf_predefined_type = (enum spl_transfer_func_predefined) plane_state->in_transfer_func.tf; 173 + 174 + spl_in->h_active = pipe_ctx->plane_res.scl_data.h_active; 175 + spl_in->v_active = pipe_ctx->plane_res.scl_data.v_active; 173 176 /* Check if it is stream is in fullscreen and if its HDR. 174 177 * Use this to determine sharpness levels 175 178 */ ··· 187 184 void translate_SPL_out_params_to_pipe_ctx(struct pipe_ctx *pipe_ctx, struct spl_out *spl_out) 188 185 { 189 186 // Make scaler data recout point to spl output field recout 190 - populate_rect_from_splrect(&pipe_ctx->plane_res.scl_data.recout, &spl_out->scl_data.recout); 187 + populate_rect_from_splrect(&pipe_ctx->plane_res.scl_data.recout, &spl_out->dscl_prog_data->recout); 191 188 // Make scaler data ratios point to spl output field ratios 192 - populate_ratios_from_splratios(&pipe_ctx->plane_res.scl_data.ratios, &spl_out->scl_data.ratios); 189 + populate_ratios_from_splratios(&pipe_ctx->plane_res.scl_data.ratios, &spl_out->dscl_prog_data->ratios); 193 190 // Make scaler data viewport point to spl output field viewport 194 - populate_rect_from_splrect(&pipe_ctx->plane_res.scl_data.viewport, &spl_out->scl_data.viewport); 191 + populate_rect_from_splrect(&pipe_ctx->plane_res.scl_data.viewport, &spl_out->dscl_prog_data->viewport); 195 192 // Make scaler data viewport_c point to spl output field viewport_c 196 - populate_rect_from_splrect(&pipe_ctx->plane_res.scl_data.viewport_c, &spl_out->scl_data.viewport_c); 193 + populate_rect_from_splrect(&pipe_ctx->plane_res.scl_data.viewport_c, &spl_out->dscl_prog_data->viewport_c); 197 194 // Make scaler data taps point to spl output field scaling taps 198 - populate_taps_from_spltaps(&pipe_ctx->plane_res.scl_data.taps, &spl_out->scl_data.taps); 195 + populate_taps_from_spltaps(&pipe_ctx->plane_res.scl_data.taps, &spl_out->dscl_prog_data->taps); 199 196 // Make scaler data init point to spl output field init 200 - populate_inits_from_splinits(&pipe_ctx->plane_res.scl_data.inits, &spl_out->scl_data.inits); 197 + populate_inits_from_splinits(&pipe_ctx->plane_res.scl_data.inits, &spl_out->dscl_prog_data->init); 201 198 }
+1 -1
drivers/gpu/drm/amd/display/dc/spl/Makefile
··· 23 23 # Makefile for the 'spl' sub-component of DAL. 24 24 # It provides the scaling library interface. 25 25 26 - SPL = dc_spl.o dc_spl_scl_filters.o dc_spl_scl_easf_filters.o dc_spl_isharp_filters.o dc_spl_filters.o 26 + SPL = dc_spl.o dc_spl_scl_filters.o dc_spl_scl_easf_filters.o dc_spl_isharp_filters.o dc_spl_filters.o spl_fixpt31_32.o 27 27 28 28 AMD_DAL_SPL = $(addprefix $(AMDDALPATH)/dc/spl/,$(SPL)) 29 29
+286 -278
drivers/gpu/drm/amd/display/dc/spl/dc_spl.c
··· 4 4 5 5 #include "dc_spl.h" 6 6 #include "dc_spl_scl_filters.h" 7 - #include "dc_spl_isharp_filters.h" 8 7 #include "dc_spl_scl_easf_filters.h" 8 + #include "dc_spl_isharp_filters.h" 9 + #include "spl_debug.h" 9 10 10 - #define IDENTITY_RATIO(ratio) (dc_fixpt_u2d19(ratio) == (1 << 19)) 11 + #define IDENTITY_RATIO(ratio) (spl_fixpt_u2d19(ratio) == (1 << 19)) 11 12 #define MIN_VIEWPORT_SIZE 12 12 13 13 14 static struct spl_rect intersect_rec(const struct spl_rect *r0, const struct spl_rect *r1) ··· 109 108 const struct spl_rect *stream_src = &spl_in->basic_out.src_rect; 110 109 const struct spl_rect *stream_dst = &spl_in->basic_out.dst_rect; 111 110 struct spl_rect rec_out = {0}; 112 - struct fixed31_32 temp; 111 + struct spl_fixed31_32 temp; 113 112 114 113 115 - temp = dc_fixpt_from_fraction(rec_in->x * (long long)stream_dst->width, 114 + temp = spl_fixpt_from_fraction(rec_in->x * (long long)stream_dst->width, 116 115 stream_src->width); 117 - rec_out.x = stream_dst->x + dc_fixpt_round(temp); 116 + rec_out.x = stream_dst->x + spl_fixpt_round(temp); 118 117 119 - temp = dc_fixpt_from_fraction( 118 + temp = spl_fixpt_from_fraction( 120 119 (rec_in->x + rec_in->width) * (long long)stream_dst->width, 121 120 stream_src->width); 122 - rec_out.width = stream_dst->x + dc_fixpt_round(temp) - rec_out.x; 121 + rec_out.width = stream_dst->x + spl_fixpt_round(temp) - rec_out.x; 123 122 124 - temp = dc_fixpt_from_fraction(rec_in->y * (long long)stream_dst->height, 123 + temp = spl_fixpt_from_fraction(rec_in->y * (long long)stream_dst->height, 125 124 stream_src->height); 126 - rec_out.y = stream_dst->y + dc_fixpt_round(temp); 125 + rec_out.y = stream_dst->y + spl_fixpt_round(temp); 127 126 128 - temp = dc_fixpt_from_fraction( 127 + temp = spl_fixpt_from_fraction( 129 128 (rec_in->y + rec_in->height) * (long long)stream_dst->height, 130 129 stream_src->height); 131 - rec_out.height = stream_dst->y + dc_fixpt_round(temp) - rec_out.y; 130 + rec_out.height = stream_dst->y + spl_fixpt_round(temp) - rec_out.y; 132 131 133 132 return rec_out; 134 133 } ··· 146 145 mpc_rec.x = plane_clip_rec->x + mpc_rec.width * mpc_slice_idx; 147 146 mpc_rec.height = plane_clip_rec->height; 148 147 mpc_rec.y = plane_clip_rec->y; 149 - ASSERT(mpc_slice_count == 1 || 148 + SPL_ASSERT(mpc_slice_count == 1 || 150 149 spl_in->basic_out.view_format != SPL_VIEW_3D_SIDE_BY_SIDE || 151 150 mpc_rec.width % 2 == 0); 152 151 ··· 159 158 } 160 159 161 160 if (spl_in->basic_out.view_format == SPL_VIEW_3D_TOP_AND_BOTTOM) { 162 - ASSERT(mpc_rec.height % 2 == 0); 161 + SPL_ASSERT(mpc_rec.height % 2 == 0); 163 162 mpc_rec.height /= 2; 164 163 } 165 164 return mpc_rec; ··· 199 198 return spl_in->basic_out.odm_slice_rect; 200 199 } 201 200 202 - static void spl_calculate_recout(struct spl_in *spl_in, struct spl_out *spl_out) 201 + static void spl_calculate_recout(struct spl_in *spl_in, struct spl_scratch *spl_scratch, struct spl_out *spl_out) 203 202 { 204 203 /* 205 204 * A plane clip represents the desired plane size and position in Stream ··· 342 341 /* shift the overlapping area so it is with respect to current 343 342 * ODM slice's position 344 343 */ 345 - spl_out->scl_data.recout = shift_rec( 344 + spl_scratch->scl_data.recout = shift_rec( 346 345 &overlapping_area, 347 346 -odm_slice.x, -odm_slice.y); 348 - spl_out->scl_data.recout.height -= 347 + spl_scratch->scl_data.recout.height -= 349 348 spl_in->debug.visual_confirm_base_offset; 350 - spl_out->scl_data.recout.height -= 349 + spl_scratch->scl_data.recout.height -= 351 350 spl_in->debug.visual_confirm_dpp_offset; 352 351 } else 353 352 /* if there is no overlap, zero recout */ 354 - memset(&spl_out->scl_data.recout, 0, 353 + memset(&spl_scratch->scl_data.recout, 0, 355 354 sizeof(struct spl_rect)); 356 355 } 357 356 358 357 /* Calculate scaling ratios */ 359 - static void spl_calculate_scaling_ratios(struct spl_in *spl_in, struct spl_out *spl_out) 358 + static void spl_calculate_scaling_ratios(struct spl_in *spl_in, 359 + struct spl_scratch *spl_scratch, 360 + struct spl_out *spl_out) 360 361 { 361 362 const int in_w = spl_in->basic_out.src_rect.width; 362 363 const int in_h = spl_in->basic_out.src_rect.height; ··· 369 366 /*Swap surf_src height and width since scaling ratios are in recout rotation*/ 370 367 if (spl_in->basic_in.rotation == SPL_ROTATION_ANGLE_90 || 371 368 spl_in->basic_in.rotation == SPL_ROTATION_ANGLE_270) 372 - swap(surf_src.height, surf_src.width); 369 + spl_swap(surf_src.height, surf_src.width); 373 370 374 - spl_out->scl_data.ratios.horz = dc_fixpt_from_fraction( 371 + spl_scratch->scl_data.ratios.horz = spl_fixpt_from_fraction( 375 372 surf_src.width, 376 373 spl_in->basic_in.dst_rect.width); 377 - spl_out->scl_data.ratios.vert = dc_fixpt_from_fraction( 374 + spl_scratch->scl_data.ratios.vert = spl_fixpt_from_fraction( 378 375 surf_src.height, 379 376 spl_in->basic_in.dst_rect.height); 380 377 381 378 if (spl_in->basic_out.view_format == SPL_VIEW_3D_SIDE_BY_SIDE) 382 - spl_out->scl_data.ratios.horz.value *= 2; 379 + spl_scratch->scl_data.ratios.horz.value *= 2; 383 380 else if (spl_in->basic_out.view_format == SPL_VIEW_3D_TOP_AND_BOTTOM) 384 - spl_out->scl_data.ratios.vert.value *= 2; 381 + spl_scratch->scl_data.ratios.vert.value *= 2; 385 382 386 - spl_out->scl_data.ratios.vert.value = div64_s64( 387 - spl_out->scl_data.ratios.vert.value * in_h, out_h); 388 - spl_out->scl_data.ratios.horz.value = div64_s64( 389 - spl_out->scl_data.ratios.horz.value * in_w, out_w); 383 + spl_scratch->scl_data.ratios.vert.value = spl_div64_s64( 384 + spl_scratch->scl_data.ratios.vert.value * in_h, out_h); 385 + spl_scratch->scl_data.ratios.horz.value = spl_div64_s64( 386 + spl_scratch->scl_data.ratios.horz.value * in_w, out_w); 390 387 391 - spl_out->scl_data.ratios.horz_c = spl_out->scl_data.ratios.horz; 392 - spl_out->scl_data.ratios.vert_c = spl_out->scl_data.ratios.vert; 388 + spl_scratch->scl_data.ratios.horz_c = spl_scratch->scl_data.ratios.horz; 389 + spl_scratch->scl_data.ratios.vert_c = spl_scratch->scl_data.ratios.vert; 393 390 394 391 if (spl_in->basic_in.format == SPL_PIXEL_FORMAT_420BPP8 395 392 || spl_in->basic_in.format == SPL_PIXEL_FORMAT_420BPP10) { 396 - spl_out->scl_data.ratios.horz_c.value /= 2; 397 - spl_out->scl_data.ratios.vert_c.value /= 2; 393 + spl_scratch->scl_data.ratios.horz_c.value /= 2; 394 + spl_scratch->scl_data.ratios.vert_c.value /= 2; 398 395 } 399 - spl_out->scl_data.ratios.horz = dc_fixpt_truncate( 400 - spl_out->scl_data.ratios.horz, 19); 401 - spl_out->scl_data.ratios.vert = dc_fixpt_truncate( 402 - spl_out->scl_data.ratios.vert, 19); 403 - spl_out->scl_data.ratios.horz_c = dc_fixpt_truncate( 404 - spl_out->scl_data.ratios.horz_c, 19); 405 - spl_out->scl_data.ratios.vert_c = dc_fixpt_truncate( 406 - spl_out->scl_data.ratios.vert_c, 19); 396 + spl_scratch->scl_data.ratios.horz = spl_fixpt_truncate( 397 + spl_scratch->scl_data.ratios.horz, 19); 398 + spl_scratch->scl_data.ratios.vert = spl_fixpt_truncate( 399 + spl_scratch->scl_data.ratios.vert, 19); 400 + spl_scratch->scl_data.ratios.horz_c = spl_fixpt_truncate( 401 + spl_scratch->scl_data.ratios.horz_c, 19); 402 + spl_scratch->scl_data.ratios.vert_c = spl_fixpt_truncate( 403 + spl_scratch->scl_data.ratios.vert_c, 19); 407 404 408 405 /* 409 406 * Coefficient table and some registers are different based on ratio 410 407 * that is output/input. Currently we calculate input/output 411 408 * Store 1/ratio in recip_ratio for those lookups 412 409 */ 413 - spl_out->scl_data.recip_ratios.horz = dc_fixpt_recip( 414 - spl_out->scl_data.ratios.horz); 415 - spl_out->scl_data.recip_ratios.vert = dc_fixpt_recip( 416 - spl_out->scl_data.ratios.vert); 417 - spl_out->scl_data.recip_ratios.horz_c = dc_fixpt_recip( 418 - spl_out->scl_data.ratios.horz_c); 419 - spl_out->scl_data.recip_ratios.vert_c = dc_fixpt_recip( 420 - spl_out->scl_data.ratios.vert_c); 410 + spl_scratch->scl_data.recip_ratios.horz = spl_fixpt_recip( 411 + spl_scratch->scl_data.ratios.horz); 412 + spl_scratch->scl_data.recip_ratios.vert = spl_fixpt_recip( 413 + spl_scratch->scl_data.ratios.vert); 414 + spl_scratch->scl_data.recip_ratios.horz_c = spl_fixpt_recip( 415 + spl_scratch->scl_data.ratios.horz_c); 416 + spl_scratch->scl_data.recip_ratios.vert_c = spl_fixpt_recip( 417 + spl_scratch->scl_data.ratios.vert_c); 421 418 } 422 419 423 420 /* Calculate Viewport size */ 424 - static void spl_calculate_viewport_size(struct spl_in *spl_in, struct spl_out *spl_out) 421 + static void spl_calculate_viewport_size(struct spl_in *spl_in, struct spl_scratch *spl_scratch) 425 422 { 426 - spl_out->scl_data.viewport.width = dc_fixpt_ceil(dc_fixpt_mul_int(spl_out->scl_data.ratios.horz, 427 - spl_out->scl_data.recout.width)); 428 - spl_out->scl_data.viewport.height = dc_fixpt_ceil(dc_fixpt_mul_int(spl_out->scl_data.ratios.vert, 429 - spl_out->scl_data.recout.height)); 430 - spl_out->scl_data.viewport_c.width = dc_fixpt_ceil(dc_fixpt_mul_int(spl_out->scl_data.ratios.horz_c, 431 - spl_out->scl_data.recout.width)); 432 - spl_out->scl_data.viewport_c.height = dc_fixpt_ceil(dc_fixpt_mul_int(spl_out->scl_data.ratios.vert_c, 433 - spl_out->scl_data.recout.height)); 423 + spl_scratch->scl_data.viewport.width = spl_fixpt_ceil(spl_fixpt_mul_int(spl_scratch->scl_data.ratios.horz, 424 + spl_scratch->scl_data.recout.width)); 425 + spl_scratch->scl_data.viewport.height = spl_fixpt_ceil(spl_fixpt_mul_int(spl_scratch->scl_data.ratios.vert, 426 + spl_scratch->scl_data.recout.height)); 427 + spl_scratch->scl_data.viewport_c.width = spl_fixpt_ceil(spl_fixpt_mul_int(spl_scratch->scl_data.ratios.horz_c, 428 + spl_scratch->scl_data.recout.width)); 429 + spl_scratch->scl_data.viewport_c.height = spl_fixpt_ceil(spl_fixpt_mul_int(spl_scratch->scl_data.ratios.vert_c, 430 + spl_scratch->scl_data.recout.height)); 434 431 if (spl_in->basic_in.rotation == SPL_ROTATION_ANGLE_90 || 435 432 spl_in->basic_in.rotation == SPL_ROTATION_ANGLE_270) { 436 - swap(spl_out->scl_data.viewport.width, spl_out->scl_data.viewport.height); 437 - swap(spl_out->scl_data.viewport_c.width, spl_out->scl_data.viewport_c.height); 433 + spl_swap(spl_scratch->scl_data.viewport.width, spl_scratch->scl_data.viewport.height); 434 + spl_swap(spl_scratch->scl_data.viewport_c.width, spl_scratch->scl_data.viewport_c.height); 438 435 } 439 436 } 440 437 ··· 471 468 int recout_size, 472 469 int src_size, 473 470 int taps, 474 - struct fixed31_32 ratio, 475 - struct fixed31_32 init_adj, 476 - struct fixed31_32 *init, 471 + struct spl_fixed31_32 ratio, 472 + struct spl_fixed31_32 init_adj, 473 + struct spl_fixed31_32 *init, 477 474 int *vp_offset, 478 475 int *vp_size) 479 476 { 480 - struct fixed31_32 temp; 477 + struct spl_fixed31_32 temp; 481 478 int int_part; 482 479 483 480 /* ··· 490 487 * init_bot = init + scaling_ratio 491 488 * to get pixel perfect combine add the fraction from calculating vp offset 492 489 */ 493 - temp = dc_fixpt_mul_int(ratio, recout_offset_within_recout_full); 494 - *vp_offset = dc_fixpt_floor(temp); 490 + temp = spl_fixpt_mul_int(ratio, recout_offset_within_recout_full); 491 + *vp_offset = spl_fixpt_floor(temp); 495 492 temp.value &= 0xffffffff; 496 - *init = dc_fixpt_add(dc_fixpt_div_int(dc_fixpt_add_int(ratio, taps + 1), 2), temp); 497 - *init = dc_fixpt_add(*init, init_adj); 498 - *init = dc_fixpt_truncate(*init, 19); 493 + *init = spl_fixpt_add(spl_fixpt_div_int(spl_fixpt_add_int(ratio, taps + 1), 2), temp); 494 + *init = spl_fixpt_add(*init, init_adj); 495 + *init = spl_fixpt_truncate(*init, 19); 499 496 500 497 /* 501 498 * If viewport has non 0 offset and there are more taps than covered by init then 502 499 * we should decrease the offset and increase init so we are never sampling 503 500 * outside of viewport. 504 501 */ 505 - int_part = dc_fixpt_floor(*init); 502 + int_part = spl_fixpt_floor(*init); 506 503 if (int_part < taps) { 507 504 int_part = taps - int_part; 508 505 if (int_part > *vp_offset) 509 506 int_part = *vp_offset; 510 507 *vp_offset -= int_part; 511 - *init = dc_fixpt_add_int(*init, int_part); 508 + *init = spl_fixpt_add_int(*init, int_part); 512 509 } 513 510 /* 514 511 * If taps are sampling outside of viewport at end of recout and there are more pixels 515 512 * available in the surface we should increase the viewport size, regardless set vp to 516 513 * only what is used. 517 514 */ 518 - temp = dc_fixpt_add(*init, dc_fixpt_mul_int(ratio, recout_size - 1)); 519 - *vp_size = dc_fixpt_floor(temp); 515 + temp = spl_fixpt_add(*init, spl_fixpt_mul_int(ratio, recout_size - 1)); 516 + *vp_size = spl_fixpt_floor(temp); 520 517 if (*vp_size + *vp_offset > src_size) 521 518 *vp_size = src_size - *vp_offset; 522 519 ··· 539 536 } 540 537 541 538 /*Calculate inits and viewport */ 542 - static void spl_calculate_inits_and_viewports(struct spl_in *spl_in, struct spl_out *spl_out) 539 + static void spl_calculate_inits_and_viewports(struct spl_in *spl_in, 540 + struct spl_scratch *spl_scratch) 543 541 { 544 542 struct spl_rect src = spl_in->basic_in.src_rect; 545 543 struct spl_rect recout_dst_in_active_timing; ··· 551 547 int vpc_div = (spl_in->basic_in.format == SPL_PIXEL_FORMAT_420BPP8 552 548 || spl_in->basic_in.format == SPL_PIXEL_FORMAT_420BPP10) ? 2 : 1; 553 549 bool orthogonal_rotation, flip_vert_scan_dir, flip_horz_scan_dir; 554 - struct fixed31_32 init_adj_h = dc_fixpt_zero; 555 - struct fixed31_32 init_adj_v = dc_fixpt_zero; 550 + struct spl_fixed31_32 init_adj_h = spl_fixpt_zero; 551 + struct spl_fixed31_32 init_adj_v = spl_fixpt_zero; 556 552 557 553 recout_clip_in_active_timing = shift_rec( 558 - &spl_out->scl_data.recout, odm_slice.x, odm_slice.y); 554 + &spl_scratch->scl_data.recout, odm_slice.x, odm_slice.y); 559 555 recout_dst_in_active_timing = calculate_plane_rec_in_timing_active( 560 556 spl_in, &spl_in->basic_in.dst_rect); 561 557 overlap_in_active_timing = intersect_rec(&recout_clip_in_active_timing, ··· 578 574 &flip_horz_scan_dir); 579 575 580 576 if (orthogonal_rotation) { 581 - swap(src.width, src.height); 582 - swap(flip_vert_scan_dir, flip_horz_scan_dir); 577 + spl_swap(src.width, src.height); 578 + spl_swap(flip_vert_scan_dir, flip_horz_scan_dir); 583 579 } 584 580 585 581 if (spl_is_yuv420(spl_in->basic_in.format)) { ··· 591 587 switch (spl_in->basic_in.cositing) { 592 588 593 589 case CHROMA_COSITING_LEFT: 594 - init_adj_h = dc_fixpt_zero; 595 - init_adj_v = dc_fixpt_from_fraction(sign, 4); 590 + init_adj_h = spl_fixpt_zero; 591 + init_adj_v = spl_fixpt_from_fraction(sign, 4); 596 592 break; 597 593 case CHROMA_COSITING_NONE: 598 - init_adj_h = dc_fixpt_from_fraction(sign, 4); 599 - init_adj_v = dc_fixpt_from_fraction(sign, 4); 594 + init_adj_h = spl_fixpt_from_fraction(sign, 4); 595 + init_adj_v = spl_fixpt_from_fraction(sign, 4); 600 596 break; 601 597 case CHROMA_COSITING_TOPLEFT: 602 598 default: 603 - init_adj_h = dc_fixpt_zero; 604 - init_adj_v = dc_fixpt_zero; 599 + init_adj_h = spl_fixpt_zero; 600 + init_adj_v = spl_fixpt_zero; 605 601 break; 606 602 } 607 603 } ··· 609 605 spl_calculate_init_and_vp( 610 606 flip_horz_scan_dir, 611 607 recout_clip_in_recout_dst.x, 612 - spl_out->scl_data.recout.width, 608 + spl_scratch->scl_data.recout.width, 613 609 src.width, 614 - spl_out->scl_data.taps.h_taps, 615 - spl_out->scl_data.ratios.horz, 616 - dc_fixpt_zero, 617 - &spl_out->scl_data.inits.h, 618 - &spl_out->scl_data.viewport.x, 619 - &spl_out->scl_data.viewport.width); 610 + spl_scratch->scl_data.taps.h_taps, 611 + spl_scratch->scl_data.ratios.horz, 612 + spl_fixpt_zero, 613 + &spl_scratch->scl_data.inits.h, 614 + &spl_scratch->scl_data.viewport.x, 615 + &spl_scratch->scl_data.viewport.width); 620 616 spl_calculate_init_and_vp( 621 617 flip_horz_scan_dir, 622 618 recout_clip_in_recout_dst.x, 623 - spl_out->scl_data.recout.width, 619 + spl_scratch->scl_data.recout.width, 624 620 src.width / vpc_div, 625 - spl_out->scl_data.taps.h_taps_c, 626 - spl_out->scl_data.ratios.horz_c, 621 + spl_scratch->scl_data.taps.h_taps_c, 622 + spl_scratch->scl_data.ratios.horz_c, 627 623 init_adj_h, 628 - &spl_out->scl_data.inits.h_c, 629 - &spl_out->scl_data.viewport_c.x, 630 - &spl_out->scl_data.viewport_c.width); 624 + &spl_scratch->scl_data.inits.h_c, 625 + &spl_scratch->scl_data.viewport_c.x, 626 + &spl_scratch->scl_data.viewport_c.width); 631 627 spl_calculate_init_and_vp( 632 628 flip_vert_scan_dir, 633 629 recout_clip_in_recout_dst.y, 634 - spl_out->scl_data.recout.height, 630 + spl_scratch->scl_data.recout.height, 635 631 src.height, 636 - spl_out->scl_data.taps.v_taps, 637 - spl_out->scl_data.ratios.vert, 638 - dc_fixpt_zero, 639 - &spl_out->scl_data.inits.v, 640 - &spl_out->scl_data.viewport.y, 641 - &spl_out->scl_data.viewport.height); 632 + spl_scratch->scl_data.taps.v_taps, 633 + spl_scratch->scl_data.ratios.vert, 634 + spl_fixpt_zero, 635 + &spl_scratch->scl_data.inits.v, 636 + &spl_scratch->scl_data.viewport.y, 637 + &spl_scratch->scl_data.viewport.height); 642 638 spl_calculate_init_and_vp( 643 639 flip_vert_scan_dir, 644 640 recout_clip_in_recout_dst.y, 645 - spl_out->scl_data.recout.height, 641 + spl_scratch->scl_data.recout.height, 646 642 src.height / vpc_div, 647 - spl_out->scl_data.taps.v_taps_c, 648 - spl_out->scl_data.ratios.vert_c, 643 + spl_scratch->scl_data.taps.v_taps_c, 644 + spl_scratch->scl_data.ratios.vert_c, 649 645 init_adj_v, 650 - &spl_out->scl_data.inits.v_c, 651 - &spl_out->scl_data.viewport_c.y, 652 - &spl_out->scl_data.viewport_c.height); 646 + &spl_scratch->scl_data.inits.v_c, 647 + &spl_scratch->scl_data.viewport_c.y, 648 + &spl_scratch->scl_data.viewport_c.height); 653 649 if (orthogonal_rotation) { 654 - swap(spl_out->scl_data.viewport.x, spl_out->scl_data.viewport.y); 655 - swap(spl_out->scl_data.viewport.width, spl_out->scl_data.viewport.height); 656 - swap(spl_out->scl_data.viewport_c.x, spl_out->scl_data.viewport_c.y); 657 - swap(spl_out->scl_data.viewport_c.width, spl_out->scl_data.viewport_c.height); 650 + spl_swap(spl_scratch->scl_data.viewport.x, spl_scratch->scl_data.viewport.y); 651 + spl_swap(spl_scratch->scl_data.viewport.width, spl_scratch->scl_data.viewport.height); 652 + spl_swap(spl_scratch->scl_data.viewport_c.x, spl_scratch->scl_data.viewport_c.y); 653 + spl_swap(spl_scratch->scl_data.viewport_c.width, spl_scratch->scl_data.viewport_c.height); 658 654 } 659 - spl_out->scl_data.viewport.x += src.x; 660 - spl_out->scl_data.viewport.y += src.y; 661 - ASSERT(src.x % vpc_div == 0 && src.y % vpc_div == 0); 662 - spl_out->scl_data.viewport_c.x += src.x / vpc_div; 663 - spl_out->scl_data.viewport_c.y += src.y / vpc_div; 655 + spl_scratch->scl_data.viewport.x += src.x; 656 + spl_scratch->scl_data.viewport.y += src.y; 657 + SPL_ASSERT(src.x % vpc_div == 0 && src.y % vpc_div == 0); 658 + spl_scratch->scl_data.viewport_c.x += src.x / vpc_div; 659 + spl_scratch->scl_data.viewport_c.y += src.y / vpc_div; 664 660 } 665 661 666 662 static void spl_handle_3d_recout(struct spl_in *spl_in, struct spl_rect *recout) ··· 671 667 * This may break with rotation, good thing we aren't mixing hw rotation and 3d 672 668 */ 673 669 if (spl_in->basic_in.mpc_combine_v) { 674 - ASSERT(spl_in->basic_in.rotation == SPL_ROTATION_ANGLE_0 || 670 + SPL_ASSERT(spl_in->basic_in.rotation == SPL_ROTATION_ANGLE_0 || 675 671 (spl_in->basic_out.view_format != SPL_VIEW_3D_TOP_AND_BOTTOM && 676 672 spl_in->basic_out.view_format != SPL_VIEW_3D_SIDE_BY_SIDE)); 677 673 if (spl_in->basic_out.view_format == SPL_VIEW_3D_TOP_AND_BOTTOM) ··· 712 708 const struct spl_scaler_data *data, 713 709 bool enable_isharp, bool enable_easf) 714 710 { 715 - const long long one = dc_fixpt_one.value; 711 + const long long one = spl_fixpt_one.value; 716 712 enum spl_pixel_format pixel_format = spl_in->basic_in.format; 717 713 718 714 /* Bypass if ratio is 1:1 with no ISHARP or force scale on */ ··· 766 762 } 767 763 768 764 /* Enable EASF ?*/ 769 - static bool enable_easf(struct spl_in *spl_in, struct spl_out *spl_out) 765 + static bool enable_easf(struct spl_in *spl_in, struct spl_scratch *spl_scratch) 770 766 { 771 767 int vratio = 0; 772 768 int hratio = 0; ··· 782 778 spl_in->basic_in.tf_type, spl_in->basic_in.tf_predefined_type, 783 779 &spl_in->lls_pref); 784 780 785 - vratio = dc_fixpt_ceil(spl_out->scl_data.ratios.vert); 786 - hratio = dc_fixpt_ceil(spl_out->scl_data.ratios.horz); 781 + vratio = spl_fixpt_ceil(spl_scratch->scl_data.ratios.vert); 782 + hratio = spl_fixpt_ceil(spl_scratch->scl_data.ratios.horz); 787 783 788 784 if (!lls_enable_easf || spl_in->disable_easf) 789 785 skip_easf = true; ··· 803 799 } 804 800 805 801 /* Check if video is in fullscreen mode */ 806 - static bool spl_is_video_fullscreen(struct spl_in *spl_in, struct spl_out *spl_out) 802 + static bool spl_is_video_fullscreen(struct spl_in *spl_in) 807 803 { 808 804 if (spl_is_yuv420(spl_in->basic_in.format) && spl_in->is_fullscreen) 809 805 return true; ··· 811 807 } 812 808 813 809 static bool spl_get_isharp_en(struct spl_in *spl_in, 814 - struct spl_out *spl_out) 810 + struct spl_scratch *spl_scratch) 815 811 { 816 812 bool enable_isharp = false; 817 813 int vratio = 0; 818 814 int hratio = 0; 819 - struct spl_taps taps = spl_out->scl_data.taps; 820 - bool fullscreen = spl_is_video_fullscreen(spl_in, spl_out); 815 + struct spl_taps taps = spl_scratch->scl_data.taps; 816 + bool fullscreen = spl_is_video_fullscreen(spl_in); 821 817 822 - vratio = dc_fixpt_ceil(spl_out->scl_data.ratios.vert); 823 - hratio = dc_fixpt_ceil(spl_out->scl_data.ratios.horz); 818 + vratio = spl_fixpt_ceil(spl_scratch->scl_data.ratios.vert); 819 + hratio = spl_fixpt_ceil(spl_scratch->scl_data.ratios.horz); 824 820 825 821 /* Return if adaptive sharpness is disabled */ 826 822 if (spl_in->adaptive_sharpness.enable == false) ··· 852 848 853 849 /* Calculate optimal number of taps */ 854 850 static bool spl_get_optimal_number_of_taps( 855 - int max_downscale_src_width, struct spl_in *spl_in, struct spl_out *spl_out, 851 + int max_downscale_src_width, struct spl_in *spl_in, struct spl_scratch *spl_scratch, 856 852 const struct spl_taps *in_taps, bool *enable_easf_v, bool *enable_easf_h, 857 853 bool *enable_isharp) 858 854 { ··· 862 858 enum lb_memory_config lb_config; 863 859 bool skip_easf = false; 864 860 865 - if (spl_out->scl_data.viewport.width > spl_out->scl_data.h_active && 861 + if (spl_scratch->scl_data.viewport.width > spl_scratch->scl_data.h_active && 866 862 max_downscale_src_width != 0 && 867 - spl_out->scl_data.viewport.width > max_downscale_src_width) 863 + spl_scratch->scl_data.viewport.width > max_downscale_src_width) 868 864 return false; 869 865 870 866 /* Check if we are using EASF or not */ 871 - skip_easf = enable_easf(spl_in, spl_out); 867 + skip_easf = enable_easf(spl_in, spl_scratch); 872 868 873 869 /* 874 870 * Set default taps if none are provided ··· 877 873 */ 878 874 if (skip_easf) { 879 875 if (in_taps->h_taps == 0) { 880 - if (dc_fixpt_ceil(spl_out->scl_data.ratios.horz) > 1) 881 - spl_out->scl_data.taps.h_taps = min(2 * dc_fixpt_ceil( 882 - spl_out->scl_data.ratios.horz), 8); 876 + if (spl_fixpt_ceil(spl_scratch->scl_data.ratios.horz) > 1) 877 + spl_scratch->scl_data.taps.h_taps = spl_min(2 * spl_fixpt_ceil( 878 + spl_scratch->scl_data.ratios.horz), 8); 883 879 else 884 - spl_out->scl_data.taps.h_taps = 4; 880 + spl_scratch->scl_data.taps.h_taps = 4; 885 881 } else 886 - spl_out->scl_data.taps.h_taps = in_taps->h_taps; 882 + spl_scratch->scl_data.taps.h_taps = in_taps->h_taps; 887 883 if (in_taps->v_taps == 0) { 888 - if (dc_fixpt_ceil(spl_out->scl_data.ratios.vert) > 1) 889 - spl_out->scl_data.taps.v_taps = min(dc_fixpt_ceil(dc_fixpt_mul_int( 890 - spl_out->scl_data.ratios.vert, 2)), 8); 884 + if (spl_fixpt_ceil(spl_scratch->scl_data.ratios.vert) > 1) 885 + spl_scratch->scl_data.taps.v_taps = spl_min(spl_fixpt_ceil(spl_fixpt_mul_int( 886 + spl_scratch->scl_data.ratios.vert, 2)), 8); 891 887 else 892 - spl_out->scl_data.taps.v_taps = 4; 888 + spl_scratch->scl_data.taps.v_taps = 4; 893 889 } else 894 - spl_out->scl_data.taps.v_taps = in_taps->v_taps; 890 + spl_scratch->scl_data.taps.v_taps = in_taps->v_taps; 895 891 if (in_taps->v_taps_c == 0) { 896 - if (dc_fixpt_ceil(spl_out->scl_data.ratios.vert_c) > 1) 897 - spl_out->scl_data.taps.v_taps_c = min(dc_fixpt_ceil(dc_fixpt_mul_int( 898 - spl_out->scl_data.ratios.vert_c, 2)), 8); 892 + if (spl_fixpt_ceil(spl_scratch->scl_data.ratios.vert_c) > 1) 893 + spl_scratch->scl_data.taps.v_taps_c = spl_min(spl_fixpt_ceil(spl_fixpt_mul_int( 894 + spl_scratch->scl_data.ratios.vert_c, 2)), 8); 899 895 else 900 - spl_out->scl_data.taps.v_taps_c = 4; 896 + spl_scratch->scl_data.taps.v_taps_c = 4; 901 897 } else 902 - spl_out->scl_data.taps.v_taps_c = in_taps->v_taps_c; 898 + spl_scratch->scl_data.taps.v_taps_c = in_taps->v_taps_c; 903 899 if (in_taps->h_taps_c == 0) { 904 - if (dc_fixpt_ceil(spl_out->scl_data.ratios.horz_c) > 1) 905 - spl_out->scl_data.taps.h_taps_c = min(2 * dc_fixpt_ceil( 906 - spl_out->scl_data.ratios.horz_c), 8); 900 + if (spl_fixpt_ceil(spl_scratch->scl_data.ratios.horz_c) > 1) 901 + spl_scratch->scl_data.taps.h_taps_c = spl_min(2 * spl_fixpt_ceil( 902 + spl_scratch->scl_data.ratios.horz_c), 8); 907 903 else 908 - spl_out->scl_data.taps.h_taps_c = 4; 904 + spl_scratch->scl_data.taps.h_taps_c = 4; 909 905 } else if ((in_taps->h_taps_c % 2) != 0 && in_taps->h_taps_c != 1) 910 906 /* Only 1 and even h_taps_c are supported by hw */ 911 - spl_out->scl_data.taps.h_taps_c = in_taps->h_taps_c - 1; 907 + spl_scratch->scl_data.taps.h_taps_c = in_taps->h_taps_c - 1; 912 908 else 913 - spl_out->scl_data.taps.h_taps_c = in_taps->h_taps_c; 909 + spl_scratch->scl_data.taps.h_taps_c = in_taps->h_taps_c; 914 910 } else { 915 911 if (spl_is_yuv420(spl_in->basic_in.format)) { 916 - spl_out->scl_data.taps.h_taps = 6; 917 - spl_out->scl_data.taps.v_taps = 6; 918 - spl_out->scl_data.taps.h_taps_c = 4; 919 - spl_out->scl_data.taps.v_taps_c = 4; 912 + spl_scratch->scl_data.taps.h_taps = 6; 913 + spl_scratch->scl_data.taps.v_taps = 6; 914 + spl_scratch->scl_data.taps.h_taps_c = 4; 915 + spl_scratch->scl_data.taps.v_taps_c = 4; 920 916 } else { /* RGB */ 921 - spl_out->scl_data.taps.h_taps = 6; 922 - spl_out->scl_data.taps.v_taps = 6; 923 - spl_out->scl_data.taps.h_taps_c = 6; 924 - spl_out->scl_data.taps.v_taps_c = 6; 917 + spl_scratch->scl_data.taps.h_taps = 6; 918 + spl_scratch->scl_data.taps.v_taps = 6; 919 + spl_scratch->scl_data.taps.h_taps_c = 6; 920 + spl_scratch->scl_data.taps.v_taps_c = 6; 925 921 } 926 922 } 927 923 928 924 /*Ensure we can support the requested number of vtaps*/ 929 - min_taps_y = dc_fixpt_ceil(spl_out->scl_data.ratios.vert); 930 - min_taps_c = dc_fixpt_ceil(spl_out->scl_data.ratios.vert_c); 925 + min_taps_y = spl_fixpt_ceil(spl_scratch->scl_data.ratios.vert); 926 + min_taps_c = spl_fixpt_ceil(spl_scratch->scl_data.ratios.vert_c); 931 927 932 928 /* Use LB_MEMORY_CONFIG_3 for 4:2:0 */ 933 929 if ((spl_in->basic_in.format == SPL_PIXEL_FORMAT_420BPP8) ··· 936 932 else 937 933 lb_config = LB_MEMORY_CONFIG_0; 938 934 // Determine max vtap support by calculating how much line buffer can fit 939 - spl_in->funcs->spl_calc_lb_num_partitions(spl_in->basic_out.alpha_en, &spl_out->scl_data, 935 + spl_in->funcs->spl_calc_lb_num_partitions(spl_in->basic_out.alpha_en, &spl_scratch->scl_data, 940 936 lb_config, &num_part_y, &num_part_c); 941 937 /* MAX_V_TAPS = MIN (NUM_LINES - MAX(CEILING(V_RATIO,1)-2, 0), 8) */ 942 - if (dc_fixpt_ceil(spl_out->scl_data.ratios.vert) > 2) 943 - max_taps_y = num_part_y - (dc_fixpt_ceil(spl_out->scl_data.ratios.vert) - 2); 938 + if (spl_fixpt_ceil(spl_scratch->scl_data.ratios.vert) > 2) 939 + max_taps_y = num_part_y - (spl_fixpt_ceil(spl_scratch->scl_data.ratios.vert) - 2); 944 940 else 945 941 max_taps_y = num_part_y; 946 942 947 - if (dc_fixpt_ceil(spl_out->scl_data.ratios.vert_c) > 2) 948 - max_taps_c = num_part_c - (dc_fixpt_ceil(spl_out->scl_data.ratios.vert_c) - 2); 943 + if (spl_fixpt_ceil(spl_scratch->scl_data.ratios.vert_c) > 2) 944 + max_taps_c = num_part_c - (spl_fixpt_ceil(spl_scratch->scl_data.ratios.vert_c) - 2); 949 945 else 950 946 max_taps_c = num_part_c; 951 947 ··· 954 950 else if (max_taps_c < min_taps_c) 955 951 return false; 956 952 957 - if (spl_out->scl_data.taps.v_taps > max_taps_y) 958 - spl_out->scl_data.taps.v_taps = max_taps_y; 953 + if (spl_scratch->scl_data.taps.v_taps > max_taps_y) 954 + spl_scratch->scl_data.taps.v_taps = max_taps_y; 959 955 960 - if (spl_out->scl_data.taps.v_taps_c > max_taps_c) 961 - spl_out->scl_data.taps.v_taps_c = max_taps_c; 956 + if (spl_scratch->scl_data.taps.v_taps_c > max_taps_c) 957 + spl_scratch->scl_data.taps.v_taps_c = max_taps_c; 962 958 963 959 if (!skip_easf) { 964 960 /* ··· 975 971 * If optimal no of taps is 7 or 8, then fine since max tap is 6 976 972 * 977 973 */ 978 - if (spl_out->scl_data.taps.v_taps == 5) 979 - spl_out->scl_data.taps.v_taps = 4; 974 + if (spl_scratch->scl_data.taps.v_taps == 5) 975 + spl_scratch->scl_data.taps.v_taps = 4; 980 976 981 - if (spl_out->scl_data.taps.v_taps_c == 5) 982 - spl_out->scl_data.taps.v_taps_c = 4; 977 + if (spl_scratch->scl_data.taps.v_taps_c == 5) 978 + spl_scratch->scl_data.taps.v_taps_c = 4; 983 979 984 - if (spl_out->scl_data.taps.h_taps == 5) 985 - spl_out->scl_data.taps.h_taps = 4; 980 + if (spl_scratch->scl_data.taps.h_taps == 5) 981 + spl_scratch->scl_data.taps.h_taps = 4; 986 982 987 - if (spl_out->scl_data.taps.h_taps_c == 5) 988 - spl_out->scl_data.taps.h_taps_c = 4; 983 + if (spl_scratch->scl_data.taps.h_taps_c == 5) 984 + spl_scratch->scl_data.taps.h_taps_c = 4; 989 985 990 986 if (spl_is_yuv420(spl_in->basic_in.format)) { 991 - if ((spl_out->scl_data.taps.h_taps <= 4) || 992 - (spl_out->scl_data.taps.h_taps_c <= 3)) { 987 + if ((spl_scratch->scl_data.taps.h_taps <= 4) || 988 + (spl_scratch->scl_data.taps.h_taps_c <= 3)) { 993 989 *enable_easf_v = false; 994 990 *enable_easf_h = false; 995 - } else if ((spl_out->scl_data.taps.v_taps <= 3) || 996 - (spl_out->scl_data.taps.v_taps_c <= 3)) { 991 + } else if ((spl_scratch->scl_data.taps.v_taps <= 3) || 992 + (spl_scratch->scl_data.taps.v_taps_c <= 3)) { 997 993 *enable_easf_v = false; 998 994 *enable_easf_h = true; 999 995 } else { 1000 996 *enable_easf_v = true; 1001 997 *enable_easf_h = true; 1002 998 } 1003 - ASSERT((spl_out->scl_data.taps.v_taps > 1) && 1004 - (spl_out->scl_data.taps.v_taps_c > 1)); 999 + SPL_ASSERT((spl_scratch->scl_data.taps.v_taps > 1) && 1000 + (spl_scratch->scl_data.taps.v_taps_c > 1)); 1005 1001 } else { /* RGB */ 1006 - if (spl_out->scl_data.taps.h_taps <= 3) { 1002 + if (spl_scratch->scl_data.taps.h_taps <= 3) { 1007 1003 *enable_easf_v = false; 1008 1004 *enable_easf_h = false; 1009 - } else if (spl_out->scl_data.taps.v_taps < 3) { 1005 + } else if (spl_scratch->scl_data.taps.v_taps < 3) { 1010 1006 *enable_easf_v = false; 1011 1007 *enable_easf_h = true; 1012 1008 } else { 1013 1009 *enable_easf_v = true; 1014 1010 *enable_easf_h = true; 1015 1011 } 1016 - ASSERT(spl_out->scl_data.taps.v_taps > 1); 1012 + SPL_ASSERT(spl_scratch->scl_data.taps.v_taps > 1); 1017 1013 } 1018 1014 } else { 1019 1015 *enable_easf_v = false; ··· 1028 1024 * EASF is not enabled 1029 1025 */ 1030 1026 1031 - *enable_isharp = spl_get_isharp_en(spl_in, spl_out); 1027 + *enable_isharp = spl_get_isharp_en(spl_in, spl_scratch); 1032 1028 if (!*enable_isharp && !spl_in->basic_out.always_scale) { 1033 - if ((IDENTITY_RATIO(spl_out->scl_data.ratios.horz)) && 1034 - (IDENTITY_RATIO(spl_out->scl_data.ratios.vert))) { 1035 - spl_out->scl_data.taps.h_taps = 1; 1036 - spl_out->scl_data.taps.v_taps = 1; 1029 + if ((IDENTITY_RATIO(spl_scratch->scl_data.ratios.horz)) && 1030 + (IDENTITY_RATIO(spl_scratch->scl_data.ratios.vert))) { 1031 + spl_scratch->scl_data.taps.h_taps = 1; 1032 + spl_scratch->scl_data.taps.v_taps = 1; 1037 1033 1038 - if (IDENTITY_RATIO(spl_out->scl_data.ratios.horz_c)) 1039 - spl_out->scl_data.taps.h_taps_c = 1; 1034 + if (IDENTITY_RATIO(spl_scratch->scl_data.ratios.horz_c)) 1035 + spl_scratch->scl_data.taps.h_taps_c = 1; 1040 1036 1041 - if (IDENTITY_RATIO(spl_out->scl_data.ratios.vert_c)) 1042 - spl_out->scl_data.taps.v_taps_c = 1; 1037 + if (IDENTITY_RATIO(spl_scratch->scl_data.ratios.vert_c)) 1038 + spl_scratch->scl_data.taps.v_taps_c = 1; 1043 1039 1044 1040 *enable_easf_v = false; 1045 1041 *enable_easf_h = false; 1046 1042 } else { 1047 1043 if ((!*enable_easf_h) && 1048 - (IDENTITY_RATIO(spl_out->scl_data.ratios.horz_c))) 1049 - spl_out->scl_data.taps.h_taps_c = 1; 1044 + (IDENTITY_RATIO(spl_scratch->scl_data.ratios.horz_c))) 1045 + spl_scratch->scl_data.taps.h_taps_c = 1; 1050 1046 1051 1047 if ((!*enable_easf_v) && 1052 - (IDENTITY_RATIO(spl_out->scl_data.ratios.vert_c))) 1053 - spl_out->scl_data.taps.v_taps_c = 1; 1048 + (IDENTITY_RATIO(spl_scratch->scl_data.ratios.vert_c))) 1049 + spl_scratch->scl_data.taps.v_taps_c = 1; 1054 1050 } 1055 1051 } 1056 1052 return true; ··· 1073 1069 static void spl_set_manual_ratio_init_data(struct dscl_prog_data *dscl_prog_data, 1074 1070 const struct spl_scaler_data *scl_data) 1075 1071 { 1076 - struct fixed31_32 bot; 1072 + struct spl_fixed31_32 bot; 1077 1073 1078 - dscl_prog_data->ratios.h_scale_ratio = dc_fixpt_u3d19(scl_data->ratios.horz) << 5; 1079 - dscl_prog_data->ratios.v_scale_ratio = dc_fixpt_u3d19(scl_data->ratios.vert) << 5; 1080 - dscl_prog_data->ratios.h_scale_ratio_c = dc_fixpt_u3d19(scl_data->ratios.horz_c) << 5; 1081 - dscl_prog_data->ratios.v_scale_ratio_c = dc_fixpt_u3d19(scl_data->ratios.vert_c) << 5; 1074 + dscl_prog_data->ratios.h_scale_ratio = spl_fixpt_u3d19(scl_data->ratios.horz) << 5; 1075 + dscl_prog_data->ratios.v_scale_ratio = spl_fixpt_u3d19(scl_data->ratios.vert) << 5; 1076 + dscl_prog_data->ratios.h_scale_ratio_c = spl_fixpt_u3d19(scl_data->ratios.horz_c) << 5; 1077 + dscl_prog_data->ratios.v_scale_ratio_c = spl_fixpt_u3d19(scl_data->ratios.vert_c) << 5; 1082 1078 /* 1083 1079 * 0.24 format for fraction, first five bits zeroed 1084 1080 */ 1085 1081 dscl_prog_data->init.h_filter_init_frac = 1086 - dc_fixpt_u0d19(scl_data->inits.h) << 5; 1082 + spl_fixpt_u0d19(scl_data->inits.h) << 5; 1087 1083 dscl_prog_data->init.h_filter_init_int = 1088 - dc_fixpt_floor(scl_data->inits.h); 1084 + spl_fixpt_floor(scl_data->inits.h); 1089 1085 dscl_prog_data->init.h_filter_init_frac_c = 1090 - dc_fixpt_u0d19(scl_data->inits.h_c) << 5; 1086 + spl_fixpt_u0d19(scl_data->inits.h_c) << 5; 1091 1087 dscl_prog_data->init.h_filter_init_int_c = 1092 - dc_fixpt_floor(scl_data->inits.h_c); 1088 + spl_fixpt_floor(scl_data->inits.h_c); 1093 1089 dscl_prog_data->init.v_filter_init_frac = 1094 - dc_fixpt_u0d19(scl_data->inits.v) << 5; 1090 + spl_fixpt_u0d19(scl_data->inits.v) << 5; 1095 1091 dscl_prog_data->init.v_filter_init_int = 1096 - dc_fixpt_floor(scl_data->inits.v); 1092 + spl_fixpt_floor(scl_data->inits.v); 1097 1093 dscl_prog_data->init.v_filter_init_frac_c = 1098 - dc_fixpt_u0d19(scl_data->inits.v_c) << 5; 1094 + spl_fixpt_u0d19(scl_data->inits.v_c) << 5; 1099 1095 dscl_prog_data->init.v_filter_init_int_c = 1100 - dc_fixpt_floor(scl_data->inits.v_c); 1096 + spl_fixpt_floor(scl_data->inits.v_c); 1101 1097 1102 - bot = dc_fixpt_add(scl_data->inits.v, scl_data->ratios.vert); 1103 - dscl_prog_data->init.v_filter_init_bot_frac = dc_fixpt_u0d19(bot) << 5; 1104 - dscl_prog_data->init.v_filter_init_bot_int = dc_fixpt_floor(bot); 1105 - bot = dc_fixpt_add(scl_data->inits.v_c, scl_data->ratios.vert_c); 1106 - dscl_prog_data->init.v_filter_init_bot_frac_c = dc_fixpt_u0d19(bot) << 5; 1107 - dscl_prog_data->init.v_filter_init_bot_int_c = dc_fixpt_floor(bot); 1098 + bot = spl_fixpt_add(scl_data->inits.v, scl_data->ratios.vert); 1099 + dscl_prog_data->init.v_filter_init_bot_frac = spl_fixpt_u0d19(bot) << 5; 1100 + dscl_prog_data->init.v_filter_init_bot_int = spl_fixpt_floor(bot); 1101 + bot = spl_fixpt_add(scl_data->inits.v_c, scl_data->ratios.vert_c); 1102 + dscl_prog_data->init.v_filter_init_bot_frac_c = spl_fixpt_u0d19(bot) << 5; 1103 + dscl_prog_data->init.v_filter_init_bot_int_c = spl_fixpt_floor(bot); 1108 1104 } 1109 1105 1110 1106 static void spl_set_taps_data(struct dscl_prog_data *dscl_prog_data, ··· 1117 1113 } 1118 1114 1119 1115 /* Populate dscl prog data structure from scaler data calculated by SPL */ 1120 - static void spl_set_dscl_prog_data(struct spl_in *spl_in, struct spl_out *spl_out, 1121 - bool enable_easf_v, bool enable_easf_h, bool enable_isharp) 1116 + static void spl_set_dscl_prog_data(struct spl_in *spl_in, struct spl_scratch *spl_scratch, 1117 + struct spl_out *spl_out, bool enable_easf_v, bool enable_easf_h, bool enable_isharp) 1122 1118 { 1123 1119 struct dscl_prog_data *dscl_prog_data = spl_out->dscl_prog_data; 1124 1120 1125 - const struct spl_scaler_data *data = &spl_out->scl_data; 1121 + const struct spl_scaler_data *data = &spl_scratch->scl_data; 1126 1122 1127 1123 struct scl_black_color *scl_black_color = &dscl_prog_data->scl_black_color; 1128 1124 1129 1125 bool enable_easf = enable_easf_v || enable_easf_h; 1130 1126 1131 1127 // Set values for recout 1132 - dscl_prog_data->recout = spl_out->scl_data.recout; 1128 + dscl_prog_data->recout = spl_scratch->scl_data.recout; 1133 1129 // Set values for MPC Size 1134 - dscl_prog_data->mpc_size.width = spl_out->scl_data.h_active; 1135 - dscl_prog_data->mpc_size.height = spl_out->scl_data.v_active; 1130 + dscl_prog_data->mpc_size.width = spl_scratch->scl_data.h_active; 1131 + dscl_prog_data->mpc_size.height = spl_scratch->scl_data.v_active; 1136 1132 1137 1133 // SCL_MODE - Set SCL_MODE data 1138 1134 dscl_prog_data->dscl_mode = spl_get_dscl_mode(spl_in, data, enable_isharp, ··· 1147 1143 // Set HTaps/VTaps 1148 1144 spl_set_taps_data(dscl_prog_data, data); 1149 1145 // Set viewport 1150 - dscl_prog_data->viewport = spl_out->scl_data.viewport; 1146 + dscl_prog_data->viewport = spl_scratch->scl_data.viewport; 1151 1147 // Set viewport_c 1152 - dscl_prog_data->viewport_c = spl_out->scl_data.viewport_c; 1148 + dscl_prog_data->viewport_c = spl_scratch->scl_data.viewport_c; 1153 1149 // Set filters data 1154 1150 spl_set_filters_data(dscl_prog_data, data, enable_easf_v, enable_easf_h); 1155 1151 } 1156 1152 1157 1153 /* Set EASF data */ 1158 - static void spl_set_easf_data(struct spl_out *spl_out, bool enable_easf_v, 1154 + static void spl_set_easf_data(struct spl_scratch *spl_scratch, struct spl_out *spl_out, bool enable_easf_v, 1159 1155 bool enable_easf_h, enum linear_light_scaling lls_pref, 1160 1156 enum spl_pixel_format format, enum system_setup setup) 1161 1157 { ··· 1168 1164 dscl_prog_data->easf_v_bf2_mode = 0xF; // 4-bit, BF2 calculation mode 1169 1165 /* 2-bit, BF3 chroma mode correction calculation mode */ 1170 1166 dscl_prog_data->easf_v_bf3_mode = spl_get_v_bf3_mode( 1171 - spl_out->scl_data.recip_ratios.vert); 1167 + spl_scratch->scl_data.recip_ratios.vert); 1172 1168 /* FP1.5.10 [ minCoef ]*/ 1173 1169 dscl_prog_data->easf_v_ringest_3tap_dntilt_uptilt = 1174 - spl_get_3tap_dntilt_uptilt_offset(spl_out->scl_data.taps.v_taps, 1175 - spl_out->scl_data.recip_ratios.vert); 1170 + spl_get_3tap_dntilt_uptilt_offset(spl_scratch->scl_data.taps.v_taps, 1171 + spl_scratch->scl_data.recip_ratios.vert); 1176 1172 /* FP1.5.10 [ upTiltMaxVal ]*/ 1177 1173 dscl_prog_data->easf_v_ringest_3tap_uptilt_max = 1178 - spl_get_3tap_uptilt_maxval(spl_out->scl_data.taps.v_taps, 1179 - spl_out->scl_data.recip_ratios.vert); 1174 + spl_get_3tap_uptilt_maxval(spl_scratch->scl_data.taps.v_taps, 1175 + spl_scratch->scl_data.recip_ratios.vert); 1180 1176 /* FP1.5.10 [ dnTiltSlope ]*/ 1181 1177 dscl_prog_data->easf_v_ringest_3tap_dntilt_slope = 1182 - spl_get_3tap_dntilt_slope(spl_out->scl_data.taps.v_taps, 1183 - spl_out->scl_data.recip_ratios.vert); 1178 + spl_get_3tap_dntilt_slope(spl_scratch->scl_data.taps.v_taps, 1179 + spl_scratch->scl_data.recip_ratios.vert); 1184 1180 /* FP1.5.10 [ upTilt1Slope ]*/ 1185 1181 dscl_prog_data->easf_v_ringest_3tap_uptilt1_slope = 1186 - spl_get_3tap_uptilt1_slope(spl_out->scl_data.taps.v_taps, 1187 - spl_out->scl_data.recip_ratios.vert); 1182 + spl_get_3tap_uptilt1_slope(spl_scratch->scl_data.taps.v_taps, 1183 + spl_scratch->scl_data.recip_ratios.vert); 1188 1184 /* FP1.5.10 [ upTilt2Slope ]*/ 1189 1185 dscl_prog_data->easf_v_ringest_3tap_uptilt2_slope = 1190 - spl_get_3tap_uptilt2_slope(spl_out->scl_data.taps.v_taps, 1191 - spl_out->scl_data.recip_ratios.vert); 1186 + spl_get_3tap_uptilt2_slope(spl_scratch->scl_data.taps.v_taps, 1187 + spl_scratch->scl_data.recip_ratios.vert); 1192 1188 /* FP1.5.10 [ upTilt2Offset ]*/ 1193 1189 dscl_prog_data->easf_v_ringest_3tap_uptilt2_offset = 1194 - spl_get_3tap_uptilt2_offset(spl_out->scl_data.taps.v_taps, 1195 - spl_out->scl_data.recip_ratios.vert); 1190 + spl_get_3tap_uptilt2_offset(spl_scratch->scl_data.taps.v_taps, 1191 + spl_scratch->scl_data.recip_ratios.vert); 1196 1192 /* FP1.5.10; (2.0) Ring reducer gain for 4 or 6-tap mode [H_REDUCER_GAIN4] */ 1197 1193 dscl_prog_data->easf_v_ringest_eventap_reduceg1 = 1198 - spl_get_reducer_gain4(spl_out->scl_data.taps.v_taps, 1199 - spl_out->scl_data.recip_ratios.vert); 1194 + spl_get_reducer_gain4(spl_scratch->scl_data.taps.v_taps, 1195 + spl_scratch->scl_data.recip_ratios.vert); 1200 1196 /* FP1.5.10; (2.5) Ring reducer gain for 6-tap mode [V_REDUCER_GAIN6] */ 1201 1197 dscl_prog_data->easf_v_ringest_eventap_reduceg2 = 1202 - spl_get_reducer_gain6(spl_out->scl_data.taps.v_taps, 1203 - spl_out->scl_data.recip_ratios.vert); 1198 + spl_get_reducer_gain6(spl_scratch->scl_data.taps.v_taps, 1199 + spl_scratch->scl_data.recip_ratios.vert); 1204 1200 /* FP1.5.10; (-0.135742) Ring gain for 6-tap set to -139/1024 */ 1205 1201 dscl_prog_data->easf_v_ringest_eventap_gain1 = 1206 - spl_get_gainRing4(spl_out->scl_data.taps.v_taps, 1207 - spl_out->scl_data.recip_ratios.vert); 1202 + spl_get_gainRing4(spl_scratch->scl_data.taps.v_taps, 1203 + spl_scratch->scl_data.recip_ratios.vert); 1208 1204 /* FP1.5.10; (-0.024414) Ring gain for 6-tap set to -25/1024 */ 1209 1205 dscl_prog_data->easf_v_ringest_eventap_gain2 = 1210 - spl_get_gainRing6(spl_out->scl_data.taps.v_taps, 1211 - spl_out->scl_data.recip_ratios.vert); 1206 + spl_get_gainRing6(spl_scratch->scl_data.taps.v_taps, 1207 + spl_scratch->scl_data.recip_ratios.vert); 1212 1208 dscl_prog_data->easf_v_bf_maxa = 63; //Vertical Max BF value A in U0.6 format.Selected if V_FCNTL == 0 1213 1209 dscl_prog_data->easf_v_bf_maxb = 63; //Vertical Max BF value A in U0.6 format.Selected if V_FCNTL == 1 1214 1210 dscl_prog_data->easf_v_bf_mina = 0; //Vertical Min BF value A in U0.6 format.Selected if V_FCNTL == 0 ··· 1334 1330 0xF; // 4-bit, BF2 calculation mode 1335 1331 /* 2-bit, BF3 chroma mode correction calculation mode */ 1336 1332 dscl_prog_data->easf_h_bf3_mode = spl_get_h_bf3_mode( 1337 - spl_out->scl_data.recip_ratios.horz); 1333 + spl_scratch->scl_data.recip_ratios.horz); 1338 1334 /* FP1.5.10; (2.0) Ring reducer gain for 4 or 6-tap mode [H_REDUCER_GAIN4] */ 1339 1335 dscl_prog_data->easf_h_ringest_eventap_reduceg1 = 1340 - spl_get_reducer_gain4(spl_out->scl_data.taps.h_taps, 1341 - spl_out->scl_data.recip_ratios.horz); 1336 + spl_get_reducer_gain4(spl_scratch->scl_data.taps.h_taps, 1337 + spl_scratch->scl_data.recip_ratios.horz); 1342 1338 /* FP1.5.10; (2.5) Ring reducer gain for 6-tap mode [V_REDUCER_GAIN6] */ 1343 1339 dscl_prog_data->easf_h_ringest_eventap_reduceg2 = 1344 - spl_get_reducer_gain6(spl_out->scl_data.taps.h_taps, 1345 - spl_out->scl_data.recip_ratios.horz); 1340 + spl_get_reducer_gain6(spl_scratch->scl_data.taps.h_taps, 1341 + spl_scratch->scl_data.recip_ratios.horz); 1346 1342 /* FP1.5.10; (-0.135742) Ring gain for 6-tap set to -139/1024 */ 1347 1343 dscl_prog_data->easf_h_ringest_eventap_gain1 = 1348 - spl_get_gainRing4(spl_out->scl_data.taps.h_taps, 1349 - spl_out->scl_data.recip_ratios.horz); 1344 + spl_get_gainRing4(spl_scratch->scl_data.taps.h_taps, 1345 + spl_scratch->scl_data.recip_ratios.horz); 1350 1346 /* FP1.5.10; (-0.024414) Ring gain for 6-tap set to -25/1024 */ 1351 1347 dscl_prog_data->easf_h_ringest_eventap_gain2 = 1352 - spl_get_gainRing6(spl_out->scl_data.taps.h_taps, 1353 - spl_out->scl_data.recip_ratios.horz); 1348 + spl_get_gainRing6(spl_scratch->scl_data.taps.h_taps, 1349 + spl_scratch->scl_data.recip_ratios.horz); 1354 1350 dscl_prog_data->easf_h_bf_maxa = 63; //Horz Max BF value A in U0.6 format.Selected if H_FCNTL==0 1355 1351 dscl_prog_data->easf_h_bf_maxb = 63; //Horz Max BF value B in U0.6 format.Selected if H_FCNTL==1 1356 1352 dscl_prog_data->easf_h_bf_mina = 0; //Horz Min BF value B in U0.6 format.Selected if H_FCNTL==0 ··· 1528 1524 static void spl_set_isharp_data(struct dscl_prog_data *dscl_prog_data, 1529 1525 struct adaptive_sharpness adp_sharpness, bool enable_isharp, 1530 1526 enum linear_light_scaling lls_pref, enum spl_pixel_format format, 1531 - const struct spl_scaler_data *data, struct fixed31_32 ratio, 1527 + const struct spl_scaler_data *data, struct spl_fixed31_32 ratio, 1532 1528 enum system_setup setup) 1533 1529 { 1534 1530 /* Turn off sharpener if not required */ ··· 1642 1638 bool enable_easf_h = false; 1643 1639 int vratio = 0; 1644 1640 int hratio = 0; 1645 - const struct spl_scaler_data *data = &spl_out->scl_data; 1646 - struct fixed31_32 isharp_scale_ratio; 1641 + struct spl_scratch spl_scratch; 1642 + struct spl_fixed31_32 isharp_scale_ratio; 1647 1643 enum system_setup setup; 1648 1644 bool enable_isharp = false; 1645 + const struct spl_scaler_data *data = &spl_scratch.scl_data; 1649 1646 1647 + memset(&spl_scratch, 0, sizeof(struct spl_scratch)); 1648 + spl_scratch.scl_data.h_active = spl_in->h_active; 1649 + spl_scratch.scl_data.v_active = spl_in->v_active; 1650 1650 // All SPL calls 1651 1651 /* recout calculation */ 1652 1652 /* depends on h_active */ 1653 - spl_calculate_recout(spl_in, spl_out); 1653 + spl_calculate_recout(spl_in, &spl_scratch, spl_out); 1654 1654 /* depends on pixel format */ 1655 - spl_calculate_scaling_ratios(spl_in, spl_out); 1655 + spl_calculate_scaling_ratios(spl_in, &spl_scratch, spl_out); 1656 1656 /* depends on scaling ratios and recout, does not calculate offset yet */ 1657 - spl_calculate_viewport_size(spl_in, spl_out); 1657 + spl_calculate_viewport_size(spl_in, &spl_scratch); 1658 1658 1659 1659 res = spl_get_optimal_number_of_taps( 1660 1660 spl_in->basic_out.max_downscale_src_width, spl_in, 1661 - spl_out, &spl_in->scaling_quality, &enable_easf_v, 1661 + &spl_scratch, &spl_in->scaling_quality, &enable_easf_v, 1662 1662 &enable_easf_h, &enable_isharp); 1663 1663 /* 1664 1664 * Depends on recout, scaling ratios, h_active and taps 1665 1665 * May need to re-check lb size after this in some obscure scenario 1666 1666 */ 1667 1667 if (res) 1668 - spl_calculate_inits_and_viewports(spl_in, spl_out); 1668 + spl_calculate_inits_and_viewports(spl_in, &spl_scratch); 1669 1669 // Handle 3d recout 1670 - spl_handle_3d_recout(spl_in, &spl_out->scl_data.recout); 1670 + spl_handle_3d_recout(spl_in, &spl_scratch.scl_data.recout); 1671 1671 // Clamp 1672 - spl_clamp_viewport(&spl_out->scl_data.viewport); 1672 + spl_clamp_viewport(&spl_scratch.scl_data.viewport); 1673 1673 1674 1674 if (!res) 1675 1675 return res; 1676 1676 1677 1677 // Save all calculated parameters in dscl_prog_data structure to program hw registers 1678 - spl_set_dscl_prog_data(spl_in, spl_out, enable_easf_v, enable_easf_h, enable_isharp); 1678 + spl_set_dscl_prog_data(spl_in, &spl_scratch, spl_out, enable_easf_v, enable_easf_h, enable_isharp); 1679 1679 1680 1680 if (spl_in->lls_pref == LLS_PREF_YES) { 1681 1681 if (spl_in->is_hdr_on) ··· 1693 1685 setup = SDR_NL; 1694 1686 } 1695 1687 // Set EASF 1696 - spl_set_easf_data(spl_out, enable_easf_v, enable_easf_h, spl_in->lls_pref, 1688 + spl_set_easf_data(&spl_scratch, spl_out, enable_easf_v, enable_easf_h, spl_in->lls_pref, 1697 1689 spl_in->basic_in.format, setup); 1698 1690 // Set iSHARP 1699 - vratio = dc_fixpt_ceil(spl_out->scl_data.ratios.vert); 1700 - hratio = dc_fixpt_ceil(spl_out->scl_data.ratios.horz); 1691 + vratio = spl_fixpt_ceil(spl_scratch.scl_data.ratios.vert); 1692 + hratio = spl_fixpt_ceil(spl_scratch.scl_data.ratios.horz); 1701 1693 if (vratio <= hratio) 1702 - isharp_scale_ratio = spl_out->scl_data.recip_ratios.vert; 1694 + isharp_scale_ratio = spl_scratch.scl_data.recip_ratios.vert; 1703 1695 else 1704 - isharp_scale_ratio = spl_out->scl_data.recip_ratios.horz; 1696 + isharp_scale_ratio = spl_scratch.scl_data.recip_ratios.horz; 1705 1697 1706 1698 spl_set_isharp_data(spl_out->dscl_prog_data, spl_in->adaptive_sharpness, enable_isharp, 1707 1699 spl_in->lls_pref, spl_in->basic_in.format, data, isharp_scale_ratio, setup);
+13 -14
drivers/gpu/drm/amd/display/dc/spl/dc_spl_isharp_filters.c
··· 3 3 // Copyright 2024 Advanced Micro Devices, Inc. 4 4 5 5 #include "dc_spl_types.h" 6 + #include "spl_debug.h" 6 7 #include "dc_spl_filters.h" 7 8 #include "dc_spl_isharp_filters.h" 8 9 ··· 632 631 return filter_isharp_bs_3tap_64p_s1_12; 633 632 } 634 633 635 - void spl_build_isharp_1dlut_from_reference_curve(struct fixed31_32 ratio, enum system_setup setup) 634 + void spl_build_isharp_1dlut_from_reference_curve(struct spl_fixed31_32 ratio, enum system_setup setup) 636 635 { 637 636 uint8_t *byte_ptr_1dlut_src, *byte_ptr_1dlut_dst; 638 - struct fixed31_32 sharp_base, sharp_calc, sharp_level, ratio_level; 637 + struct spl_fixed31_32 sharp_base, sharp_calc, sharp_level, ratio_level; 639 638 int i, j; 640 639 struct scale_ratio_to_sharpness_level_lookup *setup_lookup_ptr; 641 640 int num_sharp_ramp_levels; ··· 681 680 * base scale ratio to sharpness curve 682 681 */ 683 682 j = 0; 684 - sharp_level = dc_fixpt_zero; 683 + sharp_level = spl_fixpt_zero; 685 684 while (j < num_sharp_ramp_levels) { 686 - ratio_level = dc_fixpt_from_fraction(setup_lookup_ptr->ratio_numer, 685 + ratio_level = spl_fixpt_from_fraction(setup_lookup_ptr->ratio_numer, 687 686 setup_lookup_ptr->ratio_denom); 688 687 if (ratio.value >= ratio_level.value) { 689 - sharp_level = dc_fixpt_from_fraction(setup_lookup_ptr->sharpness_numer, 688 + sharp_level = spl_fixpt_from_fraction(setup_lookup_ptr->sharpness_numer, 690 689 setup_lookup_ptr->sharpness_denom); 691 690 break; 692 691 } ··· 708 707 size_1dlut = sizeof(filter_isharp_1D_lut_3p0x); 709 708 memset(byte_ptr_1dlut_dst, 0, size_1dlut); 710 709 for (j = 0; j < size_1dlut; j++) { 711 - sharp_base = dc_fixpt_from_int((int)*byte_ptr_1dlut_src); 712 - sharp_calc = dc_fixpt_mul(sharp_base, sharp_level); 713 - sharp_calc = dc_fixpt_div(sharp_calc, dc_fixpt_from_int(3)); 714 - sharp_calc = dc_fixpt_min(dc_fixpt_from_int(255), sharp_calc); 715 - sharp_calc = dc_fixpt_add(sharp_calc, dc_fixpt_from_fraction(1, 2)); 716 - sharp_calc_int = dc_fixpt_floor(sharp_calc); 710 + sharp_base = spl_fixpt_from_int((int)*byte_ptr_1dlut_src); 711 + sharp_calc = spl_fixpt_mul(sharp_base, sharp_level); 712 + sharp_calc = spl_fixpt_div(sharp_calc, spl_fixpt_from_int(3)); 713 + sharp_calc = spl_fixpt_min(spl_fixpt_from_int(255), sharp_calc); 714 + sharp_calc = spl_fixpt_add(sharp_calc, spl_fixpt_from_fraction(1, 2)); 715 + sharp_calc_int = spl_fixpt_floor(sharp_calc); 717 716 if (sharp_calc_int > 255) 718 717 sharp_calc_int = 255; 719 718 *byte_ptr_1dlut_dst = (uint8_t)sharp_calc_int; ··· 743 742 filter_isharp_bs_4tap_in_6_64p_s1_12, 6); 744 743 } 745 744 746 - #ifdef CONFIG_DRM_AMD_DC_FP 747 745 uint16_t *spl_dscl_get_blur_scale_coeffs_64p(int taps) 748 746 { 749 747 if (taps == 3) ··· 753 753 return spl_get_filter_isharp_bs_4tap_in_6_64p(); 754 754 else { 755 755 /* should never happen, bug */ 756 - BREAK_TO_DEBUGGER(); 756 + SPL_BREAK_TO_DEBUGGER(); 757 757 return NULL; 758 758 } 759 759 } ··· 767 767 dscl_prog_data->filter_blur_scale_v = 768 768 spl_dscl_get_blur_scale_coeffs_64p(data->taps.v_taps); 769 769 } 770 - #endif 771 770
+1 -1
drivers/gpu/drm/amd/display/dc/spl/dc_spl_isharp_filters.h
··· 43 43 void spl_set_blur_scale_data(struct dscl_prog_data *dscl_prog_data, 44 44 const struct spl_scaler_data *data); 45 45 46 - void spl_build_isharp_1dlut_from_reference_curve(struct fixed31_32 ratio, enum system_setup setup); 46 + void spl_build_isharp_1dlut_from_reference_curve(struct spl_fixed31_32 ratio, enum system_setup setup); 47 47 uint32_t *spl_get_pregen_filter_isharp_1D_lut(enum explicit_sharpness sharpness); 48 48 #endif /* __DC_SPL_ISHARP_FILTERS_H__ */
+41 -40
drivers/gpu/drm/amd/display/dc/spl/dc_spl_scl_easf_filters.c
··· 2 2 // 3 3 // Copyright 2024 Advanced Micro Devices, Inc. 4 4 5 + #include "spl_debug.h" 5 6 #include "dc_spl_filters.h" 6 7 #include "dc_spl_scl_filters.h" 7 8 #include "dc_spl_scl_easf_filters.h" ··· 1407 1406 easf_filter_6tap_64p_ratio_1_00_s1_12, 6); 1408 1407 } 1409 1408 1410 - uint16_t *spl_get_easf_filter_3tap_64p(struct fixed31_32 ratio) 1409 + uint16_t *spl_get_easf_filter_3tap_64p(struct spl_fixed31_32 ratio) 1411 1410 { 1412 - if (ratio.value < dc_fixpt_from_fraction(3, 10).value) 1411 + if (ratio.value < spl_fixpt_from_fraction(3, 10).value) 1413 1412 return easf_filter_3tap_64p_ratio_0_30_s1_12; 1414 - else if (ratio.value < dc_fixpt_from_fraction(4, 10).value) 1413 + else if (ratio.value < spl_fixpt_from_fraction(4, 10).value) 1415 1414 return easf_filter_3tap_64p_ratio_0_40_s1_12; 1416 - else if (ratio.value < dc_fixpt_from_fraction(5, 10).value) 1415 + else if (ratio.value < spl_fixpt_from_fraction(5, 10).value) 1417 1416 return easf_filter_3tap_64p_ratio_0_50_s1_12; 1418 - else if (ratio.value < dc_fixpt_from_fraction(6, 10).value) 1417 + else if (ratio.value < spl_fixpt_from_fraction(6, 10).value) 1419 1418 return easf_filter_3tap_64p_ratio_0_60_s1_12; 1420 - else if (ratio.value < dc_fixpt_from_fraction(7, 10).value) 1419 + else if (ratio.value < spl_fixpt_from_fraction(7, 10).value) 1421 1420 return easf_filter_3tap_64p_ratio_0_70_s1_12; 1422 - else if (ratio.value < dc_fixpt_from_fraction(8, 10).value) 1421 + else if (ratio.value < spl_fixpt_from_fraction(8, 10).value) 1423 1422 return easf_filter_3tap_64p_ratio_0_80_s1_12; 1424 - else if (ratio.value < dc_fixpt_from_fraction(9, 10).value) 1423 + else if (ratio.value < spl_fixpt_from_fraction(9, 10).value) 1425 1424 return easf_filter_3tap_64p_ratio_0_90_s1_12; 1426 1425 else 1427 1426 return easf_filter_3tap_64p_ratio_1_00_s1_12; 1428 1427 } 1429 1428 1430 - uint16_t *spl_get_easf_filter_4tap_64p(struct fixed31_32 ratio) 1429 + uint16_t *spl_get_easf_filter_4tap_64p(struct spl_fixed31_32 ratio) 1431 1430 { 1432 - if (ratio.value < dc_fixpt_from_fraction(3, 10).value) 1431 + if (ratio.value < spl_fixpt_from_fraction(3, 10).value) 1433 1432 return easf_filter_4tap_64p_ratio_0_30_s1_12; 1434 - else if (ratio.value < dc_fixpt_from_fraction(4, 10).value) 1433 + else if (ratio.value < spl_fixpt_from_fraction(4, 10).value) 1435 1434 return easf_filter_4tap_64p_ratio_0_40_s1_12; 1436 - else if (ratio.value < dc_fixpt_from_fraction(5, 10).value) 1435 + else if (ratio.value < spl_fixpt_from_fraction(5, 10).value) 1437 1436 return easf_filter_4tap_64p_ratio_0_50_s1_12; 1438 - else if (ratio.value < dc_fixpt_from_fraction(6, 10).value) 1437 + else if (ratio.value < spl_fixpt_from_fraction(6, 10).value) 1439 1438 return easf_filter_4tap_64p_ratio_0_60_s1_12; 1440 - else if (ratio.value < dc_fixpt_from_fraction(7, 10).value) 1439 + else if (ratio.value < spl_fixpt_from_fraction(7, 10).value) 1441 1440 return easf_filter_4tap_64p_ratio_0_70_s1_12; 1442 - else if (ratio.value < dc_fixpt_from_fraction(8, 10).value) 1441 + else if (ratio.value < spl_fixpt_from_fraction(8, 10).value) 1443 1442 return easf_filter_4tap_64p_ratio_0_80_s1_12; 1444 - else if (ratio.value < dc_fixpt_from_fraction(9, 10).value) 1443 + else if (ratio.value < spl_fixpt_from_fraction(9, 10).value) 1445 1444 return easf_filter_4tap_64p_ratio_0_90_s1_12; 1446 1445 else 1447 1446 return easf_filter_4tap_64p_ratio_1_00_s1_12; 1448 1447 } 1449 1448 1450 - uint16_t *spl_get_easf_filter_6tap_64p(struct fixed31_32 ratio) 1449 + uint16_t *spl_get_easf_filter_6tap_64p(struct spl_fixed31_32 ratio) 1451 1450 { 1452 - if (ratio.value < dc_fixpt_from_fraction(3, 10).value) 1451 + if (ratio.value < spl_fixpt_from_fraction(3, 10).value) 1453 1452 return easf_filter_6tap_64p_ratio_0_30_s1_12; 1454 - else if (ratio.value < dc_fixpt_from_fraction(4, 10).value) 1453 + else if (ratio.value < spl_fixpt_from_fraction(4, 10).value) 1455 1454 return easf_filter_6tap_64p_ratio_0_40_s1_12; 1456 - else if (ratio.value < dc_fixpt_from_fraction(5, 10).value) 1455 + else if (ratio.value < spl_fixpt_from_fraction(5, 10).value) 1457 1456 return easf_filter_6tap_64p_ratio_0_50_s1_12; 1458 - else if (ratio.value < dc_fixpt_from_fraction(6, 10).value) 1457 + else if (ratio.value < spl_fixpt_from_fraction(6, 10).value) 1459 1458 return easf_filter_6tap_64p_ratio_0_60_s1_12; 1460 - else if (ratio.value < dc_fixpt_from_fraction(7, 10).value) 1459 + else if (ratio.value < spl_fixpt_from_fraction(7, 10).value) 1461 1460 return easf_filter_6tap_64p_ratio_0_70_s1_12; 1462 - else if (ratio.value < dc_fixpt_from_fraction(8, 10).value) 1461 + else if (ratio.value < spl_fixpt_from_fraction(8, 10).value) 1463 1462 return easf_filter_6tap_64p_ratio_0_80_s1_12; 1464 - else if (ratio.value < dc_fixpt_from_fraction(9, 10).value) 1463 + else if (ratio.value < spl_fixpt_from_fraction(9, 10).value) 1465 1464 return easf_filter_6tap_64p_ratio_0_90_s1_12; 1466 1465 else 1467 1466 return easf_filter_6tap_64p_ratio_1_00_s1_12; 1468 1467 } 1469 1468 1470 - uint16_t *spl_dscl_get_easf_filter_coeffs_64p(int taps, struct fixed31_32 ratio) 1469 + uint16_t *spl_dscl_get_easf_filter_coeffs_64p(int taps, struct spl_fixed31_32 ratio) 1471 1470 { 1472 1471 if (taps == 6) 1473 1472 return spl_get_easf_filter_6tap_64p(ratio); ··· 1477 1476 return spl_get_easf_filter_3tap_64p(ratio); 1478 1477 else { 1479 1478 /* should never happen, bug */ 1480 - BREAK_TO_DEBUGGER(); 1479 + SPL_BREAK_TO_DEBUGGER(); 1481 1480 return NULL; 1482 1481 } 1483 1482 } ··· 1518 1517 } 1519 1518 } 1520 1519 1521 - static uint32_t spl_easf_get_scale_ratio_to_reg_value(struct fixed31_32 ratio, 1520 + static uint32_t spl_easf_get_scale_ratio_to_reg_value(struct spl_fixed31_32 ratio, 1522 1521 struct scale_ratio_to_reg_value_lookup *lookup_table_base_ptr, 1523 1522 unsigned int num_entries) 1524 1523 { ··· 1535 1534 if (lookup_table_index_ptr->numer < 0) 1536 1535 break; 1537 1536 1538 - if (ratio.value < dc_fixpt_from_fraction( 1537 + if (ratio.value < spl_fixpt_from_fraction( 1539 1538 lookup_table_index_ptr->numer, 1540 1539 lookup_table_index_ptr->denom).value) { 1541 1540 value = lookup_table_index_ptr->reg_value; ··· 1546 1545 } 1547 1546 return value; 1548 1547 } 1549 - uint32_t spl_get_v_bf3_mode(struct fixed31_32 ratio) 1548 + uint32_t spl_get_v_bf3_mode(struct spl_fixed31_32 ratio) 1550 1549 { 1551 1550 uint32_t value; 1552 1551 unsigned int num_entries = sizeof(easf_v_bf3_mode_lookup) / ··· 1555 1554 easf_v_bf3_mode_lookup, num_entries); 1556 1555 return value; 1557 1556 } 1558 - uint32_t spl_get_h_bf3_mode(struct fixed31_32 ratio) 1557 + uint32_t spl_get_h_bf3_mode(struct spl_fixed31_32 ratio) 1559 1558 { 1560 1559 uint32_t value; 1561 1560 unsigned int num_entries = sizeof(easf_h_bf3_mode_lookup) / ··· 1564 1563 easf_h_bf3_mode_lookup, num_entries); 1565 1564 return value; 1566 1565 } 1567 - uint32_t spl_get_reducer_gain6(int taps, struct fixed31_32 ratio) 1566 + uint32_t spl_get_reducer_gain6(int taps, struct spl_fixed31_32 ratio) 1568 1567 { 1569 1568 uint32_t value; 1570 1569 unsigned int num_entries; ··· 1583 1582 value = 0; 1584 1583 return value; 1585 1584 } 1586 - uint32_t spl_get_reducer_gain4(int taps, struct fixed31_32 ratio) 1585 + uint32_t spl_get_reducer_gain4(int taps, struct spl_fixed31_32 ratio) 1587 1586 { 1588 1587 uint32_t value; 1589 1588 unsigned int num_entries; ··· 1602 1601 value = 0; 1603 1602 return value; 1604 1603 } 1605 - uint32_t spl_get_gainRing6(int taps, struct fixed31_32 ratio) 1604 + uint32_t spl_get_gainRing6(int taps, struct spl_fixed31_32 ratio) 1606 1605 { 1607 1606 uint32_t value; 1608 1607 unsigned int num_entries; ··· 1621 1620 value = 0; 1622 1621 return value; 1623 1622 } 1624 - uint32_t spl_get_gainRing4(int taps, struct fixed31_32 ratio) 1623 + uint32_t spl_get_gainRing4(int taps, struct spl_fixed31_32 ratio) 1625 1624 { 1626 1625 uint32_t value; 1627 1626 unsigned int num_entries; ··· 1640 1639 value = 0; 1641 1640 return value; 1642 1641 } 1643 - uint32_t spl_get_3tap_dntilt_uptilt_offset(int taps, struct fixed31_32 ratio) 1642 + uint32_t spl_get_3tap_dntilt_uptilt_offset(int taps, struct spl_fixed31_32 ratio) 1644 1643 { 1645 1644 uint32_t value; 1646 1645 unsigned int num_entries; ··· 1654 1653 value = 0; 1655 1654 return value; 1656 1655 } 1657 - uint32_t spl_get_3tap_uptilt_maxval(int taps, struct fixed31_32 ratio) 1656 + uint32_t spl_get_3tap_uptilt_maxval(int taps, struct spl_fixed31_32 ratio) 1658 1657 { 1659 1658 uint32_t value; 1660 1659 unsigned int num_entries; ··· 1668 1667 value = 0; 1669 1668 return value; 1670 1669 } 1671 - uint32_t spl_get_3tap_dntilt_slope(int taps, struct fixed31_32 ratio) 1670 + uint32_t spl_get_3tap_dntilt_slope(int taps, struct spl_fixed31_32 ratio) 1672 1671 { 1673 1672 uint32_t value; 1674 1673 unsigned int num_entries; ··· 1682 1681 value = 0; 1683 1682 return value; 1684 1683 } 1685 - uint32_t spl_get_3tap_uptilt1_slope(int taps, struct fixed31_32 ratio) 1684 + uint32_t spl_get_3tap_uptilt1_slope(int taps, struct spl_fixed31_32 ratio) 1686 1685 { 1687 1686 uint32_t value; 1688 1687 unsigned int num_entries; ··· 1696 1695 value = 0; 1697 1696 return value; 1698 1697 } 1699 - uint32_t spl_get_3tap_uptilt2_slope(int taps, struct fixed31_32 ratio) 1698 + uint32_t spl_get_3tap_uptilt2_slope(int taps, struct spl_fixed31_32 ratio) 1700 1699 { 1701 1700 uint32_t value; 1702 1701 unsigned int num_entries; ··· 1710 1709 value = 0; 1711 1710 return value; 1712 1711 } 1713 - uint32_t spl_get_3tap_uptilt2_offset(int taps, struct fixed31_32 ratio) 1712 + uint32_t spl_get_3tap_uptilt2_offset(int taps, struct spl_fixed31_32 ratio) 1714 1713 { 1715 1714 uint32_t value; 1716 1715 unsigned int num_entries;
+16 -16
drivers/gpu/drm/amd/display/dc/spl/dc_spl_scl_easf_filters.h
··· 14 14 }; 15 15 16 16 void spl_init_easf_filter_coeffs(void); 17 - uint16_t *spl_get_easf_filter_3tap_64p(struct fixed31_32 ratio); 18 - uint16_t *spl_get_easf_filter_4tap_64p(struct fixed31_32 ratio); 19 - uint16_t *spl_get_easf_filter_6tap_64p(struct fixed31_32 ratio); 20 - uint16_t *spl_dscl_get_easf_filter_coeffs_64p(int taps, struct fixed31_32 ratio); 17 + uint16_t *spl_get_easf_filter_3tap_64p(struct spl_fixed31_32 ratio); 18 + uint16_t *spl_get_easf_filter_4tap_64p(struct spl_fixed31_32 ratio); 19 + uint16_t *spl_get_easf_filter_6tap_64p(struct spl_fixed31_32 ratio); 20 + uint16_t *spl_dscl_get_easf_filter_coeffs_64p(int taps, struct spl_fixed31_32 ratio); 21 21 void spl_set_filters_data(struct dscl_prog_data *dscl_prog_data, 22 22 const struct spl_scaler_data *data, bool enable_easf_v, 23 23 bool enable_easf_h); 24 24 25 - uint32_t spl_get_v_bf3_mode(struct fixed31_32 ratio); 26 - uint32_t spl_get_h_bf3_mode(struct fixed31_32 ratio); 27 - uint32_t spl_get_reducer_gain6(int taps, struct fixed31_32 ratio); 28 - uint32_t spl_get_reducer_gain4(int taps, struct fixed31_32 ratio); 29 - uint32_t spl_get_gainRing6(int taps, struct fixed31_32 ratio); 30 - uint32_t spl_get_gainRing4(int taps, struct fixed31_32 ratio); 31 - uint32_t spl_get_3tap_dntilt_uptilt_offset(int taps, struct fixed31_32 ratio); 32 - uint32_t spl_get_3tap_uptilt_maxval(int taps, struct fixed31_32 ratio); 33 - uint32_t spl_get_3tap_dntilt_slope(int taps, struct fixed31_32 ratio); 34 - uint32_t spl_get_3tap_uptilt1_slope(int taps, struct fixed31_32 ratio); 35 - uint32_t spl_get_3tap_uptilt2_slope(int taps, struct fixed31_32 ratio); 36 - uint32_t spl_get_3tap_uptilt2_offset(int taps, struct fixed31_32 ratio); 25 + uint32_t spl_get_v_bf3_mode(struct spl_fixed31_32 ratio); 26 + uint32_t spl_get_h_bf3_mode(struct spl_fixed31_32 ratio); 27 + uint32_t spl_get_reducer_gain6(int taps, struct spl_fixed31_32 ratio); 28 + uint32_t spl_get_reducer_gain4(int taps, struct spl_fixed31_32 ratio); 29 + uint32_t spl_get_gainRing6(int taps, struct spl_fixed31_32 ratio); 30 + uint32_t spl_get_gainRing4(int taps, struct spl_fixed31_32 ratio); 31 + uint32_t spl_get_3tap_dntilt_uptilt_offset(int taps, struct spl_fixed31_32 ratio); 32 + uint32_t spl_get_3tap_uptilt_maxval(int taps, struct spl_fixed31_32 ratio); 33 + uint32_t spl_get_3tap_dntilt_slope(int taps, struct spl_fixed31_32 ratio); 34 + uint32_t spl_get_3tap_uptilt1_slope(int taps, struct spl_fixed31_32 ratio); 35 + uint32_t spl_get_3tap_uptilt2_slope(int taps, struct spl_fixed31_32 ratio); 36 + uint32_t spl_get_3tap_uptilt2_offset(int taps, struct spl_fixed31_32 ratio); 37 37 38 38 #endif /* __DC_SPL_SCL_EASF_FILTERS_H__ */
+35 -34
drivers/gpu/drm/amd/display/dc/spl/dc_spl_scl_filters.c
··· 3 3 // Copyright 2024 Advanced Micro Devices, Inc. 4 4 5 5 #include "dc_spl_types.h" 6 + #include "spl_debug.h" 6 7 #include "dc_spl_scl_filters.h" 7 8 //========================================= 8 9 // <num_taps> = 2 ··· 1319 1318 0x3FD4, 0x3F84, 0x0214, 0x0694, 0x0694, 0x0214, 0x3F84, 0x3FD4 1320 1319 }; 1321 1320 1322 - const uint16_t *spl_get_filter_3tap_16p(struct fixed31_32 ratio) 1321 + const uint16_t *spl_get_filter_3tap_16p(struct spl_fixed31_32 ratio) 1323 1322 { 1324 - if (ratio.value < dc_fixpt_one.value) 1323 + if (ratio.value < spl_fixpt_one.value) 1325 1324 return filter_3tap_16p_upscale; 1326 - else if (ratio.value < dc_fixpt_from_fraction(4, 3).value) 1325 + else if (ratio.value < spl_fixpt_from_fraction(4, 3).value) 1327 1326 return filter_3tap_16p_116; 1328 - else if (ratio.value < dc_fixpt_from_fraction(5, 3).value) 1327 + else if (ratio.value < spl_fixpt_from_fraction(5, 3).value) 1329 1328 return filter_3tap_16p_149; 1330 1329 else 1331 1330 return filter_3tap_16p_183; 1332 1331 } 1333 1332 1334 - const uint16_t *spl_get_filter_3tap_64p(struct fixed31_32 ratio) 1333 + const uint16_t *spl_get_filter_3tap_64p(struct spl_fixed31_32 ratio) 1335 1334 { 1336 - if (ratio.value < dc_fixpt_one.value) 1335 + if (ratio.value < spl_fixpt_one.value) 1337 1336 return filter_3tap_64p_upscale; 1338 - else if (ratio.value < dc_fixpt_from_fraction(4, 3).value) 1337 + else if (ratio.value < spl_fixpt_from_fraction(4, 3).value) 1339 1338 return filter_3tap_64p_116; 1340 - else if (ratio.value < dc_fixpt_from_fraction(5, 3).value) 1339 + else if (ratio.value < spl_fixpt_from_fraction(5, 3).value) 1341 1340 return filter_3tap_64p_149; 1342 1341 else 1343 1342 return filter_3tap_64p_183; 1344 1343 } 1345 1344 1346 - const uint16_t *spl_get_filter_4tap_16p(struct fixed31_32 ratio) 1345 + const uint16_t *spl_get_filter_4tap_16p(struct spl_fixed31_32 ratio) 1347 1346 { 1348 - if (ratio.value < dc_fixpt_one.value) 1347 + if (ratio.value < spl_fixpt_one.value) 1349 1348 return filter_4tap_16p_upscale; 1350 - else if (ratio.value < dc_fixpt_from_fraction(4, 3).value) 1349 + else if (ratio.value < spl_fixpt_from_fraction(4, 3).value) 1351 1350 return filter_4tap_16p_116; 1352 - else if (ratio.value < dc_fixpt_from_fraction(5, 3).value) 1351 + else if (ratio.value < spl_fixpt_from_fraction(5, 3).value) 1353 1352 return filter_4tap_16p_149; 1354 1353 else 1355 1354 return filter_4tap_16p_183; 1356 1355 } 1357 1356 1358 - const uint16_t *spl_get_filter_4tap_64p(struct fixed31_32 ratio) 1357 + const uint16_t *spl_get_filter_4tap_64p(struct spl_fixed31_32 ratio) 1359 1358 { 1360 - if (ratio.value < dc_fixpt_one.value) 1359 + if (ratio.value < spl_fixpt_one.value) 1361 1360 return filter_4tap_64p_upscale; 1362 - else if (ratio.value < dc_fixpt_from_fraction(4, 3).value) 1361 + else if (ratio.value < spl_fixpt_from_fraction(4, 3).value) 1363 1362 return filter_4tap_64p_116; 1364 - else if (ratio.value < dc_fixpt_from_fraction(5, 3).value) 1363 + else if (ratio.value < spl_fixpt_from_fraction(5, 3).value) 1365 1364 return filter_4tap_64p_149; 1366 1365 else 1367 1366 return filter_4tap_64p_183; 1368 1367 } 1369 1368 1370 - const uint16_t *spl_get_filter_5tap_64p(struct fixed31_32 ratio) 1369 + const uint16_t *spl_get_filter_5tap_64p(struct spl_fixed31_32 ratio) 1371 1370 { 1372 - if (ratio.value < dc_fixpt_one.value) 1371 + if (ratio.value < spl_fixpt_one.value) 1373 1372 return filter_5tap_64p_upscale; 1374 - else if (ratio.value < dc_fixpt_from_fraction(4, 3).value) 1373 + else if (ratio.value < spl_fixpt_from_fraction(4, 3).value) 1375 1374 return filter_5tap_64p_116; 1376 - else if (ratio.value < dc_fixpt_from_fraction(5, 3).value) 1375 + else if (ratio.value < spl_fixpt_from_fraction(5, 3).value) 1377 1376 return filter_5tap_64p_149; 1378 1377 else 1379 1378 return filter_5tap_64p_183; 1380 1379 } 1381 1380 1382 - const uint16_t *spl_get_filter_6tap_64p(struct fixed31_32 ratio) 1381 + const uint16_t *spl_get_filter_6tap_64p(struct spl_fixed31_32 ratio) 1383 1382 { 1384 - if (ratio.value < dc_fixpt_one.value) 1383 + if (ratio.value < spl_fixpt_one.value) 1385 1384 return filter_6tap_64p_upscale; 1386 - else if (ratio.value < dc_fixpt_from_fraction(4, 3).value) 1385 + else if (ratio.value < spl_fixpt_from_fraction(4, 3).value) 1387 1386 return filter_6tap_64p_116; 1388 - else if (ratio.value < dc_fixpt_from_fraction(5, 3).value) 1387 + else if (ratio.value < spl_fixpt_from_fraction(5, 3).value) 1389 1388 return filter_6tap_64p_149; 1390 1389 else 1391 1390 return filter_6tap_64p_183; 1392 1391 } 1393 1392 1394 - const uint16_t *spl_get_filter_7tap_64p(struct fixed31_32 ratio) 1393 + const uint16_t *spl_get_filter_7tap_64p(struct spl_fixed31_32 ratio) 1395 1394 { 1396 - if (ratio.value < dc_fixpt_one.value) 1395 + if (ratio.value < spl_fixpt_one.value) 1397 1396 return filter_7tap_64p_upscale; 1398 - else if (ratio.value < dc_fixpt_from_fraction(4, 3).value) 1397 + else if (ratio.value < spl_fixpt_from_fraction(4, 3).value) 1399 1398 return filter_7tap_64p_116; 1400 - else if (ratio.value < dc_fixpt_from_fraction(5, 3).value) 1399 + else if (ratio.value < spl_fixpt_from_fraction(5, 3).value) 1401 1400 return filter_7tap_64p_149; 1402 1401 else 1403 1402 return filter_7tap_64p_183; 1404 1403 } 1405 1404 1406 - const uint16_t *spl_get_filter_8tap_64p(struct fixed31_32 ratio) 1405 + const uint16_t *spl_get_filter_8tap_64p(struct spl_fixed31_32 ratio) 1407 1406 { 1408 - if (ratio.value < dc_fixpt_one.value) 1407 + if (ratio.value < spl_fixpt_one.value) 1409 1408 return filter_8tap_64p_upscale; 1410 - else if (ratio.value < dc_fixpt_from_fraction(4, 3).value) 1409 + else if (ratio.value < spl_fixpt_from_fraction(4, 3).value) 1411 1410 return filter_8tap_64p_116; 1412 - else if (ratio.value < dc_fixpt_from_fraction(5, 3).value) 1411 + else if (ratio.value < spl_fixpt_from_fraction(5, 3).value) 1413 1412 return filter_8tap_64p_149; 1414 1413 else 1415 1414 return filter_8tap_64p_183; ··· 1425 1424 return filter_2tap_64p; 1426 1425 } 1427 1426 1428 - const uint16_t *spl_dscl_get_filter_coeffs_64p(int taps, struct fixed31_32 ratio) 1427 + const uint16_t *spl_dscl_get_filter_coeffs_64p(int taps, struct spl_fixed31_32 ratio) 1429 1428 { 1430 1429 if (taps == 8) 1431 1430 return spl_get_filter_8tap_64p(ratio); ··· 1445 1444 return NULL; 1446 1445 else { 1447 1446 /* should never happen, bug */ 1448 - BREAK_TO_DEBUGGER(); 1447 + SPL_BREAK_TO_DEBUGGER(); 1449 1448 return NULL; 1450 1449 } 1451 1450 }
+9 -9
drivers/gpu/drm/amd/display/dc/spl/dc_spl_scl_filters.h
··· 7 7 8 8 #include "dc_spl_types.h" 9 9 10 - const uint16_t *spl_get_filter_3tap_16p(struct fixed31_32 ratio); 11 - const uint16_t *spl_get_filter_3tap_64p(struct fixed31_32 ratio); 12 - const uint16_t *spl_get_filter_4tap_16p(struct fixed31_32 ratio); 13 - const uint16_t *spl_get_filter_4tap_64p(struct fixed31_32 ratio); 14 - const uint16_t *spl_get_filter_5tap_64p(struct fixed31_32 ratio); 15 - const uint16_t *spl_get_filter_6tap_64p(struct fixed31_32 ratio); 16 - const uint16_t *spl_get_filter_7tap_64p(struct fixed31_32 ratio); 17 - const uint16_t *spl_get_filter_8tap_64p(struct fixed31_32 ratio); 10 + const uint16_t *spl_get_filter_3tap_16p(struct spl_fixed31_32 ratio); 11 + const uint16_t *spl_get_filter_3tap_64p(struct spl_fixed31_32 ratio); 12 + const uint16_t *spl_get_filter_4tap_16p(struct spl_fixed31_32 ratio); 13 + const uint16_t *spl_get_filter_4tap_64p(struct spl_fixed31_32 ratio); 14 + const uint16_t *spl_get_filter_5tap_64p(struct spl_fixed31_32 ratio); 15 + const uint16_t *spl_get_filter_6tap_64p(struct spl_fixed31_32 ratio); 16 + const uint16_t *spl_get_filter_7tap_64p(struct spl_fixed31_32 ratio); 17 + const uint16_t *spl_get_filter_8tap_64p(struct spl_fixed31_32 ratio); 18 18 const uint16_t *spl_get_filter_2tap_16p(void); 19 19 const uint16_t *spl_get_filter_2tap_64p(void); 20 - const uint16_t *spl_dscl_get_filter_coeffs_64p(int taps, struct fixed31_32 ratio); 20 + const uint16_t *spl_dscl_get_filter_coeffs_64p(int taps, struct spl_fixed31_32 ratio); 21 21 22 22 #endif /* __DC_SPL_SCL_FILTERS_H__ */
+23 -16
drivers/gpu/drm/amd/display/dc/spl/dc_spl_types.h
··· 2 2 // 3 3 // Copyright 2024 Advanced Micro Devices, Inc. 4 4 5 - #include "os_types.h" 6 - #include "dc_hw_types.h" 7 - #ifndef ASSERT 8 - #define ASSERT(_bool) (void *)0 9 - #endif 10 - #include "include/fixed31_32.h" // fixed31_32 and related functions 11 5 #ifndef __DC_SPL_TYPES_H__ 12 6 #define __DC_SPL_TYPES_H__ 7 + 8 + #include "spl_os_types.h" // swap 9 + #ifndef SPL_ASSERT 10 + #define SPL_ASSERT(_bool) ((void *)0) 11 + #endif 12 + #include "spl_fixpt31_32.h" // fixed31_32 and related functions 13 13 14 14 enum lb_memory_config { 15 15 /* Enable all 3 pieces of memory */ ··· 39 39 }; 40 40 41 41 struct spl_ratios { 42 - struct fixed31_32 horz; 43 - struct fixed31_32 vert; 44 - struct fixed31_32 horz_c; 45 - struct fixed31_32 vert_c; 42 + struct spl_fixed31_32 horz; 43 + struct spl_fixed31_32 vert; 44 + struct spl_fixed31_32 horz_c; 45 + struct spl_fixed31_32 vert_c; 46 46 }; 47 47 struct spl_inits { 48 - struct fixed31_32 h; 49 - struct fixed31_32 h_c; 50 - struct fixed31_32 v; 51 - struct fixed31_32 v_c; 48 + struct spl_fixed31_32 h; 49 + struct spl_fixed31_32 h_c; 50 + struct spl_fixed31_32 v; 51 + struct spl_fixed31_32 v_c; 52 52 }; 53 53 54 54 struct spl_taps { ··· 409 409 }; 410 410 411 411 /* SPL input and output definitions */ 412 - // SPL outputs struct 413 - struct spl_out { 412 + // SPL scratch struct 413 + struct spl_scratch { 414 414 // Pack all SPL outputs in scl_data 415 415 struct spl_scaler_data scl_data; 416 + }; 417 + 418 + /* SPL input and output definitions */ 419 + // SPL outputs struct 420 + struct spl_out { 416 421 // Pack all output need to program hw registers 417 422 struct dscl_prog_data *dscl_prog_data; 418 423 }; ··· 502 497 struct spl_debug debug; 503 498 bool is_fullscreen; 504 499 bool is_hdr_on; 500 + int h_active; 501 + int v_active; 505 502 }; 506 503 // end of SPL inputs 507 504
+23
drivers/gpu/drm/amd/display/dc/spl/spl_debug.h
··· 1 + /* Copyright � 1997-2004 Advanced Micro Devices, Inc. All rights reserved. */ 2 + 3 + #ifndef SPL_DEBUG_H 4 + #define SPL_DEBUG_H 5 + 6 + #ifdef SPL_ASSERT 7 + #undef SPL_ASSERT 8 + #endif 9 + #define SPL_ASSERT(b) 10 + 11 + #define SPL_ASSERT_CRITICAL(expr) do {if (expr)/* Do nothing */; } while (0) 12 + 13 + #ifdef SPL_DALMSG 14 + #undef SPL_DALMSG 15 + #endif 16 + #define SPL_DALMSG(b) 17 + 18 + #ifdef SPL_DAL_ASSERT_MSG 19 + #undef SPL_DAL_ASSERT_MSG 20 + #endif 21 + #define SPL_DAL_ASSERT_MSG(b, m) 22 + 23 + #endif // SPL_DEBUG_H
+518
drivers/gpu/drm/amd/display/dc/spl/spl_fixpt31_32.c
··· 1 + /* 2 + * Copyright 2012-15 Advanced Micro Devices, Inc. 3 + * 4 + * Permission is hereby granted, free of charge, to any person obtaining a 5 + * copy of this software and associated documentation files (the "Software"), 6 + * to deal in the Software without restriction, including without limitation 7 + * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 + * and/or sell copies of the Software, and to permit persons to whom the 9 + * Software is furnished to do so, subject to the following conditions: 10 + * 11 + * The above copyright notice and this permission notice shall be included in 12 + * all copies or substantial portions of the Software. 13 + * 14 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 + * OTHER DEALINGS IN THE SOFTWARE. 21 + * 22 + * Authors: AMD 23 + * 24 + */ 25 + 26 + #include "spl_fixpt31_32.h" 27 + 28 + static const struct spl_fixed31_32 spl_fixpt_two_pi = { 26986075409LL }; 29 + static const struct spl_fixed31_32 spl_fixpt_ln2 = { 2977044471LL }; 30 + static const struct spl_fixed31_32 spl_fixpt_ln2_div_2 = { 1488522236LL }; 31 + 32 + static inline unsigned long long abs_i64( 33 + long long arg) 34 + { 35 + if (arg > 0) 36 + return (unsigned long long)arg; 37 + else 38 + return (unsigned long long)(-arg); 39 + } 40 + 41 + /* 42 + * @brief 43 + * result = dividend / divisor 44 + * *remainder = dividend % divisor 45 + */ 46 + static inline unsigned long long complete_integer_division_u64( 47 + unsigned long long dividend, 48 + unsigned long long divisor, 49 + unsigned long long *remainder) 50 + { 51 + unsigned long long result; 52 + 53 + ASSERT(divisor); 54 + 55 + result = spl_div64_u64_rem(dividend, divisor, remainder); 56 + 57 + return result; 58 + } 59 + 60 + 61 + #define FRACTIONAL_PART_MASK \ 62 + ((1ULL << FIXED31_32_BITS_PER_FRACTIONAL_PART) - 1) 63 + 64 + #define GET_INTEGER_PART(x) \ 65 + ((x) >> FIXED31_32_BITS_PER_FRACTIONAL_PART) 66 + 67 + #define GET_FRACTIONAL_PART(x) \ 68 + (FRACTIONAL_PART_MASK & (x)) 69 + 70 + struct spl_fixed31_32 spl_fixpt_from_fraction(long long numerator, long long denominator) 71 + { 72 + struct spl_fixed31_32 res; 73 + 74 + bool arg1_negative = numerator < 0; 75 + bool arg2_negative = denominator < 0; 76 + 77 + unsigned long long arg1_value = arg1_negative ? -numerator : numerator; 78 + unsigned long long arg2_value = arg2_negative ? -denominator : denominator; 79 + 80 + unsigned long long remainder; 81 + 82 + /* determine integer part */ 83 + 84 + unsigned long long res_value = complete_integer_division_u64( 85 + arg1_value, arg2_value, &remainder); 86 + 87 + ASSERT(res_value <= LONG_MAX); 88 + 89 + /* determine fractional part */ 90 + { 91 + unsigned int i = FIXED31_32_BITS_PER_FRACTIONAL_PART; 92 + 93 + do { 94 + remainder <<= 1; 95 + 96 + res_value <<= 1; 97 + 98 + if (remainder >= arg2_value) { 99 + res_value |= 1; 100 + remainder -= arg2_value; 101 + } 102 + } while (--i != 0); 103 + } 104 + 105 + /* round up LSB */ 106 + { 107 + unsigned long long summand = (remainder << 1) >= arg2_value; 108 + 109 + ASSERT(res_value <= LLONG_MAX - summand); 110 + 111 + res_value += summand; 112 + } 113 + 114 + res.value = (long long)res_value; 115 + 116 + if (arg1_negative ^ arg2_negative) 117 + res.value = -res.value; 118 + 119 + return res; 120 + } 121 + 122 + struct spl_fixed31_32 spl_fixpt_mul(struct spl_fixed31_32 arg1, struct spl_fixed31_32 arg2) 123 + { 124 + struct spl_fixed31_32 res; 125 + 126 + bool arg1_negative = arg1.value < 0; 127 + bool arg2_negative = arg2.value < 0; 128 + 129 + unsigned long long arg1_value = arg1_negative ? -arg1.value : arg1.value; 130 + unsigned long long arg2_value = arg2_negative ? -arg2.value : arg2.value; 131 + 132 + unsigned long long arg1_int = GET_INTEGER_PART(arg1_value); 133 + unsigned long long arg2_int = GET_INTEGER_PART(arg2_value); 134 + 135 + unsigned long long arg1_fra = GET_FRACTIONAL_PART(arg1_value); 136 + unsigned long long arg2_fra = GET_FRACTIONAL_PART(arg2_value); 137 + 138 + unsigned long long tmp; 139 + 140 + res.value = arg1_int * arg2_int; 141 + 142 + ASSERT(res.value <= (long long)LONG_MAX); 143 + 144 + res.value <<= FIXED31_32_BITS_PER_FRACTIONAL_PART; 145 + 146 + tmp = arg1_int * arg2_fra; 147 + 148 + ASSERT(tmp <= (unsigned long long)(LLONG_MAX - res.value)); 149 + 150 + res.value += tmp; 151 + 152 + tmp = arg2_int * arg1_fra; 153 + 154 + ASSERT(tmp <= (unsigned long long)(LLONG_MAX - res.value)); 155 + 156 + res.value += tmp; 157 + 158 + tmp = arg1_fra * arg2_fra; 159 + 160 + tmp = (tmp >> FIXED31_32_BITS_PER_FRACTIONAL_PART) + 161 + (tmp >= (unsigned long long)spl_fixpt_half.value); 162 + 163 + ASSERT(tmp <= (unsigned long long)(LLONG_MAX - res.value)); 164 + 165 + res.value += tmp; 166 + 167 + if (arg1_negative ^ arg2_negative) 168 + res.value = -res.value; 169 + 170 + return res; 171 + } 172 + 173 + struct spl_fixed31_32 spl_fixpt_sqr(struct spl_fixed31_32 arg) 174 + { 175 + struct spl_fixed31_32 res; 176 + 177 + unsigned long long arg_value = abs_i64(arg.value); 178 + 179 + unsigned long long arg_int = GET_INTEGER_PART(arg_value); 180 + 181 + unsigned long long arg_fra = GET_FRACTIONAL_PART(arg_value); 182 + 183 + unsigned long long tmp; 184 + 185 + res.value = arg_int * arg_int; 186 + 187 + ASSERT(res.value <= (long long)LONG_MAX); 188 + 189 + res.value <<= FIXED31_32_BITS_PER_FRACTIONAL_PART; 190 + 191 + tmp = arg_int * arg_fra; 192 + 193 + ASSERT(tmp <= (unsigned long long)(LLONG_MAX - res.value)); 194 + 195 + res.value += tmp; 196 + 197 + ASSERT(tmp <= (unsigned long long)(LLONG_MAX - res.value)); 198 + 199 + res.value += tmp; 200 + 201 + tmp = arg_fra * arg_fra; 202 + 203 + tmp = (tmp >> FIXED31_32_BITS_PER_FRACTIONAL_PART) + 204 + (tmp >= (unsigned long long)spl_fixpt_half.value); 205 + 206 + ASSERT(tmp <= (unsigned long long)(LLONG_MAX - res.value)); 207 + 208 + res.value += tmp; 209 + 210 + return res; 211 + } 212 + 213 + struct spl_fixed31_32 spl_fixpt_recip(struct spl_fixed31_32 arg) 214 + { 215 + /* 216 + * @note 217 + * Good idea to use Newton's method 218 + */ 219 + 220 + ASSERT(arg.value); 221 + 222 + return spl_fixpt_from_fraction( 223 + spl_fixpt_one.value, 224 + arg.value); 225 + } 226 + 227 + struct spl_fixed31_32 spl_fixpt_sinc(struct spl_fixed31_32 arg) 228 + { 229 + struct spl_fixed31_32 square; 230 + 231 + struct spl_fixed31_32 res = spl_fixpt_one; 232 + 233 + int n = 27; 234 + 235 + struct spl_fixed31_32 arg_norm = arg; 236 + 237 + if (spl_fixpt_le( 238 + spl_fixpt_two_pi, 239 + spl_fixpt_abs(arg))) { 240 + arg_norm = spl_fixpt_sub( 241 + arg_norm, 242 + spl_fixpt_mul_int( 243 + spl_fixpt_two_pi, 244 + (int)spl_div64_s64( 245 + arg_norm.value, 246 + spl_fixpt_two_pi.value))); 247 + } 248 + 249 + square = spl_fixpt_sqr(arg_norm); 250 + 251 + do { 252 + res = spl_fixpt_sub( 253 + spl_fixpt_one, 254 + spl_fixpt_div_int( 255 + spl_fixpt_mul( 256 + square, 257 + res), 258 + n * (n - 1))); 259 + 260 + n -= 2; 261 + } while (n > 2); 262 + 263 + if (arg.value != arg_norm.value) 264 + res = spl_fixpt_div( 265 + spl_fixpt_mul(res, arg_norm), 266 + arg); 267 + 268 + return res; 269 + } 270 + 271 + struct spl_fixed31_32 spl_fixpt_sin(struct spl_fixed31_32 arg) 272 + { 273 + return spl_fixpt_mul( 274 + arg, 275 + spl_fixpt_sinc(arg)); 276 + } 277 + 278 + struct spl_fixed31_32 spl_fixpt_cos(struct spl_fixed31_32 arg) 279 + { 280 + /* TODO implement argument normalization */ 281 + 282 + const struct spl_fixed31_32 square = spl_fixpt_sqr(arg); 283 + 284 + struct spl_fixed31_32 res = spl_fixpt_one; 285 + 286 + int n = 26; 287 + 288 + do { 289 + res = spl_fixpt_sub( 290 + spl_fixpt_one, 291 + spl_fixpt_div_int( 292 + spl_fixpt_mul( 293 + square, 294 + res), 295 + n * (n - 1))); 296 + 297 + n -= 2; 298 + } while (n != 0); 299 + 300 + return res; 301 + } 302 + 303 + /* 304 + * @brief 305 + * result = exp(arg), 306 + * where abs(arg) < 1 307 + * 308 + * Calculated as Taylor series. 309 + */ 310 + static struct spl_fixed31_32 fixed31_32_exp_from_taylor_series(struct spl_fixed31_32 arg) 311 + { 312 + unsigned int n = 9; 313 + 314 + struct spl_fixed31_32 res = spl_fixpt_from_fraction( 315 + n + 2, 316 + n + 1); 317 + /* TODO find correct res */ 318 + 319 + ASSERT(spl_fixpt_lt(arg, spl_fixpt_one)); 320 + 321 + do 322 + res = spl_fixpt_add( 323 + spl_fixpt_one, 324 + spl_fixpt_div_int( 325 + spl_fixpt_mul( 326 + arg, 327 + res), 328 + n)); 329 + while (--n != 1); 330 + 331 + return spl_fixpt_add( 332 + spl_fixpt_one, 333 + spl_fixpt_mul( 334 + arg, 335 + res)); 336 + } 337 + 338 + struct spl_fixed31_32 spl_fixpt_exp(struct spl_fixed31_32 arg) 339 + { 340 + /* 341 + * @brief 342 + * Main equation is: 343 + * exp(x) = exp(r + m * ln(2)) = (1 << m) * exp(r), 344 + * where m = round(x / ln(2)), r = x - m * ln(2) 345 + */ 346 + 347 + if (spl_fixpt_le( 348 + spl_fixpt_ln2_div_2, 349 + spl_fixpt_abs(arg))) { 350 + int m = spl_fixpt_round( 351 + spl_fixpt_div( 352 + arg, 353 + spl_fixpt_ln2)); 354 + 355 + struct spl_fixed31_32 r = spl_fixpt_sub( 356 + arg, 357 + spl_fixpt_mul_int( 358 + spl_fixpt_ln2, 359 + m)); 360 + 361 + ASSERT(m != 0); 362 + 363 + ASSERT(spl_fixpt_lt( 364 + spl_fixpt_abs(r), 365 + spl_fixpt_one)); 366 + 367 + if (m > 0) 368 + return spl_fixpt_shl( 369 + fixed31_32_exp_from_taylor_series(r), 370 + (unsigned char)m); 371 + else 372 + return spl_fixpt_div_int( 373 + fixed31_32_exp_from_taylor_series(r), 374 + 1LL << -m); 375 + } else if (arg.value != 0) 376 + return fixed31_32_exp_from_taylor_series(arg); 377 + else 378 + return spl_fixpt_one; 379 + } 380 + 381 + struct spl_fixed31_32 spl_fixpt_log(struct spl_fixed31_32 arg) 382 + { 383 + struct spl_fixed31_32 res = spl_fixpt_neg(spl_fixpt_one); 384 + /* TODO improve 1st estimation */ 385 + 386 + struct spl_fixed31_32 error; 387 + 388 + ASSERT(arg.value > 0); 389 + /* TODO if arg is negative, return NaN */ 390 + /* TODO if arg is zero, return -INF */ 391 + 392 + do { 393 + struct spl_fixed31_32 res1 = spl_fixpt_add( 394 + spl_fixpt_sub( 395 + res, 396 + spl_fixpt_one), 397 + spl_fixpt_div( 398 + arg, 399 + spl_fixpt_exp(res))); 400 + 401 + error = spl_fixpt_sub( 402 + res, 403 + res1); 404 + 405 + res = res1; 406 + /* TODO determine max_allowed_error based on quality of exp() */ 407 + } while (abs_i64(error.value) > 100ULL); 408 + 409 + return res; 410 + } 411 + 412 + 413 + /* this function is a generic helper to translate fixed point value to 414 + * specified integer format that will consist of integer_bits integer part and 415 + * fractional_bits fractional part. For example it is used in 416 + * spl_fixpt_u2d19 to receive 2 bits integer part and 19 bits fractional 417 + * part in 32 bits. It is used in hw programming (scaler) 418 + */ 419 + 420 + static inline unsigned int ux_dy( 421 + long long value, 422 + unsigned int integer_bits, 423 + unsigned int fractional_bits) 424 + { 425 + /* 1. create mask of integer part */ 426 + unsigned int result = (1 << integer_bits) - 1; 427 + /* 2. mask out fractional part */ 428 + unsigned int fractional_part = FRACTIONAL_PART_MASK & value; 429 + /* 3. shrink fixed point integer part to be of integer_bits width*/ 430 + result &= GET_INTEGER_PART(value); 431 + /* 4. make space for fractional part to be filled in after integer */ 432 + result <<= fractional_bits; 433 + /* 5. shrink fixed point fractional part to of fractional_bits width*/ 434 + fractional_part >>= FIXED31_32_BITS_PER_FRACTIONAL_PART - fractional_bits; 435 + /* 6. merge the result */ 436 + return result | fractional_part; 437 + } 438 + 439 + static inline unsigned int clamp_ux_dy( 440 + long long value, 441 + unsigned int integer_bits, 442 + unsigned int fractional_bits, 443 + unsigned int min_clamp) 444 + { 445 + unsigned int truncated_val = ux_dy(value, integer_bits, fractional_bits); 446 + 447 + if (value >= (1LL << (integer_bits + FIXED31_32_BITS_PER_FRACTIONAL_PART))) 448 + return (1 << (integer_bits + fractional_bits)) - 1; 449 + else if (truncated_val > min_clamp) 450 + return truncated_val; 451 + else 452 + return min_clamp; 453 + } 454 + 455 + unsigned int spl_fixpt_u4d19(struct spl_fixed31_32 arg) 456 + { 457 + return ux_dy(arg.value, 4, 19); 458 + } 459 + 460 + unsigned int spl_fixpt_u3d19(struct spl_fixed31_32 arg) 461 + { 462 + return ux_dy(arg.value, 3, 19); 463 + } 464 + 465 + unsigned int spl_fixpt_u2d19(struct spl_fixed31_32 arg) 466 + { 467 + return ux_dy(arg.value, 2, 19); 468 + } 469 + 470 + unsigned int spl_fixpt_u0d19(struct spl_fixed31_32 arg) 471 + { 472 + return ux_dy(arg.value, 0, 19); 473 + } 474 + 475 + unsigned int spl_fixpt_clamp_u0d14(struct spl_fixed31_32 arg) 476 + { 477 + return clamp_ux_dy(arg.value, 0, 14, 1); 478 + } 479 + 480 + unsigned int spl_fixpt_clamp_u0d10(struct spl_fixed31_32 arg) 481 + { 482 + return clamp_ux_dy(arg.value, 0, 10, 1); 483 + } 484 + 485 + int spl_fixpt_s4d19(struct spl_fixed31_32 arg) 486 + { 487 + if (arg.value < 0) 488 + return -(int)ux_dy(spl_fixpt_abs(arg).value, 4, 19); 489 + else 490 + return ux_dy(arg.value, 4, 19); 491 + } 492 + 493 + struct spl_fixed31_32 spl_fixpt_from_ux_dy(unsigned int value, 494 + unsigned int integer_bits, 495 + unsigned int fractional_bits) 496 + { 497 + struct spl_fixed31_32 fixpt_value = spl_fixpt_zero; 498 + struct spl_fixed31_32 fixpt_int_value = spl_fixpt_zero; 499 + long long frac_mask = ((long long)1 << (long long)integer_bits) - 1; 500 + 501 + fixpt_value.value = (long long)value << (FIXED31_32_BITS_PER_FRACTIONAL_PART - fractional_bits); 502 + frac_mask = frac_mask << fractional_bits; 503 + fixpt_int_value.value = value & frac_mask; 504 + fixpt_int_value.value <<= (FIXED31_32_BITS_PER_FRACTIONAL_PART - fractional_bits); 505 + fixpt_value.value |= fixpt_int_value.value; 506 + return fixpt_value; 507 + } 508 + 509 + struct spl_fixed31_32 spl_fixpt_from_int_dy(unsigned int int_value, 510 + unsigned int frac_value, 511 + unsigned int integer_bits, 512 + unsigned int fractional_bits) 513 + { 514 + struct spl_fixed31_32 fixpt_value = spl_fixpt_from_int(int_value); 515 + 516 + fixpt_value.value |= (long long)frac_value << (FIXED31_32_BITS_PER_FRACTIONAL_PART - fractional_bits); 517 + return fixpt_value; 518 + }
+546
drivers/gpu/drm/amd/display/dc/spl/spl_fixpt31_32.h
··· 1 + /* 2 + * Copyright 2012-15 Advanced Micro Devices, Inc. 3 + * 4 + * Permission is hereby granted, free of charge, to any person obtaining a 5 + * copy of this software and associated documentation files (the "Software"), 6 + * to deal in the Software without restriction, including without limitation 7 + * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 + * and/or sell copies of the Software, and to permit persons to whom the 9 + * Software is furnished to do so, subject to the following conditions: 10 + * 11 + * The above copyright notice and this permission notice shall be included in 12 + * all copies or substantial portions of the Software. 13 + * 14 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 + * OTHER DEALINGS IN THE SOFTWARE. 21 + * 22 + * Authors: AMD 23 + * 24 + */ 25 + 26 + #ifndef __SPL_FIXED31_32_H__ 27 + #define __SPL_FIXED31_32_H__ 28 + 29 + #include "os_types.h" 30 + #include "spl_os_types.h" // swap 31 + #ifndef ASSERT 32 + #define ASSERT(_bool) ((void *)0) 33 + #endif 34 + 35 + #ifndef LLONG_MAX 36 + #define LLONG_MAX 9223372036854775807ll 37 + #endif 38 + #ifndef LLONG_MIN 39 + #define LLONG_MIN (-LLONG_MAX - 1ll) 40 + #endif 41 + 42 + #define FIXED31_32_BITS_PER_FRACTIONAL_PART 32 43 + #ifndef LLONG_MIN 44 + #define LLONG_MIN (1LL<<63) 45 + #endif 46 + #ifndef LLONG_MAX 47 + #define LLONG_MAX (-1LL>>1) 48 + #endif 49 + 50 + /* 51 + * @brief 52 + * Arithmetic operations on real numbers 53 + * represented as fixed-point numbers. 54 + * There are: 1 bit for sign, 55 + * 31 bit for integer part, 56 + * 32 bits for fractional part. 57 + * 58 + * @note 59 + * Currently, overflows and underflows are asserted; 60 + * no special result returned. 61 + */ 62 + 63 + struct spl_fixed31_32 { 64 + long long value; 65 + }; 66 + 67 + 68 + /* 69 + * @brief 70 + * Useful constants 71 + */ 72 + 73 + static const struct spl_fixed31_32 spl_fixpt_zero = { 0 }; 74 + static const struct spl_fixed31_32 spl_fixpt_epsilon = { 1LL }; 75 + static const struct spl_fixed31_32 spl_fixpt_half = { 0x80000000LL }; 76 + static const struct spl_fixed31_32 spl_fixpt_one = { 0x100000000LL }; 77 + 78 + /* 79 + * @brief 80 + * Initialization routines 81 + */ 82 + 83 + /* 84 + * @brief 85 + * result = numerator / denominator 86 + */ 87 + struct spl_fixed31_32 spl_fixpt_from_fraction(long long numerator, long long denominator); 88 + 89 + /* 90 + * @brief 91 + * result = arg 92 + */ 93 + static inline struct spl_fixed31_32 spl_fixpt_from_int(int arg) 94 + { 95 + struct spl_fixed31_32 res; 96 + 97 + res.value = (long long) arg << FIXED31_32_BITS_PER_FRACTIONAL_PART; 98 + 99 + return res; 100 + } 101 + 102 + /* 103 + * @brief 104 + * Unary operators 105 + */ 106 + 107 + /* 108 + * @brief 109 + * result = -arg 110 + */ 111 + static inline struct spl_fixed31_32 spl_fixpt_neg(struct spl_fixed31_32 arg) 112 + { 113 + struct spl_fixed31_32 res; 114 + 115 + res.value = -arg.value; 116 + 117 + return res; 118 + } 119 + 120 + /* 121 + * @brief 122 + * result = abs(arg) := (arg >= 0) ? arg : -arg 123 + */ 124 + static inline struct spl_fixed31_32 spl_fixpt_abs(struct spl_fixed31_32 arg) 125 + { 126 + if (arg.value < 0) 127 + return spl_fixpt_neg(arg); 128 + else 129 + return arg; 130 + } 131 + 132 + /* 133 + * @brief 134 + * Binary relational operators 135 + */ 136 + 137 + /* 138 + * @brief 139 + * result = arg1 < arg2 140 + */ 141 + static inline bool spl_fixpt_lt(struct spl_fixed31_32 arg1, struct spl_fixed31_32 arg2) 142 + { 143 + return arg1.value < arg2.value; 144 + } 145 + 146 + /* 147 + * @brief 148 + * result = arg1 <= arg2 149 + */ 150 + static inline bool spl_fixpt_le(struct spl_fixed31_32 arg1, struct spl_fixed31_32 arg2) 151 + { 152 + return arg1.value <= arg2.value; 153 + } 154 + 155 + /* 156 + * @brief 157 + * result = arg1 == arg2 158 + */ 159 + static inline bool spl_fixpt_eq(struct spl_fixed31_32 arg1, struct spl_fixed31_32 arg2) 160 + { 161 + return arg1.value == arg2.value; 162 + } 163 + 164 + /* 165 + * @brief 166 + * result = min(arg1, arg2) := (arg1 <= arg2) ? arg1 : arg2 167 + */ 168 + static inline struct spl_fixed31_32 spl_fixpt_min(struct spl_fixed31_32 arg1, struct spl_fixed31_32 arg2) 169 + { 170 + if (arg1.value <= arg2.value) 171 + return arg1; 172 + else 173 + return arg2; 174 + } 175 + 176 + /* 177 + * @brief 178 + * result = max(arg1, arg2) := (arg1 <= arg2) ? arg2 : arg1 179 + */ 180 + static inline struct spl_fixed31_32 spl_fixpt_max(struct spl_fixed31_32 arg1, struct spl_fixed31_32 arg2) 181 + { 182 + if (arg1.value <= arg2.value) 183 + return arg2; 184 + else 185 + return arg1; 186 + } 187 + 188 + /* 189 + * @brief 190 + * | min_value, when arg <= min_value 191 + * result = | arg, when min_value < arg < max_value 192 + * | max_value, when arg >= max_value 193 + */ 194 + static inline struct spl_fixed31_32 spl_fixpt_clamp( 195 + struct spl_fixed31_32 arg, 196 + struct spl_fixed31_32 min_value, 197 + struct spl_fixed31_32 max_value) 198 + { 199 + if (spl_fixpt_le(arg, min_value)) 200 + return min_value; 201 + else if (spl_fixpt_le(max_value, arg)) 202 + return max_value; 203 + else 204 + return arg; 205 + } 206 + 207 + /* 208 + * @brief 209 + * Binary shift operators 210 + */ 211 + 212 + /* 213 + * @brief 214 + * result = arg << shift 215 + */ 216 + static inline struct spl_fixed31_32 spl_fixpt_shl(struct spl_fixed31_32 arg, unsigned char shift) 217 + { 218 + ASSERT(((arg.value >= 0) && (arg.value <= LLONG_MAX >> shift)) || 219 + ((arg.value < 0) && (arg.value >= ~(LLONG_MAX >> shift)))); 220 + 221 + arg.value = arg.value << shift; 222 + 223 + return arg; 224 + } 225 + 226 + /* 227 + * @brief 228 + * result = arg >> shift 229 + */ 230 + static inline struct spl_fixed31_32 spl_fixpt_shr(struct spl_fixed31_32 arg, unsigned char shift) 231 + { 232 + bool negative = arg.value < 0; 233 + 234 + if (negative) 235 + arg.value = -arg.value; 236 + arg.value = arg.value >> shift; 237 + if (negative) 238 + arg.value = -arg.value; 239 + return arg; 240 + } 241 + 242 + /* 243 + * @brief 244 + * Binary additive operators 245 + */ 246 + 247 + /* 248 + * @brief 249 + * result = arg1 + arg2 250 + */ 251 + static inline struct spl_fixed31_32 spl_fixpt_add(struct spl_fixed31_32 arg1, struct spl_fixed31_32 arg2) 252 + { 253 + struct spl_fixed31_32 res; 254 + 255 + ASSERT(((arg1.value >= 0) && (LLONG_MAX - arg1.value >= arg2.value)) || 256 + ((arg1.value < 0) && (LLONG_MIN - arg1.value <= arg2.value))); 257 + 258 + res.value = arg1.value + arg2.value; 259 + 260 + return res; 261 + } 262 + 263 + /* 264 + * @brief 265 + * result = arg1 + arg2 266 + */ 267 + static inline struct spl_fixed31_32 spl_fixpt_add_int(struct spl_fixed31_32 arg1, int arg2) 268 + { 269 + return spl_fixpt_add(arg1, spl_fixpt_from_int(arg2)); 270 + } 271 + 272 + /* 273 + * @brief 274 + * result = arg1 - arg2 275 + */ 276 + static inline struct spl_fixed31_32 spl_fixpt_sub(struct spl_fixed31_32 arg1, struct spl_fixed31_32 arg2) 277 + { 278 + struct spl_fixed31_32 res; 279 + 280 + ASSERT(((arg2.value >= 0) && (LLONG_MIN + arg2.value <= arg1.value)) || 281 + ((arg2.value < 0) && (LLONG_MAX + arg2.value >= arg1.value))); 282 + 283 + res.value = arg1.value - arg2.value; 284 + 285 + return res; 286 + } 287 + 288 + /* 289 + * @brief 290 + * result = arg1 - arg2 291 + */ 292 + static inline struct spl_fixed31_32 spl_fixpt_sub_int(struct spl_fixed31_32 arg1, int arg2) 293 + { 294 + return spl_fixpt_sub(arg1, spl_fixpt_from_int(arg2)); 295 + } 296 + 297 + 298 + /* 299 + * @brief 300 + * Binary multiplicative operators 301 + */ 302 + 303 + /* 304 + * @brief 305 + * result = arg1 * arg2 306 + */ 307 + struct spl_fixed31_32 spl_fixpt_mul(struct spl_fixed31_32 arg1, struct spl_fixed31_32 arg2); 308 + 309 + 310 + /* 311 + * @brief 312 + * result = arg1 * arg2 313 + */ 314 + static inline struct spl_fixed31_32 spl_fixpt_mul_int(struct spl_fixed31_32 arg1, int arg2) 315 + { 316 + return spl_fixpt_mul(arg1, spl_fixpt_from_int(arg2)); 317 + } 318 + 319 + /* 320 + * @brief 321 + * result = square(arg) := arg * arg 322 + */ 323 + struct spl_fixed31_32 spl_fixpt_sqr(struct spl_fixed31_32 arg); 324 + 325 + /* 326 + * @brief 327 + * result = arg1 / arg2 328 + */ 329 + static inline struct spl_fixed31_32 spl_fixpt_div_int(struct spl_fixed31_32 arg1, long long arg2) 330 + { 331 + return spl_fixpt_from_fraction(arg1.value, spl_fixpt_from_int((int)arg2).value); 332 + } 333 + 334 + /* 335 + * @brief 336 + * result = arg1 / arg2 337 + */ 338 + static inline struct spl_fixed31_32 spl_fixpt_div(struct spl_fixed31_32 arg1, struct spl_fixed31_32 arg2) 339 + { 340 + return spl_fixpt_from_fraction(arg1.value, arg2.value); 341 + } 342 + 343 + /* 344 + * @brief 345 + * Reciprocal function 346 + */ 347 + 348 + /* 349 + * @brief 350 + * result = reciprocal(arg) := 1 / arg 351 + * 352 + * @note 353 + * No special actions taken in case argument is zero. 354 + */ 355 + struct spl_fixed31_32 spl_fixpt_recip(struct spl_fixed31_32 arg); 356 + 357 + /* 358 + * @brief 359 + * Trigonometric functions 360 + */ 361 + 362 + /* 363 + * @brief 364 + * result = sinc(arg) := sin(arg) / arg 365 + * 366 + * @note 367 + * Argument specified in radians, 368 + * internally it's normalized to [-2pi...2pi] range. 369 + */ 370 + struct spl_fixed31_32 spl_fixpt_sinc(struct spl_fixed31_32 arg); 371 + 372 + /* 373 + * @brief 374 + * result = sin(arg) 375 + * 376 + * @note 377 + * Argument specified in radians, 378 + * internally it's normalized to [-2pi...2pi] range. 379 + */ 380 + struct spl_fixed31_32 spl_fixpt_sin(struct spl_fixed31_32 arg); 381 + 382 + /* 383 + * @brief 384 + * result = cos(arg) 385 + * 386 + * @note 387 + * Argument specified in radians 388 + * and should be in [-2pi...2pi] range - 389 + * passing arguments outside that range 390 + * will cause incorrect result! 391 + */ 392 + struct spl_fixed31_32 spl_fixpt_cos(struct spl_fixed31_32 arg); 393 + 394 + /* 395 + * @brief 396 + * Transcendent functions 397 + */ 398 + 399 + /* 400 + * @brief 401 + * result = exp(arg) 402 + * 403 + * @note 404 + * Currently, function is verified for abs(arg) <= 1. 405 + */ 406 + struct spl_fixed31_32 spl_fixpt_exp(struct spl_fixed31_32 arg); 407 + 408 + /* 409 + * @brief 410 + * result = log(arg) 411 + * 412 + * @note 413 + * Currently, abs(arg) should be less than 1. 414 + * No normalization is done. 415 + * Currently, no special actions taken 416 + * in case of invalid argument(s). Take care! 417 + */ 418 + struct spl_fixed31_32 spl_fixpt_log(struct spl_fixed31_32 arg); 419 + 420 + /* 421 + * @brief 422 + * Power function 423 + */ 424 + 425 + /* 426 + * @brief 427 + * result = pow(arg1, arg2) 428 + * 429 + * @note 430 + * Currently, abs(arg1) should be less than 1. Take care! 431 + */ 432 + static inline struct spl_fixed31_32 spl_fixpt_pow(struct spl_fixed31_32 arg1, struct spl_fixed31_32 arg2) 433 + { 434 + if (arg1.value == 0) 435 + return arg2.value == 0 ? spl_fixpt_one : spl_fixpt_zero; 436 + 437 + return spl_fixpt_exp( 438 + spl_fixpt_mul( 439 + spl_fixpt_log(arg1), 440 + arg2)); 441 + } 442 + 443 + /* 444 + * @brief 445 + * Rounding functions 446 + */ 447 + 448 + /* 449 + * @brief 450 + * result = floor(arg) := greatest integer lower than or equal to arg 451 + */ 452 + static inline int spl_fixpt_floor(struct spl_fixed31_32 arg) 453 + { 454 + unsigned long long arg_value = arg.value > 0 ? arg.value : -arg.value; 455 + 456 + if (arg.value >= 0) 457 + return (int)(arg_value >> FIXED31_32_BITS_PER_FRACTIONAL_PART); 458 + else 459 + return -(int)(arg_value >> FIXED31_32_BITS_PER_FRACTIONAL_PART); 460 + } 461 + 462 + /* 463 + * @brief 464 + * result = round(arg) := integer nearest to arg 465 + */ 466 + static inline int spl_fixpt_round(struct spl_fixed31_32 arg) 467 + { 468 + unsigned long long arg_value = arg.value > 0 ? arg.value : -arg.value; 469 + 470 + const long long summand = spl_fixpt_half.value; 471 + 472 + ASSERT(LLONG_MAX - (long long)arg_value >= summand); 473 + 474 + arg_value += summand; 475 + 476 + if (arg.value >= 0) 477 + return (int)(arg_value >> FIXED31_32_BITS_PER_FRACTIONAL_PART); 478 + else 479 + return -(int)(arg_value >> FIXED31_32_BITS_PER_FRACTIONAL_PART); 480 + } 481 + 482 + /* 483 + * @brief 484 + * result = ceil(arg) := lowest integer greater than or equal to arg 485 + */ 486 + static inline int spl_fixpt_ceil(struct spl_fixed31_32 arg) 487 + { 488 + unsigned long long arg_value = arg.value > 0 ? arg.value : -arg.value; 489 + 490 + const long long summand = spl_fixpt_one.value - 491 + spl_fixpt_epsilon.value; 492 + 493 + ASSERT(LLONG_MAX - (long long)arg_value >= summand); 494 + 495 + arg_value += summand; 496 + 497 + if (arg.value >= 0) 498 + return (int)(arg_value >> FIXED31_32_BITS_PER_FRACTIONAL_PART); 499 + else 500 + return -(int)(arg_value >> FIXED31_32_BITS_PER_FRACTIONAL_PART); 501 + } 502 + 503 + /* the following two function are used in scaler hw programming to convert fixed 504 + * point value to format 2 bits from integer part and 19 bits from fractional 505 + * part. The same applies for u0d19, 0 bits from integer part and 19 bits from 506 + * fractional 507 + */ 508 + 509 + unsigned int spl_fixpt_u4d19(struct spl_fixed31_32 arg); 510 + 511 + unsigned int spl_fixpt_u3d19(struct spl_fixed31_32 arg); 512 + 513 + unsigned int spl_fixpt_u2d19(struct spl_fixed31_32 arg); 514 + 515 + unsigned int spl_fixpt_u0d19(struct spl_fixed31_32 arg); 516 + 517 + unsigned int spl_fixpt_clamp_u0d14(struct spl_fixed31_32 arg); 518 + 519 + unsigned int spl_fixpt_clamp_u0d10(struct spl_fixed31_32 arg); 520 + 521 + int spl_fixpt_s4d19(struct spl_fixed31_32 arg); 522 + 523 + static inline struct spl_fixed31_32 spl_fixpt_truncate(struct spl_fixed31_32 arg, unsigned int frac_bits) 524 + { 525 + bool negative = arg.value < 0; 526 + 527 + if (frac_bits >= FIXED31_32_BITS_PER_FRACTIONAL_PART) { 528 + ASSERT(frac_bits == FIXED31_32_BITS_PER_FRACTIONAL_PART); 529 + return arg; 530 + } 531 + 532 + if (negative) 533 + arg.value = -arg.value; 534 + arg.value &= (~0ULL) << (FIXED31_32_BITS_PER_FRACTIONAL_PART - frac_bits); 535 + if (negative) 536 + arg.value = -arg.value; 537 + return arg; 538 + } 539 + 540 + struct spl_fixed31_32 spl_fixpt_from_ux_dy(unsigned int value, unsigned int integer_bits, unsigned int fractional_bits); 541 + struct spl_fixed31_32 spl_fixpt_from_int_dy(unsigned int int_value, 542 + unsigned int frac_value, 543 + unsigned int integer_bits, 544 + unsigned int fractional_bits); 545 + 546 + #endif
+77
drivers/gpu/drm/amd/display/dc/spl/spl_os_types.h
··· 1 + /* 2 + * Copyright 2012-16 Advanced Micro Devices, Inc. 3 + * Copyright 2019 Raptor Engineering, LLC 4 + * 5 + * Permission is hereby granted, free of charge, to any person obtaining a 6 + * copy of this software and associated documentation files (the "Software"), 7 + * to deal in the Software without restriction, including without limitation 8 + * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 + * and/or sell copies of the Software, and to permit persons to whom the 10 + * Software is furnished to do so, subject to the following conditions: 11 + * 12 + * The above copyright notice and this permission notice shall be included in 13 + * all copies or substantial portions of the Software. 14 + * 15 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 19 + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 20 + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 21 + * OTHER DEALINGS IN THE SOFTWARE. 22 + * 23 + * Authors: AMD 24 + * 25 + */ 26 + 27 + #ifndef _SPL_OS_TYPES_H_ 28 + #define _SPL_OS_TYPES_H_ 29 + 30 + #include <linux/slab.h> 31 + #include <linux/kgdb.h> 32 + #include <linux/kref.h> 33 + #include <linux/types.h> 34 + #include <linux/delay.h> 35 + #include <linux/mm.h> 36 + 37 + /* 38 + * 39 + * general debug capabilities 40 + * 41 + */ 42 + // TODO: need backport 43 + #define SPL_BREAK_TO_DEBUGGER() ASSERT(0) 44 + 45 + static inline uint64_t spl_div_u64_rem(uint64_t dividend, uint32_t divisor, uint32_t *remainder) 46 + { 47 + return div_u64_rem(dividend, divisor, remainder); 48 + } 49 + 50 + static inline uint64_t spl_div_u64(uint64_t dividend, uint32_t divisor) 51 + { 52 + return div_u64(dividend, divisor); 53 + } 54 + 55 + static inline uint64_t spl_div64_u64(uint64_t dividend, uint64_t divisor) 56 + { 57 + return div64_u64(dividend, divisor); 58 + } 59 + 60 + static inline uint64_t spl_div64_u64_rem(uint64_t dividend, uint64_t divisor, uint64_t *remainder) 61 + { 62 + return div64_u64_rem(dividend, divisor, remainder); 63 + } 64 + 65 + static inline int64_t spl_div64_s64(int64_t dividend, int64_t divisor) 66 + { 67 + return div64_s64(dividend, divisor); 68 + } 69 + 70 + #define spl_swap(a, b) \ 71 + do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0) 72 + 73 + #ifndef spl_min 74 + #define spl_min(a, b) (((a) < (b)) ? (a):(b)) 75 + #endif 76 + 77 + #endif /* _SPL_OS_TYPES_H_ */
+6
drivers/gpu/drm/amd/display/include/fixed31_32.h
··· 531 531 return arg; 532 532 } 533 533 534 + struct fixed31_32 dc_fixpt_from_ux_dy(unsigned int value, unsigned int integer_bits, unsigned int fractional_bits); 535 + struct fixed31_32 dc_fixpt_from_int_dy(unsigned int int_value, 536 + unsigned int frac_value, 537 + unsigned int integer_bits, 538 + unsigned int fractional_bits); 539 + 534 540 #endif