Skip to content

Commit 804c096

Browse files
melissawengregkh
authored andcommitted
drm/amd/display: don't ignore alpha property on pre-multiplied mode
commit e4f1541 upstream. "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 <[email protected]> Tested-by: Rodrigo Siqueira <[email protected]> Reviewed-by: Harry Wentland <[email protected]> Tested-by: Simon Ser <[email protected]> Signed-off-by: Alex Deucher <[email protected]> Cc: [email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent adee01b commit 804c096

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2460,14 +2460,18 @@ void dcn10_update_mpcc(struct dc *dc, struct pipe_ctx *pipe_ctx)
24602460
struct mpc *mpc = dc->res_pool->mpc;
24612461
struct mpc_tree *mpc_tree_params = &(pipe_ctx->stream_res.opp->mpc_tree_params);
24622462

2463-
if (per_pixel_alpha)
2464-
blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA;
2465-
else
2466-
blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA;
2467-
24682463
blnd_cfg.overlap_only = false;
24692464
blnd_cfg.global_gain = 0xff;
24702465

2466+
if (per_pixel_alpha && pipe_ctx->plane_state->global_alpha) {
2467+
blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA_COMBINED_GLOBAL_GAIN;
2468+
blnd_cfg.global_gain = pipe_ctx->plane_state->global_alpha_value;
2469+
} else if (per_pixel_alpha) {
2470+
blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA;
2471+
} else {
2472+
blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA;
2473+
}
2474+
24712475
if (pipe_ctx->plane_state->global_alpha)
24722476
blnd_cfg.global_alpha = pipe_ctx->plane_state->global_alpha_value;
24732477
else

drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2297,14 +2297,18 @@ void dcn20_update_mpcc(struct dc *dc, struct pipe_ctx *pipe_ctx)
22972297
struct mpc *mpc = dc->res_pool->mpc;
22982298
struct mpc_tree *mpc_tree_params = &(pipe_ctx->stream_res.opp->mpc_tree_params);
22992299

2300-
if (per_pixel_alpha)
2301-
blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA;
2302-
else
2303-
blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA;
2304-
23052300
blnd_cfg.overlap_only = false;
23062301
blnd_cfg.global_gain = 0xff;
23072302

2303+
if (per_pixel_alpha && pipe_ctx->plane_state->global_alpha) {
2304+
blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA_COMBINED_GLOBAL_GAIN;
2305+
blnd_cfg.global_gain = pipe_ctx->plane_state->global_alpha_value;
2306+
} else if (per_pixel_alpha) {
2307+
blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA;
2308+
} else {
2309+
blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA;
2310+
}
2311+
23082312
if (pipe_ctx->plane_state->global_alpha)
23092313
blnd_cfg.global_alpha = pipe_ctx->plane_state->global_alpha_value;
23102314
else

0 commit comments

Comments
 (0)