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

drm/amd/display: dce_transform: DCE6 Scaling Horizontal Filter Init (v2)

[Why]
DCE6 has specific SCL_HORZ_FILTER_INIT_{LUMA_RGB,CHROMA} registers
In DCE6 h_init_luma and h_init_chroma initialization is required
Some DCE6 specific SCL_{HORZ,VERT}_FILTER_CONTROL masks were not listed

[How]
Add the registers and masks in dce_transform.h
Add DCE6 specific struct sclh_ratios_inits in dce_transform.h
Add dce60_calculate_inits() function
Add dce60_program_scl_ratios_inits() function
Fix dce60_transform_set_scaler() function

v2: remove unused variable (Alex)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Mauro Rossi <issor.oruam@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Mauro Rossi and committed by
Alex Deucher
102b2f58 b70aaf55

+95 -5
+67 -5
drivers/gpu/drm/amd/display/dc/dce/dce_transform.c
··· 306 306 inits->v_init.fraction = dc_fixpt_u0d19(v_init) << 5; 307 307 } 308 308 309 + #if defined(CONFIG_DRM_AMD_DC_SI) 310 + static void dce60_calculate_inits( 311 + struct dce_transform *xfm_dce, 312 + const struct scaler_data *data, 313 + struct sclh_ratios_inits *inits) 314 + { 315 + struct fixed31_32 v_init; 316 + 317 + inits->h_int_scale_ratio = 318 + dc_fixpt_u2d19(data->ratios.horz) << 5; 319 + inits->v_int_scale_ratio = 320 + dc_fixpt_u2d19(data->ratios.vert) << 5; 321 + 322 + /* DCE6 h_init_luma setting inspired by DCE110 */ 323 + inits->h_init_luma.integer = 1; 324 + 325 + /* DCE6 h_init_chroma setting inspired by DCE110 */ 326 + inits->h_init_chroma.integer = 1; 327 + 328 + v_init = 329 + dc_fixpt_div_int( 330 + dc_fixpt_add( 331 + data->ratios.vert, 332 + dc_fixpt_from_int(data->taps.v_taps + 1)), 333 + 2); 334 + inits->v_init.integer = dc_fixpt_floor(v_init); 335 + inits->v_init.fraction = dc_fixpt_u0d19(v_init) << 5; 336 + } 337 + #endif 338 + 309 339 static void program_scl_ratios_inits( 310 340 struct dce_transform *xfm_dce, 311 341 struct scl_ratios_inits *inits) ··· 357 327 358 328 REG_WRITE(SCL_AUTOMATIC_MODE_CONTROL, 0); 359 329 } 330 + 331 + #if defined(CONFIG_DRM_AMD_DC_SI) 332 + static void dce60_program_scl_ratios_inits( 333 + struct dce_transform *xfm_dce, 334 + struct sclh_ratios_inits *inits) 335 + { 336 + 337 + REG_SET(SCL_HORZ_FILTER_SCALE_RATIO, 0, 338 + SCL_H_SCALE_RATIO, inits->h_int_scale_ratio); 339 + 340 + REG_SET(SCL_VERT_FILTER_SCALE_RATIO, 0, 341 + SCL_V_SCALE_RATIO, inits->v_int_scale_ratio); 342 + 343 + /* DCE6 has SCL_HORZ_FILTER_INIT_RGB_LUMA register */ 344 + REG_SET_2(SCL_HORZ_FILTER_INIT_RGB_LUMA, 0, 345 + SCL_H_INIT_INT_RGB_Y, inits->h_init_luma.integer, 346 + SCL_H_INIT_FRAC_RGB_Y, inits->h_init_luma.fraction); 347 + 348 + /* DCE6 has SCL_HORZ_FILTER_INIT_CHROMA register */ 349 + REG_SET_2(SCL_HORZ_FILTER_INIT_CHROMA, 0, 350 + SCL_H_INIT_INT_CBCR, inits->h_init_chroma.integer, 351 + SCL_H_INIT_FRAC_CBCR, inits->h_init_chroma.fraction); 352 + 353 + REG_SET_2(SCL_VERT_FILTER_INIT, 0, 354 + SCL_V_INIT_INT, inits->v_init.integer, 355 + SCL_V_INIT_FRAC, inits->v_init.fraction); 356 + 357 + REG_WRITE(SCL_AUTOMATIC_MODE_CONTROL, 0); 358 + } 359 + #endif 360 360 361 361 static const uint16_t *get_filter_coeffs_16p(int taps, struct fixed31_32 ratio) 362 362 { ··· 513 453 is_scaling_required = dce60_setup_scaling_configuration(xfm_dce, data); 514 454 515 455 if (is_scaling_required) { 516 - /* 3. Calculate and program ratio, filter initialization */ 517 - struct scl_ratios_inits inits = { 0 }; 456 + /* 3. Calculate and program ratio, DCE6 filter initialization */ 457 + struct sclh_ratios_inits inits = { 0 }; 518 458 519 - calculate_inits(xfm_dce, data, &inits); 459 + /* DCE6 has specific calculate_inits() function */ 460 + dce60_calculate_inits(xfm_dce, data, &inits); 520 461 521 - program_scl_ratios_inits(xfm_dce, &inits); 462 + /* DCE6 has specific program_scl_ratios_inits() function */ 463 + dce60_program_scl_ratios_inits(xfm_dce, &inits); 522 464 523 465 coeffs_v = get_filter_coeffs_16p(data->taps.v_taps, data->ratios.vert); 524 466 coeffs_h = get_filter_coeffs_16p(data->taps.h_taps, data->ratios.horz); ··· 565 503 /* 6. Program the viewport */ 566 504 program_viewport(xfm_dce, &data->viewport); 567 505 568 - /* DCE6 does not have bit to flip to new coefficient memory */ 506 + /* DCE6 has no SCL_COEF_UPDATE_COMPLETE bit to flip to new coefficient memory */ 569 507 570 508 /* DCE6 DATA_FORMAT register does not support ALPHA_EN */ 571 509 }
+28
drivers/gpu/drm/amd/display/dc/dce/dce_transform.h
··· 331 331 XFM_SF(VIEWPORT_SIZE, VIEWPORT_WIDTH, mask_sh), \ 332 332 XFM_SF(SCL_HORZ_FILTER_SCALE_RATIO, SCL_H_SCALE_RATIO, mask_sh), \ 333 333 XFM_SF(SCL_VERT_FILTER_SCALE_RATIO, SCL_V_SCALE_RATIO, mask_sh), \ 334 + XFM_SF(SCL_HORZ_FILTER_INIT_RGB_LUMA, SCL_H_INIT_INT_RGB_Y, mask_sh), \ 335 + XFM_SF(SCL_HORZ_FILTER_INIT_RGB_LUMA, SCL_H_INIT_FRAC_RGB_Y, mask_sh), \ 336 + XFM_SF(SCL_HORZ_FILTER_INIT_CHROMA, SCL_H_INIT_INT_CBCR, mask_sh), \ 337 + XFM_SF(SCL_HORZ_FILTER_INIT_CHROMA, SCL_H_INIT_FRAC_CBCR, mask_sh), \ 338 + XFM_SF(SCL_VERT_FILTER_INIT, SCL_V_INIT_INT, mask_sh), \ 339 + XFM_SF(SCL_VERT_FILTER_INIT, SCL_V_INIT_FRAC, mask_sh), \ 340 + XFM_SF(SCL_HORZ_FILTER_CONTROL, SCL_H_FILTER_PICK_NEAREST, mask_sh), \ 341 + XFM_SF(SCL_VERT_FILTER_CONTROL, SCL_V_FILTER_PICK_NEAREST, mask_sh), \ 334 342 XFM_SF(DC_LB_MEMORY_SPLIT, DC_LB_MEMORY_CONFIG, mask_sh), \ 335 343 XFM_SF(DC_LB_MEM_SIZE, DC_LB_MEM_SIZE, mask_sh) 336 344 #endif ··· 505 497 type SCL_V_SCALE_RATIO; \ 506 498 type SCL_H_INIT_INT; \ 507 499 type SCL_H_INIT_FRAC; \ 500 + type SCL_H_INIT_INT_RGB_Y; \ 501 + type SCL_H_INIT_FRAC_RGB_Y; \ 502 + type SCL_H_INIT_INT_CBCR; \ 503 + type SCL_H_INIT_FRAC_CBCR; \ 508 504 type SCL_V_INIT_INT; \ 509 505 type SCL_V_INIT_FRAC; \ 510 506 type DC_LB_MEMORY_CONFIG; \ ··· 517 505 type LB_MEMORY_SIZE; \ 518 506 type SCL_V_2TAP_HARDCODE_COEF_EN; \ 519 507 type SCL_H_2TAP_HARDCODE_COEF_EN; \ 508 + type SCL_V_FILTER_PICK_NEAREST; \ 509 + type SCL_H_FILTER_PICK_NEAREST; \ 520 510 type SCL_COEF_UPDATE_COMPLETE; \ 521 511 type ALPHA_EN 522 512 ··· 589 575 uint32_t SCL_HORZ_FILTER_SCALE_RATIO; 590 576 uint32_t SCL_VERT_FILTER_SCALE_RATIO; 591 577 uint32_t SCL_HORZ_FILTER_INIT; 578 + #if defined(CONFIG_DRM_AMD_DC_SI) 579 + uint32_t SCL_HORZ_FILTER_INIT_RGB_LUMA; 580 + uint32_t SCL_HORZ_FILTER_INIT_CHROMA; 581 + #endif 592 582 uint32_t SCL_VERT_FILTER_INIT; 593 583 uint32_t SCL_AUTOMATIC_MODE_CONTROL; 594 584 #if defined(CONFIG_DRM_AMD_DC_SI) ··· 615 597 struct init_int_and_frac h_init; 616 598 struct init_int_and_frac v_init; 617 599 }; 600 + 601 + #if defined(CONFIG_DRM_AMD_DC_SI) 602 + struct sclh_ratios_inits { 603 + uint32_t h_int_scale_ratio; 604 + uint32_t v_int_scale_ratio; 605 + struct init_int_and_frac h_init_luma; 606 + struct init_int_and_frac h_init_chroma; 607 + struct init_int_and_frac v_init; 608 + }; 609 + #endif 618 610 619 611 enum ram_filter_type { 620 612 FILTER_TYPE_RGB_Y_VERTICAL = 0, /* 0 - RGB/Y Vertical filter */