From patchwork Thu Aug 10 16:03:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Melissa Wen X-Patchwork-Id: 134083 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp534411vqi; Thu, 10 Aug 2023 09:23:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEFa3WLKNB5cJNC+kmXZFPRw2nanPlt+V7U5CuyswJTw+H7n19kojPYUWT2ycM/FNcZB6ZX X-Received: by 2002:a05:6a00:c91:b0:687:3a7d:ad7a with SMTP id a17-20020a056a000c9100b006873a7dad7amr3706934pfv.7.1691684623821; Thu, 10 Aug 2023 09:23:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691684623; cv=none; d=google.com; s=arc-20160816; b=SDZKUnhStRnrazmuXRR+nmUsseRVSGUEs8gX1gDDI82KRYEXGyt2+mVo2SKL+a71pD CwmNpY5riU7WlInhO7mNgjyaIRm89Tv3J6+FBI3TJCtbLTCrhLfbQ5guIK8Mp0qJ7oqH +k30c55mbpPrEt9kXOpVNBU5Ru8GRXkLVgbb5dJCFnnqKa+A6Zq9kFscvDs79ygUJ/0x iHoa8RsLX4C5Wg0KaknLhK1mPb+QIyrMUBLePFk7VeV/5AQveYT7x7ynCIMcNA3LEMzh jlMrzxPiwUfIwb5fm80l48NnFpnW0KVHTjdYVM5C451rfgUXMpOS4/V1E/RubSF638W7 4WhQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BaAosmlx3GeI869DyRNLKn5JFf6XZu3AYAYzLrNR2sw=; fh=K4g2hpcHeis9i+u86e9V+yTBU0PZFkfdrKenkMdV+qw=; b=SM1RUw4TIhSbOa4V70LI/ayTvH7XJ5XhvHN82VsBU8FtHYl+t84iAIMUZyd225jh9i P2pXMAXqbOE36Q6B/FkxqA1odjmnSi/TqBv4Af3eGinFQB+FyEcYmCoVCwN/2yH1HH+A ocSmfG9fBUNPICCh/HaUjY9n8VYesMdDf6vbTfN4XruDOVYS4eUGeqCeY5wvpresJQky zq+gIXPXaPYi23o7IE6G7vZz15YOP+t7o27eBk/A0ow1KtIEu0SLTtU4BWGAT4RWRfwY q7A5ZvF9qLiilUlZ3ngi29vpOGv4bbbPkUMs9XDyYAzfX0ppxLbgMLfYDQex+7vWTjfA HUng== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=qqW34HLA; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e4-20020a630f04000000b0054fe6b9502esi1710199pgl.687.2023.08.10.09.23.30; Thu, 10 Aug 2023 09:23:43 -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=fail header.i=@igalia.com header.s=20170329 header.b=qqW34HLA; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236523AbjHJQFN (ORCPT + 99 others); Thu, 10 Aug 2023 12:05:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236508AbjHJQES (ORCPT ); Thu, 10 Aug 2023 12:04:18 -0400 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A629E30DB for ; Thu, 10 Aug 2023 09:04:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: 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:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=BaAosmlx3GeI869DyRNLKn5JFf6XZu3AYAYzLrNR2sw=; b=qqW34HLABdbmcyBct/STpAT3UH LVr8qObPs6uxz29O0OGuTC4Hpg4D2nSLic6GKxTMXJAFPO9sx4jx+rMfAyk5PwJDolxZqqQqMmUAQ Y4ZtIoeZ290Q+b0BkC9NGX1AF4ZxC5RWURNdXhZ5GvqUIg0eC2LNcRyyw/fj+7GJOkrjvLAz0fNPI ZJ9nzgRngrWzTbsrOY9uaq3TEr7E5IBxhEhdrc3FbS41jT5ottMkanlM2MRI5BL5XCQBk7PeMP8a5 hTpxf1umXd5b+crrvTuX8ANbY/kc/WOcB/JGAU3ZndHRQafUe8xdGQVynbuBPojKR3iAhV94fkH+Y +kJf80mQ==; 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 1qU88r-00GjYD-Pl; Thu, 10 Aug 2023 18:04:05 +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 Cc: Joshua Ashton , Sebastian Wick , Xaver Hugl , Shashank Sharma , Nicholas Kazlauskas , sungjoon.kim@amd.com, Alex Hung , Pekka Paalanen , Simon Ser , kernel-dev@igalia.com, linux-kernel@vger.kernel.org Subject: [PATCH v2 22/34] drm/amd/display: add dc_fixpt_from_s3132 helper Date: Thu, 10 Aug 2023 15:03:02 -0100 Message-Id: <20230810160314.48225-23-mwen@igalia.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230810160314.48225-1-mwen@igalia.com> References: <20230810160314.48225-1-mwen@igalia.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773859895743736819 X-GMAIL-MSGID: 1773859895743736819 From: Joshua Ashton Detach value translation from CTM to reuse it for programming HDR multiplier property. Reviewed-by: Harry Wentland Signed-off-by: Joshua Ashton Signed-off-by: Melissa Wen --- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c | 8 +------- drivers/gpu/drm/amd/display/include/fixed31_32.h | 12 ++++++++++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c index 5659f88d1f2c..db771c895720 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c @@ -383,7 +383,6 @@ static void __drm_lut_to_dc_gamma(const struct drm_color_lut *lut, static void __drm_ctm_to_dc_matrix(const struct drm_color_ctm *ctm, struct fixed31_32 *matrix) { - int64_t val; int i; /* @@ -402,12 +401,7 @@ static void __drm_ctm_to_dc_matrix(const struct drm_color_ctm *ctm, } /* gamut_remap_matrix[i] = ctm[i - floor(i/4)] */ - val = ctm->matrix[i - (i / 4)]; - /* If negative, convert to 2's complement. */ - if (val & (1ULL << 63)) - val = -(val & ~(1ULL << 63)); - - matrix[i].value = val; + matrix[i] = dc_fixpt_from_s3132(ctm->matrix[i - (i / 4)]); } } diff --git a/drivers/gpu/drm/amd/display/include/fixed31_32.h b/drivers/gpu/drm/amd/display/include/fixed31_32.h index d4cf7ead1d87..84da1dd34efd 100644 --- a/drivers/gpu/drm/amd/display/include/fixed31_32.h +++ b/drivers/gpu/drm/amd/display/include/fixed31_32.h @@ -69,6 +69,18 @@ static const struct fixed31_32 dc_fixpt_epsilon = { 1LL }; static const struct fixed31_32 dc_fixpt_half = { 0x80000000LL }; static const struct fixed31_32 dc_fixpt_one = { 0x100000000LL }; +static inline struct fixed31_32 dc_fixpt_from_s3132(__u64 x) +{ + struct fixed31_32 val; + + /* If negative, convert to 2's complement. */ + if (x & (1ULL << 63)) + x = -(x & ~(1ULL << 63)); + + val.value = x; + return val; +} + /* * @brief * Initialization routines