From patchwork Wed Feb 19 09:20:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jay Liu X-Patchwork-Id: 13983129 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 5C266C021B1 for ; Wed, 19 Feb 2025 23:48:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4C26A10E8AF; Wed, 19 Feb 2025 23:48:38 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=mediatek.com header.i=@mediatek.com header.b="ZRihoo8M"; dkim-atps=neutral Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by gabe.freedesktop.org (Postfix) with ESMTPS id 875DB10E799 for ; Wed, 19 Feb 2025 09:21:08 +0000 (UTC) X-UUID: d6fd37f8eea211efaae1fd9735fae912-20250219 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=uRjryn1Z9973YvyrRwHv9/fVTyITLe6PZEvLBbf4Eeo=; b=ZRihoo8M4GiETNNqkMr4cGp3TdhNZLq38mZ1LaOFXpIIo84guH4URjPaR0ONi3pLXs9tLbEpPTGWneaKc65TF1tA1fl4mEKhq0M3SygkfVYh6D5PTAKN3ZB6f+9bTzuxE4fYUORjDecirXt09VgDcBUN2qD28MZYodxeRrbviuM=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.46, REQID:11b34bde-b4b7-47dd-95d2-386ce7b53def, IP:0, U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:60aa074, CLOUDID:caf8fe28-e0f8-414e-b8c3-b75c08217be8, B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102,TC:nil,Content:0|50,EDM:-3 ,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV :0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: d6fd37f8eea211efaae1fd9735fae912-20250219 Received: from mtkmbs14n1.mediatek.inc [(172.21.101.75)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 554630443; Wed, 19 Feb 2025 17:21:03 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by MTKMBS09N2.mediatek.inc (172.21.101.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Wed, 19 Feb 2025 17:21:01 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1258.28 via Frontend Transport; Wed, 19 Feb 2025 17:21:00 +0800 From: Jay Liu To: Chun-Kuang Hu , Philipp Zabel , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Yongqiang Niu , CK Hu , Hsin-Yi Wang CC: , , , , , , Jay Liu Subject: [PATCH 2/7] drm/mediatek: fix CCORR mtk_ctm_s31_32_to_s1_n function issue Date: Wed, 19 Feb 2025 17:20:35 +0800 Message-ID: <20250219092040.11227-3-jay.liu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20250219092040.11227-1-jay.liu@mediatek.com> References: <20250219092040.11227-1-jay.liu@mediatek.com> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 19 Feb 2025 23:48:37 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" if matrixbit is 11, The range of color matrix is from 0 to (BIT(11) - 1). Values from 0 to (BIT(11) - 1) represent positive numbers, values from BIT(11) to (BIT(12) - 1) represent negative numbers. For example, -1 need converted to 8191. Fixes: 738ed4156fba ("drm/mediatek: Add matrix_bits private data for ccorr") Signed-off-by: Jay Liu --- drivers/gpu/drm/mediatek/mtk_disp_ccorr.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ccorr.c b/drivers/gpu/drm/mediatek/mtk_disp_ccorr.c index 94e82b3fa2d8..a9f91b71534b 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_ccorr.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_ccorr.c @@ -100,6 +100,15 @@ static u16 mtk_ctm_s31_32_to_s1_n(u64 in, u32 n) r |= (in >> (32 - n)) & GENMASK(n, 0); } + /* + *The range of r is from 0 to (BIT(n + 1) - 1), + *where values from 0 to (BIT(n) - 1) represent positive numbers, + *and values from BIT(n) to (BIT(n + 1) - 1) represent negative numbers. + *For example, if n is 11, -1 will be converted to 8191. + */ + if (r & BIT(n + 1)) + r = (~(r & GENMASK(n, 0)) + 1) & GENMASK(n + 1, 0); + return r; }