Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp798906rwb; Mon, 26 Sep 2022 06:06:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6wEyAwKukgzunEcpjjM0S4Ja6mZ5sEWLfCDM/iV25pkNoZ1wz39GxPgQcd3ghXT1HuGcFV X-Received: by 2002:a17:907:3f19:b0:781:e579:46c2 with SMTP id hq25-20020a1709073f1900b00781e57946c2mr18069462ejc.382.1664197596730; Mon, 26 Sep 2022 06:06:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664197596; cv=none; d=google.com; s=arc-20160816; b=usE+/B29iPkQoFqYNr2++VDQNvYosHdPyowBcGFeWUEausANZPJg6MhE8c/9DrUHAu sBMvtZpslgjmAP7BZcOfr7vAVoGL47HqDfWwQNCj31jXq6+69LRW6ob6R8p0JFPvI+A6 25HF4KehwyUrhOtkdtNXLZTuYT7kLmUknWs7giso/1wWyyd1szPI0P+AFAoaBts65zGR Cp0ej1XMxLX3KsPjEE8kCOW0oXHhxqC8stCAwz89mTrerKYWbpjikXgcXsZMssAQSjBI I+19zmT81Tzk4i2PaFnVRzkrg/P6W8iFwdW6fNKDsXg3i1Zq3lBo23sIHK+LX0UH3pGJ WNlA== 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=taEJPco2/yRM0xB0Oi8qWxppcSBRaJZD3KuCcHemyFA=; b=DJ9lfpB2+ypBt5KRPg69Kcqw2JUsjF7vj7Pw2I0b2bhv+toLojZgHfNutPfqIeillX L7+iF53F7T1BjndRIx5J1tBjcrRdpuPgZ9VsrlnFAf2+f15y0Nifo/gh682rS9mXA2xr I0zKCaMuEdJ6T67dJozLvqBsP+mBOQIWu+L8r6GuAZkZlj/1p8w+uP8yq/n0EHtAx52n 2k9ZbjI4TYikFqC7VW+0xbEgsOTWt09TUxim+4qb5xUzQj5o0l/cQDZef5G6Mx7yamCB TAVSEeou0uvxzSISgqOiHZ2XMWz8KcXc5Wah1fwQnOARGF6xp9DfSVggcFbWeaM7EUwQ s+qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LCE3cZ94; 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 eg42-20020a05640228aa00b00457563c4196si1828115edb.595.2022.09.26.06.06.09; Mon, 26 Sep 2022 06:06:36 -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=LCE3cZ94; 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 S239122AbiIZMAC (ORCPT + 99 others); Mon, 26 Sep 2022 08:00:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238528AbiIZL4O (ORCPT ); Mon, 26 Sep 2022 07:56:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CD967960B; Mon, 26 Sep 2022 03:51:33 -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 0ADB360C17; Mon, 26 Sep 2022 10:50:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 139AFC433C1; Mon, 26 Sep 2022 10:50:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664189416; bh=Tb00sjBAY3nprOehK04zLLPf89XDrBubey8KUxfTO+w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LCE3cZ949iWzr+X6asa9CJUJWT7H7PE5rFKD7VPfdK2mPWLQC+8LmAoEB9KmGekew TVlNVnWrqjZszdFDPQeDbVHqfr/6m5LI5OdqkpmsHMnwBbWy7ajuqhQUgTnpKvWJL6 8mrMxQ7yOhTSUYa+RjhGBaA1vqYezOghQf29RjfY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Wheeler , Krunoslav Kovac , Aric Cyr , Pavle Kotarac , Yao Wang1 , Alex Deucher , Sasha Levin Subject: [PATCH 5.19 181/207] drm/amd/display: Limit user regamma to a valid value Date: Mon, 26 Sep 2022 12:12:50 +0200 Message-Id: <20220926100814.709822293@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926100806.522017616@linuxfoundation.org> References: <20220926100806.522017616@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 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 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: 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 64a38f08f497..5a51be753e87 100644 --- a/drivers/gpu/drm/amd/display/modules/color/color_gamma.c +++ b/drivers/gpu/drm/amd/display/modules/color/color_gamma.c @@ -1603,6 +1603,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 */ @@ -1631,6 +1632,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