Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp3043405pxb; Mon, 18 Apr 2022 14:17:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxS2KB4jvx4asMwB0o1R6+CAvKK7x/7eWCA3KTeuAf9SCHpLa87ChFXGmCUSS7RH5N1PsMd X-Received: by 2002:a17:90b:1c8e:b0:1bf:364c:dd7a with SMTP id oo14-20020a17090b1c8e00b001bf364cdd7amr14845388pjb.103.1650316670684; Mon, 18 Apr 2022 14:17:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650316670; cv=none; d=google.com; s=arc-20160816; b=B/a/okd2gzaK+G82AqN4H2BmkMF5jRm4B+bawsI8gLlowrGf1L5jpYhvtb0UWnhaYM CbiQO3UDS0XZDIWfB5qlcp6LvWIVF46iM/pXqLO0f+tfNY0xObFI2h+aqUFYBWNqaj95 5HplrSImuQKLrE7HrupF76xOOZcvpssZ5cusgeX2SXIDxRDEo0zv4iD0bddKfwMaxKLu hDO4tWNEHPRVPvS7fcqQG9ZR3tJUx+y835NvbVfcyGOR4e60/90/AwRWSaLz0yGhFp1Y P60WceeWV3wxJ7IwMDa6H6xWnE5hAFavNHBYWpyAZrbXlGI9bnNQtH64XFNUA+ddCKQq DsVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HYolVuHHhCHtKa+0oemET3ze7TALVwRpIGNxH+u1PVI=; b=j2kDhsMDQHI5plLMTMKcOe3Qs/vNZ2t/YI3ojs5AHgPQSk0RoNAHfpNDf2DaTEo3aM P1VWNxhO+xL3lPOX6SVdYUYNHFo/LWlyya52Bry3htx4vkLKt2wv5cAbD2/MNe00kCZE z9ht3547+Nm8vmhyGBbMJU1YKO8+bOeR9+tp5F4nrgrZb7039CqZlpm3fOASp8ajFp5l yVPgL2t7lM8b+Xo1VOjqSBadaN96AbnmGK6aYWzGeexNAGk3z1rb9jbWmcSUBO1yzC/m 0TggeBxKbu+4iTx/IBluk1kBgDaURRNq3HT12of1VTbSYQVB52YW0nQaoYSIQ1x/V4y5 fazQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=x3EmZde3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kx16-20020a17090b229000b001bfb0db0879si266862pjb.88.2022.04.18.14.17.31; Mon, 18 Apr 2022 14:17:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=x3EmZde3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235701AbiDRMle (ORCPT + 99 others); Mon, 18 Apr 2022 08:41:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239630AbiDRMdR (ORCPT ); Mon, 18 Apr 2022 08:33:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD7F75F76; Mon, 18 Apr 2022 05:24:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5BB6660B40; Mon, 18 Apr 2022 12:24:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3970AC385A1; Mon, 18 Apr 2022 12:24:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650284698; bh=QwI77yTeU38JG+pXWwgQj4xcJc1iPuDDqVCKq80Oph8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x3EmZde3jOTO926ZoVUTCQT/a8MuzfD5SSnIxc9i3nkJ4dGldD5E0OWT+BMlkqMH9 /O0EH2dzruPXEzc5jZPuOGmzG7FRSePJXUKaHj0Jf5GaxuNgmR5ETZFQHka8IiVjfM 74A/FfOzZRcAmb6qO7eoEkw0BBgwrGafx26ckjps= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Melissa Wen , Rodrigo Siqueira , Harry Wentland , Simon Ser , Alex Deucher Subject: [PATCH 5.17 199/219] drm/amd/display: dont ignore alpha property on pre-multiplied mode Date: Mon, 18 Apr 2022 14:12:48 +0200 Message-Id: <20220418121212.442319183@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121203.462784814@linuxfoundation.org> References: <20220418121203.462784814@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Melissa Wen commit e4f1541caf60fcbe5a59e9d25805c0b5865e546a 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 Tested-by: Rodrigo Siqueira Reviewed-by: Harry Wentland Tested-by: Simon Ser Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c | 14 +++++++++----- drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c | 14 +++++++++----- 2 files changed, 18 insertions(+), 10 deletions(-) --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c @@ -2520,14 +2520,18 @@ void dcn10_update_mpcc(struct dc *dc, st struct mpc *mpc = dc->res_pool->mpc; struct mpc_tree *mpc_tree_params = &(pipe_ctx->stream_res.opp->mpc_tree_params); - if (per_pixel_alpha) - blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA; - else - blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA; - blnd_cfg.overlap_only = false; blnd_cfg.global_gain = 0xff; + if (per_pixel_alpha && pipe_ctx->plane_state->global_alpha) { + blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA_COMBINED_GLOBAL_GAIN; + blnd_cfg.global_gain = pipe_ctx->plane_state->global_alpha_value; + } else if (per_pixel_alpha) { + blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA; + } else { + blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA; + } + if (pipe_ctx->plane_state->global_alpha) blnd_cfg.global_alpha = pipe_ctx->plane_state->global_alpha_value; else --- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c +++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c @@ -2313,14 +2313,18 @@ void dcn20_update_mpcc(struct dc *dc, st struct mpc *mpc = dc->res_pool->mpc; struct mpc_tree *mpc_tree_params = &(pipe_ctx->stream_res.opp->mpc_tree_params); - if (per_pixel_alpha) - blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA; - else - blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA; - blnd_cfg.overlap_only = false; blnd_cfg.global_gain = 0xff; + if (per_pixel_alpha && pipe_ctx->plane_state->global_alpha) { + blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA_COMBINED_GLOBAL_GAIN; + blnd_cfg.global_gain = pipe_ctx->plane_state->global_alpha_value; + } else if (per_pixel_alpha) { + blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA; + } else { + blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA; + } + if (pipe_ctx->plane_state->global_alpha) blnd_cfg.global_alpha = pipe_ctx->plane_state->global_alpha_value; else