From patchwork Sun Apr 23 14:10:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Melissa Wen X-Patchwork-Id: 86765 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2241995vqo; Sun, 23 Apr 2023 08:10:41 -0700 (PDT) X-Google-Smtp-Source: AKy350ao07iMFDSu5CRhe5JeJRdpPXrzEB5SDjvSgBv4udXdM+yxoQZWFgcl4m/m6Xcz8Ne5hN+i X-Received: by 2002:a05:6a00:1a55:b0:63d:4446:18ab with SMTP id h21-20020a056a001a5500b0063d444618abmr15084056pfv.23.1682262641030; Sun, 23 Apr 2023 08:10:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682262641; cv=none; d=google.com; s=arc-20160816; b=boBqTJzraTKNHQVPR4R0Jo1gYc8URDfI8Q4ii7ae6eeFwHI4nidowGfkXEN6Sn7AZV OLw+Xem0DtVXC1f0ae658NEAkOpx/PzNhwF0YMOm2OQ4YLsjF6/EawKNrfxPWrCELsJo s0y9I0HU3ekJa7vVZwkZblfvWvcg9qjwSRKV0EI3cuMQIv84rJgywBqz4xGSxOGv8BR6 F/bKwE9XCvBeqaHatsHjnUex9C3dwcNc+oUEHCreqL9XPM0opgWdc3ssh6oODNi7VS5W +pQsqMVeHDSf08IU4oiSH9U1w1IK7fHkFC9Ffs/DLPXuyZtmo739wrZMrUwCHGwxtSSu EXkA== 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=P4ZXpKFMtoIv2GHYDm0O+bIMEiRHVdDFlzSdVRRjl+4=; b=N7bAahJ94a0a154B/OmiLO58903JKClileCV3a7XzD1nPRVWjPTmpNTlvRVrpNGRBZ fm+8xikf1rgitdLCsbrS0TkJxTaIlWs9860a197SLwJaL6aHclR8gaAp++yP0OZZ2nY1 ZrKGVq0SHff75Lvfub1iWwCYyRPYfC+frbnRbrnXDHaIOjXoY4zfU3fKO7L1IYa7lh9C 1wIpvWa4IoaZSmD9SZRRTzm1WZ4kAZ/xodj6J/AcZTefNo+1HBDw2IbQeGsQCBonr9LN e+k9RcXQnE20Rb/X6I0psrH+PSSUHOi1e83htvV5pvRakYS8tKt1qr3kkpXk7iwZWjqm uZHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=Xf5xbFUl; 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 a12-20020aa7970c000000b0063bba11c4a0si9313829pfg.59.2023.04.23.08.10.26; Sun, 23 Apr 2023 08:10:41 -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=Xf5xbFUl; 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 S229453AbjDWOrK (ORCPT + 99 others); Sun, 23 Apr 2023 10:47:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230256AbjDWOrF (ORCPT ); Sun, 23 Apr 2023 10:47:05 -0400 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EBC62700 for ; Sun, 23 Apr 2023 07:46:51 -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=P4ZXpKFMtoIv2GHYDm0O+bIMEiRHVdDFlzSdVRRjl+4=; b=Xf5xbFUlVRcMeEfF92pKTWXigX R9y7r3VyMhFpJTzPExO/MEwG3xN9AyhwDWtZ+WGoZe8rbS3sdSGEV77TDsmVhg2icLCNnhOqq/nZq C94uECAkNCXMFTBXeOewYKAf3EFwNxYGTW+54d9UbLXWJkzvXXMvDYEDMY6JWdZI3UuFi1R/PW7yj Tj6FFfM6mOlk6Uz1yKXlU+iE+uuhNX59b6Q9G3mElUuCEDTy67bzM3TKt8//1H7bEjJsGJYcuqvdB rjmy50QlYBUT/bHPct4NQfoVfgJsbb5dW5VB8BZCE7LdtB78DNXJFGVC8sjgEQWkwzlmiQy7qFtJx UHH6t3+A==; Received: from nat-wifi.fi.muni.cz ([147.251.43.9] helo=killbill.fi.muni.cz) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1pqaTO-00ANVs-Pv; Sun, 23 Apr 2023 16:13:50 +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 , linux-kernel@vger.kernel.org Subject: [RFC PATCH 34/40] drm/amd/display: add dc_fixpt_from_s3132 helper Date: Sun, 23 Apr 2023 13:10:46 -0100 Message-Id: <20230423141051.702990-35-mwen@igalia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230423141051.702990-1-mwen@igalia.com> References: <20230423141051.702990-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,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763980230872114799?= X-GMAIL-MSGID: =?utf-8?q?1763980230872114799?= From: Joshua Ashton Detach value translation from CTM to reuse it for programming HDR multiplier property. Signed-off-by: Joshua Ashton --- .../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 07303c9f3618..d714728ca143 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 @@ -182,7 +182,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; /* @@ -201,12 +200,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 ece97ae0e826..f4cc7f97329f 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