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 B962FECAAD8 for ; Wed, 21 Sep 2022 15:55:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1961310E9C2; Wed, 21 Sep 2022 15:54:41 +0000 (UTC) Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0E0E210E9B9; Wed, 21 Sep 2022 15:54:36 +0000 (UTC) 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 ams.source.kernel.org (Postfix) with ESMTPS id AD0DAB830E0; Wed, 21 Sep 2022 15:54:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 460D6C433D6; Wed, 21 Sep 2022 15:54:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663775673; bh=0BEwOcdvfMkUKYaNeHKKXFlAaEzB4sCcBK6PLkpw9YY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qJhwh6m8n0TtTyWcvvdIVqcbYV8nHThtHjwvRLr12KM/GZhwzOeZijNZeRbhSic9Y 6OyGu5/G4GSygaDnIO8wSo3tiYrVLBvX4QDN/sgWqneipWs80rr5Cx0ltUnNPIbzNa ADOuW06a5RJwxEbYR6kI1WnyukY/OOylvVamAy5XAIctCSVVf4JptH6LD1OXh3dEwB 0LFX8lcm/liVJgjtvrrFq1AV+IXteMEiKRE95ntIHO7cjB7Z/dmweeezVTdFSAGpSo 64AADkqiNpMu7sxFfzzP54NSlv0sOXv+E6dJtNfIgTfljki/SeGlnKb9fcueZhKNOg Zwsv5UDExqlqA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH AUTOSEL 5.10 5/7] drm/amd/display: Limit user regamma to a valid value Date: Wed, 21 Sep 2022 11:54:23 -0400 Message-Id: <20220921155425.235273-5-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220921155425.235273-1-sashal@kernel.org> References: <20220921155425.235273-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sasha Levin , Aric Cyr , Krunoslav Kovac , sunpeng.li@amd.com, Xinhui.Pan@amd.com, Rodrigo.Siqueira@amd.com, amd-gfx@lists.freedesktop.org, airlied@linux.ie, Daniel Wheeler , Yao Wang1 , dri-devel@lists.freedesktop.org, daniel@ffwll.ch, Alex Deucher , harry.wentland@amd.com, christian.koenig@amd.com, Pavle Kotarac Errors-To: amd-gfx-bounces@lists.freedesktop.org Sender: "amd-gfx" From: Yao Wang1 [ Upstream commit 3601d620f22e37740cf73f8278eabf9f2aa19eb7 ] [Why] For HDR mode, we get total 512 tf_point and after switching to SDR mode we actually get 400 tf_point and the rest of points(401~512) still use dirty value from HDR mode. We should limit the rest of the points to max value. [How] Limit the value when coordinates_x.x > 1, just like what we do in translate_from_linear_space for other re-gamma build paths. Tested-by: Daniel Wheeler Reviewed-by: Krunoslav Kovac Reviewed-by: Aric Cyr Acked-by: Pavle Kotarac Signed-off-by: Yao Wang1 Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/display/modules/color/color_gamma.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/amd/display/modules/color/color_gamma.c b/drivers/gpu/drm/amd/display/modules/color/color_gamma.c index 09bc2c249e1a..3c4390d71a82 100644 --- a/drivers/gpu/drm/amd/display/modules/color/color_gamma.c +++ b/drivers/gpu/drm/amd/display/modules/color/color_gamma.c @@ -1524,6 +1524,7 @@ static void interpolate_user_regamma(uint32_t hw_points_num, struct fixed31_32 lut2; struct fixed31_32 delta_lut; struct fixed31_32 delta_index; + const struct fixed31_32 one = dc_fixpt_from_int(1); i = 0; /* fixed_pt library has problems handling too small values */ @@ -1552,6 +1553,9 @@ static void interpolate_user_regamma(uint32_t hw_points_num, } else hw_x = coordinates_x[i].x; + if (dc_fixpt_le(one, hw_x)) + hw_x = one; + norm_x = dc_fixpt_mul(norm_factor, hw_x); index = dc_fixpt_floor(norm_x); if (index < 0 || index > 255) -- 2.35.1