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

Configure Feed

Select the types of activity you want to include in your feed.

drm/amd/display: don't ignore alpha property on pre-multiplied mode

"Pre-multiplied" is the default pixel blend mode for KMS/DRM, as
documented in supported_modes of drm_plane_create_blend_mode_property():
https://cgit.freedesktop.org/drm/drm-misc/tree/drivers/gpu/drm/drm_blend.c

In this mode, both 'pixel alpha' and 'plane alpha' participate in the
calculation, as described by the pixel blend mode formula in KMS/DRM
documentation:

out.rgb = plane_alpha * fg.rgb +
(1 - (plane_alpha * fg.alpha)) * bg.rgb

Considering the blend config mechanisms we have in the driver so far,
the alpha mode that better fits this blend mode is the
_PER_PIXEL_ALPHA_COMBINED_GLOBAL_GAIN, where the value for global_gain
is the plane alpha (global_alpha).

With this change, alpha property stops to be ignored. It also addresses
Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/1734

v2:
* keep the 8-bit value for global_alpha_value (Nicholas)
* correct the logical ordering for combined global gain (Nicholas)
* apply to dcn10 too (Nicholas)

Signed-off-by: Melissa Wen <mwen@igalia.com>
Tested-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Tested-by: Simon Ser <contact@emersion.fr>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Melissa Wen and committed by
Alex Deucher
67229b27 5273e82c

+18 -10
+9 -5
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
··· 2526 2526 struct mpc *mpc = dc->res_pool->mpc; 2527 2527 struct mpc_tree *mpc_tree_params = &(pipe_ctx->stream_res.opp->mpc_tree_params); 2528 2528 2529 - if (per_pixel_alpha) 2530 - blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA; 2531 - else 2532 - blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA; 2533 - 2534 2529 blnd_cfg.overlap_only = false; 2535 2530 blnd_cfg.global_gain = 0xff; 2531 + 2532 + if (per_pixel_alpha && pipe_ctx->plane_state->global_alpha) { 2533 + blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA_COMBINED_GLOBAL_GAIN; 2534 + blnd_cfg.global_gain = pipe_ctx->plane_state->global_alpha_value; 2535 + } else if (per_pixel_alpha) { 2536 + blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA; 2537 + } else { 2538 + blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA; 2539 + } 2536 2540 2537 2541 if (pipe_ctx->plane_state->global_alpha) 2538 2542 blnd_cfg.global_alpha = pipe_ctx->plane_state->global_alpha_value;
+9 -5
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
··· 2344 2344 struct mpc *mpc = dc->res_pool->mpc; 2345 2345 struct mpc_tree *mpc_tree_params = &(pipe_ctx->stream_res.opp->mpc_tree_params); 2346 2346 2347 - if (per_pixel_alpha) 2348 - blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA; 2349 - else 2350 - blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA; 2351 - 2352 2347 blnd_cfg.overlap_only = false; 2353 2348 blnd_cfg.global_gain = 0xff; 2349 + 2350 + if (per_pixel_alpha && pipe_ctx->plane_state->global_alpha) { 2351 + blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA_COMBINED_GLOBAL_GAIN; 2352 + blnd_cfg.global_gain = pipe_ctx->plane_state->global_alpha_value; 2353 + } else if (per_pixel_alpha) { 2354 + blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA; 2355 + } else { 2356 + blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA; 2357 + } 2354 2358 2355 2359 if (pipe_ctx->plane_state->global_alpha) 2356 2360 blnd_cfg.global_alpha = pipe_ctx->plane_state->global_alpha_value;