From patchwork Thu Aug 24 13:38:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Melissa Wen X-Patchwork-Id: 13364161 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 96D6DC6FA8F for ; Thu, 24 Aug 2023 13:38:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7FEAE10E54A; Thu, 24 Aug 2023 13:38:17 +0000 (UTC) Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id BD81E10E118; Thu, 24 Aug 2023 13:38:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=GtX3uWe6SyhGZS9UiD7VVl7pKZgtrwMNbJIDvFqXd/g=; b=UEDBpYlukLNga5oW7Gft8qIKDI 8WK6r1vvSe6igJkeQhLvzqnknZXAZouqJ1akgA1XZv4iNNmD9PlB78fQttNMKfNSeuVbB2JunnHAB HWsKWZjJ0YzmMZ0UmgWxO0urKOfiLPJXlkbY/RqzMl5RRNwU1wYCNItBRpF8z2R1YgT3HEANTJsr8 0qX2Lt2Iy70wjRy8b9YcZozHF8YcZfHEcu3bDdmqPESo9qCblPAOkiiTYbhRikIrW96daoWIU7hzr FbeQvIHKrh48sFQu6ftCwSwh0psomna2jNf1ipgz0EZKCb/7+2hRDTYN2VdYFUBJ3z0hRb+IwrDIq zFJTHW0A==; Received: from [38.44.68.151] (helo=killbill.home) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1qZAXM-00Ex8o-3q; Thu, 24 Aug 2023 15:38:12 +0200 From: Melissa Wen To: amd-gfx@lists.freedesktop.org, Harry Wentland , Rodrigo Siqueira , sunpeng.li@amd.com, Alex Deucher , dri-devel@lists.freedesktop.org, christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch Subject: [PATCH] drm/amd/display: enable cursor degamma for DCN3+ DRM legacy gamma Date: Thu, 24 Aug 2023 12:38:09 -0100 Message-Id: <20230824133810.10627-1-mwen@igalia.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Krunoslav Kovac , Xaver Hugl , kernel-dev@igalia.com, Nicholas Kazlauskas Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" For DRM legacy gamma, AMD display manager applies implicit sRGB degamma using a pre-defined sRGB transfer function. It works fine for DCN2 family where degamma ROM and custom curves go to the same color block. But, on DCN3+, degamma is split into two blocks: degamma ROM for pre-defined TFs and `gamma correction` for user/custom curves and degamma ROM settings doesn't apply to cursor plane. To get DRM legacy gamma working as expected, enable cursor degamma ROM for implict sRGB degamma on HW with this configuration. Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2803 Fixes: 96b020e2163f ("drm/amd/display: check attr flag before set cursor degamma on DCN3+") Signed-off-by: Melissa Wen --- Hi, It seems that the previous color fix for atomic API brought out a difference in behavior of degamma color blocks between DCN2 and DCN3, as reported in the link. AFAIU, settings of the `degamma ROM` block for pre-defined TF doesn't apply to cursor plane. So, whenever we wants degamma ROM for cursor plane, we have to explicitly enable it using the attribute flag. This is the case when we do an implicit sRGB degamma to match DRM legacy gamma requirements. Another option would be changing the legacy gamma approach to use the `gamma correction` block where the pre-defined sRGB curve is calculated by AMD color module. I think that keeping degamma ROM usage on legacy gamma is better for performance, this is why I opted for this patch. But let me know if changing legacy gamma implementation in amdgpu_dm_color is better for consistence or any other thing to take into account. Thanks, Melissa drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c index 8eeca160d434..2aa7efd798e2 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c @@ -1269,6 +1269,13 @@ void amdgpu_dm_plane_handle_cursor_update(struct drm_plane *plane, attributes.rotation_angle = 0; attributes.attribute_flags.value = 0; + /* Enable cursor degamma ROM on DCN3+ for implicit sRGB degamma in DRM + * legacy gamma setup. + */ + if (crtc_state->cm_is_degamma_srgb && + adev->dm.dc->caps.color.dpp.gamma_corr) + attributes.attribute_flags.bits.ENABLE_CURSOR_DEGAMMA = 1; + attributes.pitch = afb->base.pitches[0] / afb->base.format->cpp[0]; if (crtc_state->stream) {