Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp780395rwb; Mon, 26 Sep 2022 05:54:51 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7jSIuImgIz++wyiwxoVHVGOq3ZkxTUJcMMpIRpSb4ReMLqYpRhko2U7NZeB379l+gHwE6z X-Received: by 2002:a05:6402:298d:b0:451:5fc5:d423 with SMTP id eq13-20020a056402298d00b004515fc5d423mr22213450edb.102.1664196891533; Mon, 26 Sep 2022 05:54:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664196891; cv=none; d=google.com; s=arc-20160816; b=AZBW+lq0CdFjXfTr6SS65nTG0vHZQ+hCCBdSORESzsxgnc9+vIU4bxBEkGK7kSC3qa 7ALfBqaJue377P3Hv/IqhLPSn6mg+Caiu9LZ399lGstLpd4Tnts0rBHU3IGGwHmIsgID tdYfIKsoC5nlegc7qFa2QguKX3Pcqdvt6ENB+zOpHZVQt7JnqO/biz6rtFfkdv+UAn7z dqlPAd77ATYjnIp+7K9eYzUS/TpmAu5j5D8zjmDNGpWdahXu7sbgOoDmz8oZBA+bjMtu cFG/Oyxe/QeYkZvHaPNXssJkCq74g+JoG6yvEBFjbfa/7ayvu8iy8hg3oUgu6IGvtaF4 JZYg== 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=RaYXHdBdxSWhHs6TM9EGOs4V8O9Esy+mrNzuSQF9Dz8=; b=wUOZELEPmvMnBI2O9mtXqK11z0JhWUw1H2n1zREqajTmMglLXUv8ETjXSfRkNRm7EA EOby3AxQNsFxWzUII8zsl2av4LJFJwQd9NeD6fgC7vx0xBvkv3yhEHswZLIpZ7m/891G lWp23PXnMTfYPOY/eZC+mgcvVgNI82wosdyg+QA4/IfQCwH41aWn44FL8fu8BfqJYnv5 OldHoGfxC6DMV6BR8sjHeP4/CJfkUuXTDV+ifZbHqakadubecnxsH8nJuDhJNJhUAl23 RRbKTQDMOcXTLeWW+utgU33vpaBV8B47r3600QI6NlZADVgAO84vpt/6gmMI5ohS0vNH 46Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vq9j9A1H; 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 i13-20020a0564020f0d00b004565c425112si8907999eda.412.2022.09.26.05.54.24; Mon, 26 Sep 2022 05:54:51 -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=vq9j9A1H; 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 S235845AbiIZKfP (ORCPT + 99 others); Mon, 26 Sep 2022 06:35:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235882AbiIZKdK (ORCPT ); Mon, 26 Sep 2022 06:33:10 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D9E337FB0; Mon, 26 Sep 2022 03:20:25 -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 ams.source.kernel.org (Postfix) with ESMTPS id 92690B80924; Mon, 26 Sep 2022 10:20:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD5B5C433D6; Mon, 26 Sep 2022 10:20:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664187609; bh=7lT88kymb+yHRk7aKUfmIghEeBPzIMSI+gUmp/ehBBM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vq9j9A1HYZW/FFCr/9iYrNELwYVk3edG9WN0cC8vN1FEJQmP0oPIQNSOK3pxVk+1e EJErgr2e2LMyxU6kJvWHUx/vzpnYWAzrwNMhRaWDe5FWbsmWEGyfUSC7Xv9EV5/04M de/EYYOS5kv7o1OTIUB3qR9yCBQ9Ey6A2xkDvOTI= 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 4.19 54/58] drm/amd/display: Limit user regamma to a valid value Date: Mon, 26 Sep 2022 12:12:13 +0200 Message-Id: <20220926100743.464586670@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926100741.430882406@linuxfoundation.org> References: <20220926100741.430882406@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 11ea1a0e629b..4e866317ec25 100644 --- a/drivers/gpu/drm/amd/display/modules/color/color_gamma.c +++ b/drivers/gpu/drm/amd/display/modules/color/color_gamma.c @@ -1206,6 +1206,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 */ @@ -1234,6 +1235,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