From patchwork Wed Oct 23 06:42:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: James Qian Wang X-Patchwork-Id: 11205751 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CA138139A for ; Wed, 23 Oct 2019 06:43:11 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id B0DFC21906 for ; Wed, 23 Oct 2019 06:43:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B0DFC21906 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EDE2C6E95F; Wed, 23 Oct 2019 06:43:10 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-ve1eur02on0625.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe06::625]) by gabe.freedesktop.org (Postfix) with ESMTPS id A86296E95F for ; Wed, 23 Oct 2019 06:43:09 +0000 (UTC) Received: from VI1PR08CA0175.eurprd08.prod.outlook.com (2603:10a6:800:d1::29) by HE1PR0801MB1769.eurprd08.prod.outlook.com (2603:10a6:3:7f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.16; Wed, 23 Oct 2019 06:43:05 +0000 Received: from AM5EUR03FT041.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::201) by VI1PR08CA0175.outlook.office365.com (2603:10a6:800:d1::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2367.21 via Frontend Transport; Wed, 23 Oct 2019 06:43:05 +0000 Received-SPF: Fail (protection.outlook.com: domain of arm.com does not designate 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT041.mail.protection.outlook.com (10.152.17.186) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2367.23 via Frontend Transport; Wed, 23 Oct 2019 06:43:05 +0000 Received: ("Tessian outbound e4042aced47b:v33"); Wed, 23 Oct 2019 06:43:03 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 1af05dff4a19bcd4 X-CR-MTA-TID: 64aa7808 Received: from 68dd3a3811af.2 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.8.56]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id FF873FE2-02A2-4B73-B53D-6B93DD935D4A.1; Wed, 23 Oct 2019 06:42:57 +0000 Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-am5eur03lp2056.outbound.protection.outlook.com [104.47.8.56]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 68dd3a3811af.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 23 Oct 2019 06:42:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SUSu0OWQQHeveEFbKcYDJL3Xx3iDycHrkay6owVnOMykMv+ZFZiBYb1fcnXyA+vTswvHZ1UPRnWku9aQdvQxp5MjBMgUn/Kx5QuPh2O3yQnPeiwr5WIJsfO2z4C92KY6fC4jcK2OZ06KvaL8aFq2bRnTHttJGw28D+TMxWYFL1SQ//Ozqcftpuu9+RSom4klaiur1Bd0nf6zoLIz0//Eupaj0iudO08T2I9Hv10atYhCEFqRZZK3Fis5gPQ0kZEfMHQdKX25YMeGGyxIgec0lIxPvREQbCwAmP2g1qWVb7DblP4BKp/L5yzxbpgCj72F5EjJbCCSzQOLN/40/a2M9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FR0RtOODGwJKPGPv6sNfKERHsmalyGvuC8CCokH63Tw=; b=jRHBC4EfqFHvJPfJQlJDH/gcPUD+T8B2nO4yj1iG2zEa+ab5ZeoTrbcX7Hg7guaeBXOTdTRgM6+796+f70mWa3/pI+WNOInzdmzuhtbChvnQ39YzROabWnRRPKEMW+YObnKS8d5xwZ2dxQLutyWbaLBguwCTPGX6NKD6t7s+n9Ps7zKOB49c/t03WJn9wwar5G61z4R6SEG+pUwaKv3qsN0REP4bnySSrKdqv/4KlsmQCB8qOrI/xG7Dcg/kaCrZ4jr5bWDEyGLyDldJqmzAnv8fezspVkf741r3j/ySJk2G4J0LSZPM6UZwG+GXm3HZbxFX8Ng2xBDgoZ5klpL4Dg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Received: from VE1PR08MB5006.eurprd08.prod.outlook.com (10.255.159.31) by VE1PR08MB4672.eurprd08.prod.outlook.com (10.255.112.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.22; Wed, 23 Oct 2019 06:42:56 +0000 Received: from VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::40ed:7ed3:90cf:ece5]) by VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::40ed:7ed3:90cf:ece5%3]) with mapi id 15.20.2367.022; Wed, 23 Oct 2019 06:42:56 +0000 From: "james qian wang (Arm Technology China)" To: Liviu Dudau , "airlied@linux.ie" , Brian Starkey , "maarten.lankhorst@linux.intel.com" , "sean@poorly.run" , "imirkin@alum.mit.edu" Subject: [PATCH v7 1/4] drm: Add a new helper drm_color_ctm_s31_32_to_qm_n() Thread-Topic: [PATCH v7 1/4] drm: Add a new helper drm_color_ctm_s31_32_to_qm_n() Thread-Index: AQHViW0axzrBedn3A0yRNgX73SioEQ== Date: Wed, 23 Oct 2019 06:42:55 +0000 Message-ID: <20191023064226.10969-2-james.qian.wang@arm.com> References: <20191023064226.10969-1-james.qian.wang@arm.com> In-Reply-To: <20191023064226.10969-1-james.qian.wang@arm.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [113.29.88.7] x-clientproxiedby: HK2PR02CA0184.apcprd02.prod.outlook.com (2603:1096:201:21::20) To VE1PR08MB5006.eurprd08.prod.outlook.com (2603:10a6:803:113::31) Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 9589ceb8-1707-4395-70b9-08d75784425b X-MS-TrafficTypeDiagnostic: VE1PR08MB4672:|VE1PR08MB4672:|HE1PR0801MB1769: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:6790;OLM:6790; x-forefront-prvs: 019919A9E4 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(396003)(136003)(39860400002)(366004)(376002)(346002)(189003)(199004)(7736002)(25786009)(2906002)(386003)(71200400001)(4326008)(36756003)(305945005)(6506007)(66066001)(2201001)(71190400001)(102836004)(5660300002)(26005)(478600001)(52116002)(55236004)(316002)(86362001)(186003)(6116002)(76176011)(3846002)(256004)(2171002)(66446008)(66946007)(103116003)(64756008)(6512007)(1076003)(66556008)(50226002)(66476007)(476003)(6436002)(8936002)(446003)(2501003)(11346002)(2616005)(6486002)(14454004)(486006)(54906003)(99286004)(81166006)(8676002)(81156014)(110136005); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB4672; H:VE1PR08MB5006.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: jc9qNN95z2LggFhMQUr/etJwrvoKW1S/byLD6AwTxBR+ydkc8Xjpn+WLnZn05hFXwQrdKXAUk51lVqCE942ff8DpyrY3lpOrVpFR9RnQxsPTLSTX4pbePMqx1hfhLgeJyJbv7SZBLmLs8lDCDD1PbxybUYWShuO7JoR8SxW533pINf2Iv5iHGM6XpbpgfDm7byTkmq65z7R26ioRPKqBv96whmzlH3BRXHjHEMeKvq4C0nPIQ/8AiurL7pwf0HMJKGR+YgsgX920LHuXHLvf3r1LHjYz3jaUXZ2IBRLQa4hVUcLpzMy0OSfEwVLXmo/jeMy0EAG7hSOFVq0lQ38/I0VdfhaFcq3ZZYqFIc4bdd1P4Wquo8UwWIT/you8VHNHEAmczGWFneb96wkAeiG4NBw33WxKfk0gZwifjCBz3XE= Content-ID: MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4672 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT041.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; IPV:CAL; SCL:-1; CTRY:IE; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(136003)(396003)(376002)(346002)(39860400002)(1110001)(339900001)(189003)(199004)(2201001)(105606002)(1076003)(4326008)(25786009)(103116003)(107886003)(5660300002)(356004)(6486002)(2906002)(6512007)(86362001)(2171002)(14454004)(23676004)(2486003)(2501003)(478600001)(54906003)(126002)(476003)(316002)(386003)(6506007)(110136005)(76130400001)(99286004)(11346002)(66066001)(36756003)(102836004)(2616005)(81156014)(47776003)(486006)(436003)(336012)(6116002)(3846002)(446003)(8676002)(50226002)(26005)(81166006)(8936002)(186003)(76176011)(22756006)(26826003)(305945005)(36906005)(7736002)(50466002)(70206006)(70586007); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0801MB1769; H:64aa7808-outbound-1.mta.getcheckrecipient.com; FPR:; SPF:Fail; LANG:en; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; MX:1; A:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: 506f0e41-01e0-40d1-85a2-08d757843c58 NoDisclaimer: True X-Forefront-PRVS: 019919A9E4 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: B6zO0q61gK0ar5cD0FNR90umAX6yPLwDC8fIP7ZYxBVFF1qCk9CmLwnrdd75W3PhJijdV5ZMQm4OUZNCJDhSCKCtRgaX9Rm7qN7cGGjasheLdZVaQO9yPU1EUe6JAGR097EtENdDMJ2MHm+QfrBgvzX23RskSDM5TIBtXNq1yKnx/hglL9N8vHKHdwd0yqIoNt1BTLCm1t4j95eFym8e1BgFlUwf2qKc0J2VIWWwv/2pwIHALi9weTcHJLPQttCzQoFKkBXYTlliknpTSRWpVmarHZWFVvz/RaQjA8W7KE+jbx46rYWJfAdVYynhmaedTj8kzuBgeg4umF7Mgw+fb5Yd1meQDzr15n7cZDFHLeCbiyyKoStB545E3peDNw/DZQowMBao8WWN3fLyk/1AVdBX8AtuRrdPd89fSt/JKPeshvzvPLVT7bkkxBOzKcB8 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2019 06:43:05.6231 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9589ceb8-1707-4395-70b9-08d75784425b X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB1769 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FR0RtOODGwJKPGPv6sNfKERHsmalyGvuC8CCokH63Tw=; b=YMqWKiuCELDGBTmwKU4eaufSfYSAEt0jyTGK03oTp3IqCQtaouR4aisJhXiXrOH8et0nA0Zqvm+TvRbV6pdH2kBUXjPTtHD48OXiEw+p0jF6jvBCV152lPFB6eJASf0P+rFOVFLP0uDykDVUgSZ+Q9iR+nmu9i1JmE2mZrcEVwU= X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FR0RtOODGwJKPGPv6sNfKERHsmalyGvuC8CCokH63Tw=; b=YMqWKiuCELDGBTmwKU4eaufSfYSAEt0jyTGK03oTp3IqCQtaouR4aisJhXiXrOH8et0nA0Zqvm+TvRbV6pdH2kBUXjPTtHD48OXiEw+p0jF6jvBCV152lPFB6eJASf0P+rFOVFLP0uDykDVUgSZ+Q9iR+nmu9i1JmE2mZrcEVwU= X-Mailman-Original-Authentication-Results: spf=fail (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.freedesktop.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.freedesktop.org; dmarc=none action=none header.from=arm.com; X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nd , Ayan Halder , "Oscar Zhang \(Arm Technology China\)" , "Tiannan Zhu \(Arm Technology China\)" , Mihail Atanassov , Daniel Vetter , "Jonathan Chai \(Arm Technology China\)" , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "Julien Yin \(Arm Technology China\)" , "Channing Chen \(Arm Technology China\)" , "james qian wang \(Arm Technology China\)" , "Yiqi Kang \(Arm Technology China\)" , "Thomas Sun \(Arm Technology China\)" , "Lowry Li \(Arm Technology China\)" , Ben Davis Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add a new helper function drm_color_ctm_s31_32_to_qm_n() for driver to convert S31.32 sign-magnitude to Qm.n 2's complement that supported by hardware. V4: Address Mihai, Daniel and Ilia's review comments. V5: Includes the sign bit in the value of m (Qm.n). V6: Allows m = 0 according to Mihail's comments. V6: Address Mihail's comments. Signed-off-by: james qian wang (Arm Technology China) Reviewed-by: Mihail Atanassov Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_color_mgmt.c | 36 ++++++++++++++++++++++++++++++++ include/drm/drm_color_mgmt.h | 2 ++ 2 files changed, 38 insertions(+) diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c index 4ce5c6d8de99..f5fba5802a07 100644 --- a/drivers/gpu/drm/drm_color_mgmt.c +++ b/drivers/gpu/drm/drm_color_mgmt.c @@ -132,6 +132,42 @@ uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision) } EXPORT_SYMBOL(drm_color_lut_extract); +/** + * drm_color_ctm_s31_32_to_qm_n + * + * @user_input: input value + * @m: number of integer bits, only support m <= 32, include the sign-bit + * @n: number of fractional bits, only support n <= 32 + * + * Convert and clamp S31.32 sign-magnitude to Qm.n (signed 2's complement). + * The sign-bit BIT(m+n) and above are 0 for positive value and 1 for negative. + * the range of value is [-2^(m-1), 2^(m-1) - 2^-n] + * + * For example + * A Q3.12 format number: + * - required bit: 3 + 12 = 15bits + * - range: [-2^2, 2^2 - 2^−15] + * + * NOTE: the m can be zero if all bit_precision are used to present fractional + * bits like Q0.32 + */ +uint64_t drm_color_ctm_s31_32_to_qm_n(uint64_t user_input, + uint32_t m, uint32_t n) +{ + u64 mag = (user_input & ~BIT_ULL(63)) >> (32 - n); + bool negative = !!(user_input & BIT_ULL(63)); + s64 val; + + WARN_ON(m > 32 || n > 32); + + + val = clamp_val(mag, 0, negative ? + BIT_ULL(n + m - 1) : BIT_ULL(n + m - 1) - 1); + + return negative ? -val : val; +} +EXPORT_SYMBOL(drm_color_ctm_s31_32_to_qm_n); + /** * drm_crtc_enable_color_mgmt - enable color management properties * @crtc: DRM CRTC diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h index d1c662d92ab7..60fea5501886 100644 --- a/include/drm/drm_color_mgmt.h +++ b/include/drm/drm_color_mgmt.h @@ -30,6 +30,8 @@ struct drm_crtc; struct drm_plane; uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision); +uint64_t drm_color_ctm_s31_32_to_qm_n(uint64_t user_input, + uint32_t m, uint32_t n); void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc, uint degamma_lut_size, From patchwork Wed Oct 23 06:43:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Qian Wang X-Patchwork-Id: 11205753 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0C7D013B1 for ; Wed, 23 Oct 2019 06:43:20 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E3B6B21906 for ; Wed, 23 Oct 2019 06:43:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E3B6B21906 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 370266E960; Wed, 23 Oct 2019 06:43:19 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130043.outbound.protection.outlook.com [40.107.13.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id AFFE76E960 for ; Wed, 23 Oct 2019 06:43:16 +0000 (UTC) Received: from VI1PR08CA0158.eurprd08.prod.outlook.com (2603:10a6:800:d1::12) by VI1PR0801MB1983.eurprd08.prod.outlook.com (2603:10a6:800:86::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.21; Wed, 23 Oct 2019 06:43:12 +0000 Received: from AM5EUR03FT041.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::207) by VI1PR08CA0158.outlook.office365.com (2603:10a6:800:d1::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.20 via Frontend Transport; Wed, 23 Oct 2019 06:43:12 +0000 Received-SPF: Fail (protection.outlook.com: domain of arm.com does not designate 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT041.mail.protection.outlook.com (10.152.17.186) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2367.23 via Frontend Transport; Wed, 23 Oct 2019 06:43:11 +0000 Received: ("Tessian outbound e4042aced47b:v33"); Wed, 23 Oct 2019 06:43:10 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 3f0e5afd2a6b8878 X-CR-MTA-TID: 64aa7808 Received: from b8d509519dc2.2 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.8.51]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 9F5E5C31-FCD1-401F-B28B-E7595C5FECF3.1; Wed, 23 Oct 2019 06:43:04 +0000 Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-am5eur03lp2051.outbound.protection.outlook.com [104.47.8.51]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id b8d509519dc2.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 23 Oct 2019 06:43:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WDD9eDug6PJPtn+KoeO51N8Wir4M8XEPu5iEO6Z9CjxnUkVSAja7lv6IHfqomdOjV2IVFe0mA0lwl2R+CVmTCJO4I4Tn2UREnzU4lbvZchnaz48B1+upshLUXsnkzpcJ6Xi03/I5JdfbNsLDyTKyF2jHmCkZgNGIiJKVQ+MvJEVtRpcX+AnjHWYgqVLbBmFA18pfwEgmnF2t22AgZCtojN41pKPaTUN1UeYXLHsv+wLM+6s/A2I7gl1X7ZsvI/0Jl1jOLpqa5v5mTEPnHq5veDSeUqktXUsm2B2wB8ibLbFK0OVJYoi+86v6d271r3TpMimJ53kBBOb+xui1MSTMtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Dwl4JXh3gudDNqqnWSO4qmhHyZFD7hivyUxQxR0plGY=; b=GyQRI8z9pe3mJbbOdfyj+Oa1YD8Y+oWJPEoPS0UvH7db+Z856MyzCNPWLD/2yBkfJhnt8g0gmNm55t9St3r4/wVr5jn7WIcOrRnxS5XWxGTyd0nOVDuyQzhLaOIA5G5B3k+8AWBRGbCCpgd6iNwLkH0LbnANjzCaFPipru4imU7KB/j6UCOHOnW+LOGtqiFzpS3xoXsVGQZjZPzU7rkdJrmLliCy3hhsfiHuxjecISOOvEmr05dVR0HGTKpNoHGHF8igQsk71sixmYEZ1e3sEEOYSkmtwoetcOMt29HrseFDfWF481mCCCNjPvJwny7oo9aL09pI7gmYCvlDSxjkRA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Received: from VE1PR08MB5006.eurprd08.prod.outlook.com (10.255.159.31) by VE1PR08MB4672.eurprd08.prod.outlook.com (10.255.112.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.22; Wed, 23 Oct 2019 06:43:03 +0000 Received: from VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::40ed:7ed3:90cf:ece5]) by VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::40ed:7ed3:90cf:ece5%3]) with mapi id 15.20.2367.022; Wed, 23 Oct 2019 06:43:03 +0000 From: "james qian wang (Arm Technology China)" To: Liviu Dudau , "airlied@linux.ie" , Brian Starkey , "maarten.lankhorst@linux.intel.com" , "sean@poorly.run" , "imirkin@alum.mit.edu" Subject: [PATCH v7 2/4] drm/komeda: Add drm_lut_to_fgamma_coeffs() Thread-Topic: [PATCH v7 2/4] drm/komeda: Add drm_lut_to_fgamma_coeffs() Thread-Index: AQHViW0eTRzKlLORfEigId1iRu45AQ== Date: Wed, 23 Oct 2019 06:43:02 +0000 Message-ID: <20191023064226.10969-3-james.qian.wang@arm.com> References: <20191023064226.10969-1-james.qian.wang@arm.com> In-Reply-To: <20191023064226.10969-1-james.qian.wang@arm.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [113.29.88.7] x-clientproxiedby: HK2PR02CA0184.apcprd02.prod.outlook.com (2603:1096:201:21::20) To VE1PR08MB5006.eurprd08.prod.outlook.com (2603:10a6:803:113::31) Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 9769c705-54d7-4ec0-3a43-08d757844615 X-MS-TrafficTypeDiagnostic: VE1PR08MB4672:|VE1PR08MB4672:|VI1PR0801MB1983: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:2043;OLM:2043; x-forefront-prvs: 019919A9E4 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(396003)(136003)(39860400002)(366004)(376002)(346002)(189003)(199004)(7736002)(25786009)(2906002)(386003)(71200400001)(4326008)(36756003)(305945005)(6506007)(66066001)(2201001)(71190400001)(102836004)(5660300002)(26005)(478600001)(52116002)(14444005)(55236004)(316002)(86362001)(186003)(6116002)(76176011)(3846002)(256004)(2171002)(66446008)(66946007)(103116003)(64756008)(6512007)(1076003)(66556008)(50226002)(66476007)(476003)(6436002)(8936002)(446003)(2501003)(11346002)(2616005)(6486002)(14454004)(486006)(54906003)(99286004)(81166006)(8676002)(81156014)(110136005); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB4672; H:VE1PR08MB5006.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: fp4LKsL/+am5Me5BtVSYezdXE3Pvjta396ABbaGdtnmlhEFfrm9ZG/QnHoLenEt+jEimTK9cBFinTT+hHZLMv2ttu2sRMapNc7INeqyTGCCqF2YR8y+OGdc8PRq6X9HlzE8lQEf8j8rrIZt1ISqBmQd0g5irLxc1ImuMmCSKWJLBaCZJGORUa9ULdnRdjslQFImr/gZzUno+D+G8zY+xBgfema6d8j5D7fX8XDbfnW5bQdDTdl4Ry8PTlkuXGgQMxYRAlPGPGjPbcdcWlJ9eBA9fSUCX5UhDQzWUjxMsydf1IafvEKJ4bdz2gnPfGHR27XIc9HTlYkx8n/7IZWdhfbF5yvjCQNSx6TPFqIhdvQNYryG3C8Dgc6sY+YphfqOT7tbPByvazBsd3nudBn1Jk640qHDQzuhcbaX8/2ZnLZ4= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4672 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT041.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; IPV:CAL; SCL:-1; CTRY:IE; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(346002)(136003)(376002)(39860400002)(396003)(1110001)(339900001)(199004)(189003)(70586007)(81156014)(8746002)(22756006)(356004)(8676002)(305945005)(70206006)(66066001)(7736002)(81166006)(8936002)(1076003)(2906002)(50226002)(76130400001)(5660300002)(47776003)(25786009)(105606002)(2501003)(86362001)(14444005)(2201001)(76176011)(50466002)(476003)(186003)(36756003)(110136005)(446003)(2616005)(23756003)(6512007)(103116003)(336012)(54906003)(6506007)(26826003)(6116002)(102836004)(26005)(316002)(99286004)(36906005)(386003)(6486002)(2171002)(478600001)(486006)(14454004)(4326008)(11346002)(126002)(3846002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0801MB1983; H:64aa7808-outbound-1.mta.getcheckrecipient.com; FPR:; SPF:Fail; LANG:en; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; A:1; MX:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: c5eac636-4a83-4e9b-00c1-08d757844098 NoDisclaimer: True X-Forefront-PRVS: 019919A9E4 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Q1tA56erTzaaT9yVi6L3Iu2yMRWbWTGlpuHSAsstEIl6rUFTfLmEnImS1M17zP8QH3P0leU00mDc9LSnnTzRF02BzEiUMF+vhMamOql4EQiIx8CfV7bgIrDR8tRJ359+cH8CmEWww9B5NwPREVmaHSSr9DBt2DbpFOigXKD22oSjKds9P9eHZFbp96Id5rd8wRY7ZbMwapmqFMTiuau0jiwebpbZ/+kxA07wExmngiKIPM2MhYi81WPu4GnWQoSC1zALy/9btd+GH69kWgjkzmiBfrKLfsyZR3MZGyEnOIywgI8kbUTsNR5Okq+GcGE7oVFRldVecGfRUYA6DuwLIr4Gf0GLVvBHDCYbbuGkBICE5RCR8jkFIozaCQZR61Q/5z4XnfbGCSLarkBuTPLARGQpUYoRXRUTrBAskMsUmAedvD8Guv58WzQ9JcH1aYCw X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2019 06:43:11.8749 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9769c705-54d7-4ec0-3a43-08d757844615 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1983 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Dwl4JXh3gudDNqqnWSO4qmhHyZFD7hivyUxQxR0plGY=; b=qAJ9pAUPPZGyS6WwxCPJincnvsW7AubD4Iib93fcAyAI7tFhmd5zFdT0g2Xc04me9EVY+E/naL+I2OAzzRHVm0NRN6zfJT8zGObGLUMlO9ao3Zw1FqXZIa/cjMCbZeidLTYdoEEJDtqn6CIjZHIDz9n8DX1fWFgFYzNaBrpz3L8= X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Dwl4JXh3gudDNqqnWSO4qmhHyZFD7hivyUxQxR0plGY=; b=qAJ9pAUPPZGyS6WwxCPJincnvsW7AubD4Iib93fcAyAI7tFhmd5zFdT0g2Xc04me9EVY+E/naL+I2OAzzRHVm0NRN6zfJT8zGObGLUMlO9ao3Zw1FqXZIa/cjMCbZeidLTYdoEEJDtqn6CIjZHIDz9n8DX1fWFgFYzNaBrpz3L8= X-Mailman-Original-Authentication-Results: spf=fail (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.freedesktop.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.freedesktop.org; dmarc=none action=none header.from=arm.com; X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nd , Ayan Halder , "Oscar Zhang \(Arm Technology China\)" , "Tiannan Zhu \(Arm Technology China\)" , Mihail Atanassov , "Jonathan Chai \(Arm Technology China\)" , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "Julien Yin \(Arm Technology China\)" , "Channing Chen \(Arm Technology China\)" , "james qian wang \(Arm Technology China\)" , "Yiqi Kang \(Arm Technology China\)" , "Thomas Sun \(Arm Technology China\)" , "Lowry Li \(Arm Technology China\)" , Ben Davis Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This function is used to convert drm color lut to komeda HW required curve coeffs values. Signed-off-by: james qian wang (Arm Technology China) Reviewed-by: Mihail Atanassov --- .../arm/display/komeda/komeda_color_mgmt.c | 52 +++++++++++++++++++ .../arm/display/komeda/komeda_color_mgmt.h | 9 +++- 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c index 9d14a92dbb17..c180ce70c26c 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c @@ -65,3 +65,55 @@ const s32 *komeda_select_yuv2rgb_coeffs(u32 color_encoding, u32 color_range) return coeffs; } + +struct gamma_curve_sector { + u32 boundary_start; + u32 num_of_segments; + u32 segment_width; +}; + +struct gamma_curve_segment { + u32 start; + u32 end; +}; + +static struct gamma_curve_sector sector_tbl[] = { + { 0, 4, 4 }, + { 16, 4, 4 }, + { 32, 4, 8 }, + { 64, 4, 16 }, + { 128, 4, 32 }, + { 256, 4, 64 }, + { 512, 16, 32 }, + { 1024, 24, 128 }, +}; + +static void +drm_lut_to_coeffs(struct drm_property_blob *lut_blob, u32 *coeffs, + struct gamma_curve_sector *sector_tbl, u32 num_sectors) +{ + struct drm_color_lut *lut; + u32 i, j, in, num = 0; + + if (!lut_blob) + return; + + lut = lut_blob->data; + + for (i = 0; i < num_sectors; i++) { + for (j = 0; j < sector_tbl[i].num_of_segments; j++) { + in = sector_tbl[i].boundary_start + + j * sector_tbl[i].segment_width; + + coeffs[num++] = drm_color_lut_extract(lut[in].red, + KOMEDA_COLOR_PRECISION); + } + } + + coeffs[num] = BIT(KOMEDA_COLOR_PRECISION); +} + +void drm_lut_to_fgamma_coeffs(struct drm_property_blob *lut_blob, u32 *coeffs) +{ + drm_lut_to_coeffs(lut_blob, coeffs, sector_tbl, ARRAY_SIZE(sector_tbl)); +} diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h index a2df218f58e7..08ab69281648 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h +++ b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h @@ -11,7 +11,14 @@ #include #define KOMEDA_N_YUV2RGB_COEFFS 12 +#define KOMEDA_N_RGB2YUV_COEFFS 12 +#define KOMEDA_COLOR_PRECISION 12 +#define KOMEDA_N_GAMMA_COEFFS 65 +#define KOMEDA_COLOR_LUT_SIZE BIT(KOMEDA_COLOR_PRECISION) +#define KOMEDA_N_CTM_COEFFS 9 + +void drm_lut_to_fgamma_coeffs(struct drm_property_blob *lut_blob, u32 *coeffs); const s32 *komeda_select_yuv2rgb_coeffs(u32 color_encoding, u32 color_range); -#endif +#endif /*_KOMEDA_COLOR_MGMT_H_*/ From patchwork Wed Oct 23 06:43:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Qian Wang X-Patchwork-Id: 11205755 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EC0C013B1 for ; Wed, 23 Oct 2019 06:43:26 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id D38A921906 for ; Wed, 23 Oct 2019 06:43:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D38A921906 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1DDCD6E961; Wed, 23 Oct 2019 06:43:26 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00065.outbound.protection.outlook.com [40.107.0.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id BE6296E961 for ; Wed, 23 Oct 2019 06:43:23 +0000 (UTC) Received: from HE1PR08CA0077.eurprd08.prod.outlook.com (2603:10a6:7:2a::48) by AM6PR08MB4344.eurprd08.prod.outlook.com (2603:10a6:20b:74::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.21; Wed, 23 Oct 2019 06:43:21 +0000 Received: from DB5EUR03FT003.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::209) by HE1PR08CA0077.outlook.office365.com (2603:10a6:7:2a::48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.20 via Frontend Transport; Wed, 23 Oct 2019 06:43:21 +0000 Received-SPF: Fail (protection.outlook.com: domain of arm.com does not designate 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT003.mail.protection.outlook.com (10.152.20.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2367.23 via Frontend Transport; Wed, 23 Oct 2019 06:43:21 +0000 Received: ("Tessian outbound 851a1162fca7:v33"); Wed, 23 Oct 2019 06:43:18 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 4494aeef9282698d X-CR-MTA-TID: 64aa7808 Received: from 2e476b2de862.2 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.4.56]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id FE1A581A-5A09-4C67-8FDA-8C8499CFE212.1; Wed, 23 Oct 2019 06:43:13 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-am5eur02lp2056.outbound.protection.outlook.com [104.47.4.56]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 2e476b2de862.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Wed, 23 Oct 2019 06:43:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UiZtsRu3tcDx8dK5yzP9uPS0G+mH/O6j84WSSzkHnDiUg5NqclMu8WlW3TiiXCkENq15hhESFDiwdQkVDwlfXPLNA7G4bLWW19xCYNMWMlg6Yo4of9M4xv5XMhlFMmiigr4IZ/6WNjKOP/R2ZawP/3x2NK8DN+PPpAauWbmWaNlTcN+il6H+T2INfHk+tHD1xWRzyvW4MXABJt8xn6FZad5e3UNIUEA3jFkjndJGKpNh2AEVruXAhNCEGeIAbBY7JBSX4TtYYmztHn21JM9pIPeFaAbNmJCto9zkvU6QxBTDQ2bVTwXR2WRcWKb4s51nrR4dAlPBiBvfQxHtNpHSuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UvaLJ9iCW/GukE6Q6/g2aWg+NqCkBH1FlUg88c+A1ko=; b=FJASo0QUBUX6blRfKu4BzP+Fd6gnuWwkoLa9aodzqXrPdmTwci3BYyEaB3cMnx14gEl7RP87XOtyqZlCUsuTzAlmX97eIL5RPYqy1spQNycHUN/ugSxZKYfMrYv6Z+U9L/0xLWzBNeF1s08oMZ89oRf76X9oSCw6T0XDgEgkSUmL8jywiZJOadShlZXFTgFTj3qxABAdA+XyvL9dBL6SoQF3/+GFUOZUkOhtqNdfCZ0E/ojNm37zurSaMJwNu3EqgQB500BWVuf5Acr5lUy8JtMMPo+eVEr2/zOS/9xhOqTP3OlVA9h2rybQIxkONM5OPnA/vi/v8+X6fF/W/i5D6w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Received: from VE1PR08MB5006.eurprd08.prod.outlook.com (10.255.159.31) by VE1PR08MB5198.eurprd08.prod.outlook.com (20.179.31.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.20; Wed, 23 Oct 2019 06:43:10 +0000 Received: from VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::40ed:7ed3:90cf:ece5]) by VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::40ed:7ed3:90cf:ece5%3]) with mapi id 15.20.2367.022; Wed, 23 Oct 2019 06:43:10 +0000 From: "james qian wang (Arm Technology China)" To: Liviu Dudau , "airlied@linux.ie" , Brian Starkey , "maarten.lankhorst@linux.intel.com" , "sean@poorly.run" , "imirkin@alum.mit.edu" Subject: [PATCH v7 3/4] drm/komeda: Add drm_ctm_to_coeffs() Thread-Topic: [PATCH v7 3/4] drm/komeda: Add drm_ctm_to_coeffs() Thread-Index: AQHViW0iknm0f8sRVESKRsTsViA0sA== Date: Wed, 23 Oct 2019 06:43:09 +0000 Message-ID: <20191023064226.10969-4-james.qian.wang@arm.com> References: <20191023064226.10969-1-james.qian.wang@arm.com> In-Reply-To: <20191023064226.10969-1-james.qian.wang@arm.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [113.29.88.7] x-clientproxiedby: HK2PR02CA0184.apcprd02.prod.outlook.com (2603:1096:201:21::20) To VE1PR08MB5006.eurprd08.prod.outlook.com (2603:10a6:803:113::31) Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 727c534b-1699-444f-59ab-08d757844ba1 X-MS-TrafficTypeDiagnostic: VE1PR08MB5198:|VE1PR08MB5198:|AM6PR08MB4344: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:3513;OLM:3513; x-forefront-prvs: 019919A9E4 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(376002)(39860400002)(396003)(366004)(136003)(346002)(199004)(189003)(66446008)(64756008)(66556008)(2501003)(2906002)(66946007)(66476007)(3846002)(36756003)(6116002)(256004)(14454004)(8676002)(486006)(478600001)(25786009)(50226002)(81156014)(2171002)(8936002)(81166006)(4326008)(103116003)(386003)(110136005)(446003)(305945005)(6506007)(316002)(66066001)(102836004)(76176011)(186003)(2616005)(476003)(6512007)(1076003)(5660300002)(99286004)(54906003)(11346002)(52116002)(71200400001)(71190400001)(2201001)(86362001)(6486002)(6436002)(26005)(7736002)(55236004); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB5198; H:VE1PR08MB5006.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: QMBIruKCqS5TdqYpA45FL7Suk1UelazrwPyXfao7utvo0ex1kG9Sm/Mj7PMnYicaH8iPVV0lbqk3H4+95PQupZy0o8ZWl4lUC/SAAoFwU+OZO3G8NB6ickRor633nCiG1Tpc9L24voCLOOa6bDIbZeUoksDfDyeU96sNyhPD3MeGQSmrZfvC03HCEV8tjdapKCyz+nRrHcnZjKrNevkadS959v6IZv8nsFTDAnwDMjKko8xrlGJ0vmo6FctCrK6mwDH+nZqid4Pf7yQ2Q6tySU/9C2QPUFUbhYOVANKIsS4Otspz6hnKPxPke8Z06VAMuCzpVBwus9yOjjO+lf8+E2Iawo5RSqf8JlVq98FR3ze81tz8ns2C/M0QserRKQxRGD+EQAXDDn839dpzH2gqTwoAU11MYWva1CddD+jF5pQDBdanX0O9dtH2K65DOil4 MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5198 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT003.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; IPV:CAL; SCL:-1; CTRY:IE; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(376002)(346002)(396003)(39860400002)(136003)(1110001)(339900001)(189003)(199004)(2906002)(26826003)(54906003)(336012)(5660300002)(23756003)(22756006)(6512007)(356004)(50466002)(2171002)(110136005)(102836004)(103116003)(1076003)(36756003)(26005)(478600001)(3846002)(6116002)(2501003)(316002)(25786009)(105606002)(486006)(81166006)(7736002)(14454004)(305945005)(386003)(70206006)(4326008)(47776003)(76130400001)(126002)(186003)(70586007)(6486002)(66066001)(8746002)(50226002)(446003)(2616005)(86362001)(11346002)(99286004)(2201001)(6506007)(8676002)(8936002)(476003)(76176011)(81156014); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR08MB4344; H:64aa7808-outbound-1.mta.getcheckrecipient.com; FPR:; SPF:Fail; LANG:en; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; MX:1; A:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: 5700c133-2ddb-4f50-a579-08d7578444b3 NoDisclaimer: True X-Forefront-PRVS: 019919A9E4 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eMebvdPcpjVZCMmCESyJGFUr9wzpfvev0sVPZUXDBbS6IYyBIiDpK6UWRJWeDyOXW0CErP4xXs6CJMENybT/aUi5K7riV5/m6BaEXsXzo3zqPMSvT5K13HFjZ+Yg38SH5cbxvKqZ+cM7Eb/qGwTOkKB78NsTOY00h49YOMnZ/Z3ozRFdSJAdJaRXbcw3iy5CJiXmYDh4u/F+WBfy0uOpaMUzekqKkeF6GV9JcByM4aN6XWc6hARRhcxABwApYTr9a29K6lKHFHwyERIRnEZQsmYrZlbPty3cpWzgzAjslxZUCNpRYLhyGCq45eU+PijLQqZkHMdio13n9Vu9819qtn1/hlT0lu8QJxnG9Ad2Pk+omEPUvC00KEUia1Y1yH6Tr1dRGYI5rDetwSEJL4+DhGNpiyrqREUjfaWxop4OSRL1+hiPXRoU02isRi0vlOdX X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2019 06:43:21.1158 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 727c534b-1699-444f-59ab-08d757844ba1 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4344 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UvaLJ9iCW/GukE6Q6/g2aWg+NqCkBH1FlUg88c+A1ko=; b=XqXguAghUKa8rRi1mGKxVIGYiWw6fOHuetMEfxaMemJjthQxwyh+iy+gPq3jaU69ZqKQuotVs3HMqcALucdRhXOFydcqRbS/9YU4c42s3uXptMy/qbeqCADL44ktgvaZZXSK+vJvqAdkX2XIwWEbDrmdi68ji7nwFO7+EjmUxfw= X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UvaLJ9iCW/GukE6Q6/g2aWg+NqCkBH1FlUg88c+A1ko=; b=XqXguAghUKa8rRi1mGKxVIGYiWw6fOHuetMEfxaMemJjthQxwyh+iy+gPq3jaU69ZqKQuotVs3HMqcALucdRhXOFydcqRbS/9YU4c42s3uXptMy/qbeqCADL44ktgvaZZXSK+vJvqAdkX2XIwWEbDrmdi68ji7nwFO7+EjmUxfw= X-Mailman-Original-Authentication-Results: spf=fail (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.freedesktop.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.freedesktop.org; dmarc=none action=none header.from=arm.com; X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nd , Ayan Halder , "Oscar Zhang \(Arm Technology China\)" , "Tiannan Zhu \(Arm Technology China\)" , Mihail Atanassov , "Jonathan Chai \(Arm Technology China\)" , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "Julien Yin \(Arm Technology China\)" , "Channing Chen \(Arm Technology China\)" , "james qian wang \(Arm Technology China\)" , "Yiqi Kang \(Arm Technology China\)" , "Thomas Sun \(Arm Technology China\)" , "Lowry Li \(Arm Technology China\)" , Ben Davis Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This function is for converting drm_color_ctm matrix to komeda hardware required required Q2.12 2's complement CSC matrix. v2: Move the fixpoint conversion function s31_32_to_q2_12() to drm core as a shared helper. Signed-off-by: james qian wang (Arm Technology China) Reviewed-by: Mihail Atanassov --- .../gpu/drm/arm/display/komeda/komeda_color_mgmt.c | 14 ++++++++++++++ .../gpu/drm/arm/display/komeda/komeda_color_mgmt.h | 1 + 2 files changed, 15 insertions(+) diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c index c180ce70c26c..d8e449e6ebda 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c @@ -117,3 +117,17 @@ void drm_lut_to_fgamma_coeffs(struct drm_property_blob *lut_blob, u32 *coeffs) { drm_lut_to_coeffs(lut_blob, coeffs, sector_tbl, ARRAY_SIZE(sector_tbl)); } + +void drm_ctm_to_coeffs(struct drm_property_blob *ctm_blob, u32 *coeffs) +{ + struct drm_color_ctm *ctm; + u32 i; + + if (!ctm_blob) + return; + + ctm = ctm_blob->data; + + for (i = 0; i < KOMEDA_N_CTM_COEFFS; i++) + coeffs[i] = drm_color_ctm_s31_32_to_qm_n(ctm->matrix[i], 3, 12); +} diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h index 08ab69281648..2f4668466112 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h +++ b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h @@ -18,6 +18,7 @@ #define KOMEDA_N_CTM_COEFFS 9 void drm_lut_to_fgamma_coeffs(struct drm_property_blob *lut_blob, u32 *coeffs); +void drm_ctm_to_coeffs(struct drm_property_blob *ctm_blob, u32 *coeffs); const s32 *komeda_select_yuv2rgb_coeffs(u32 color_encoding, u32 color_range); From patchwork Wed Oct 23 06:43:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Qian Wang X-Patchwork-Id: 11205757 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 39DF9139A for ; Wed, 23 Oct 2019 06:43:33 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 1CAD221906 for ; Wed, 23 Oct 2019 06:43:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1CAD221906 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 18C386E963; Wed, 23 Oct 2019 06:43:32 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-he1eur02on0621.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe05::621]) by gabe.freedesktop.org (Postfix) with ESMTPS id D060D6E963 for ; Wed, 23 Oct 2019 06:43:30 +0000 (UTC) Received: from DB7PR08CA0017.eurprd08.prod.outlook.com (2603:10a6:5:16::30) by VE1PR08MB4895.eurprd08.prod.outlook.com (2603:10a6:802:ac::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.21; Wed, 23 Oct 2019 06:43:27 +0000 Received: from VE1EUR03FT023.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::209) by DB7PR08CA0017.outlook.office365.com (2603:10a6:5:16::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2367.24 via Frontend Transport; Wed, 23 Oct 2019 06:43:27 +0000 Received-SPF: Fail (protection.outlook.com: domain of arm.com does not designate 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT023.mail.protection.outlook.com (10.152.18.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2367.23 via Frontend Transport; Wed, 23 Oct 2019 06:43:26 +0000 Received: ("Tessian outbound 6481c7fa5a3c:v33"); Wed, 23 Oct 2019 06:43:23 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 694ce0f428c59884 X-CR-MTA-TID: 64aa7808 Received: from 7a56dd4b3f30.2 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.8.51]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id D311E4CE-2C2D-4326-9E18-76F81C9B48E4.1; Wed, 23 Oct 2019 06:43:18 +0000 Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-am5eur03lp2051.outbound.protection.outlook.com [104.47.8.51]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 7a56dd4b3f30.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 23 Oct 2019 06:43:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rh6O9JCL0bFJYusmLKOQntTNngI2cXSQUmBnoAHcKa3Al2j28pRAhmOQZ2UzntBGnHszU2mUUtx5xBrNA/J8qh1vWiTL/TZnUPxBf0Xo3ZOm5bG/USSbX4Ib7V6LrwVHzwK6E1IQDD0KXVMqRYIttuyxO2K3+SQbyCbrBgG2WRMwPtwQzIAceDu7Za0vZD03TwR/IG/3jylwKgNL2/zAsFBCoRIyKOpBrquYbTyheRFl5KNZuTtl0DnA5G2MXkI/BsX15tF5DXeINUz4L1WE/cez0QQywmI9VO+DYriW2DYt7aBrmRU7v3Awvjc6xmIEA2dz/mIg8O/BQn5ieutJ9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9TQq3bHNRrYQiNPP2nRVJpod47h6p3GxLvGsKKnTnHo=; b=MG8PsjMd2TzJntkTevOXT36eUd0sHiyS5NnrKmhY1R1EErMKtEIF3Hct2blolrZm884Z+8n+A5QY/wXRLNURoRtDDDjeCthEdhA0aTMNFdJVlK+7n3JuN2DYm7Xpws6T2H5X2Nz+rTzVpTXFULG8Hl/s9amP9CGbWQrXAu9RH4bXBkJwgc44rWh2QXGaWEXfP/boxHWkp6blSQ/LF8+7etB5YQrDlUi4z8qc8Z8fIOAmjfHeAstpQn0gqB9XqssdFzo85GQ3/FkTSaq/Ni5v14INPnBvIPxw40tPO0uwYrys/dsNcxcOQjkGdHMfvGrAlb6+mn8GuNRZ//d3Fwke1A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Received: from VE1PR08MB5006.eurprd08.prod.outlook.com (10.255.159.31) by VE1PR08MB4672.eurprd08.prod.outlook.com (10.255.112.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.22; Wed, 23 Oct 2019 06:43:17 +0000 Received: from VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::40ed:7ed3:90cf:ece5]) by VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::40ed:7ed3:90cf:ece5%3]) with mapi id 15.20.2367.022; Wed, 23 Oct 2019 06:43:17 +0000 From: "james qian wang (Arm Technology China)" To: Liviu Dudau , "airlied@linux.ie" , Brian Starkey , "maarten.lankhorst@linux.intel.com" , "sean@poorly.run" , "imirkin@alum.mit.edu" Subject: [PATCH v7 4/4] drm/komeda: Adds gamma and color-transform support for DOU-IPS Thread-Topic: [PATCH v7 4/4] drm/komeda: Adds gamma and color-transform support for DOU-IPS Thread-Index: AQHViW0mF05EqmyI+keSzxdB9PsPEA== Date: Wed, 23 Oct 2019 06:43:16 +0000 Message-ID: <20191023064226.10969-5-james.qian.wang@arm.com> References: <20191023064226.10969-1-james.qian.wang@arm.com> In-Reply-To: <20191023064226.10969-1-james.qian.wang@arm.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [113.29.88.7] x-clientproxiedby: HK2PR02CA0184.apcprd02.prod.outlook.com (2603:1096:201:21::20) To VE1PR08MB5006.eurprd08.prod.outlook.com (2603:10a6:803:113::31) Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: a4d36d65-dad0-472e-f57a-08d757844f02 X-MS-TrafficTypeDiagnostic: VE1PR08MB4672:|VE1PR08MB4672:|VE1PR08MB4895: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:2582;OLM:2582; x-forefront-prvs: 019919A9E4 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(396003)(136003)(39860400002)(366004)(376002)(346002)(189003)(199004)(7736002)(25786009)(2906002)(386003)(71200400001)(4326008)(36756003)(305945005)(6506007)(66066001)(2201001)(71190400001)(102836004)(5660300002)(26005)(478600001)(52116002)(14444005)(55236004)(316002)(86362001)(186003)(6116002)(76176011)(3846002)(256004)(2171002)(66446008)(66946007)(103116003)(64756008)(6512007)(1076003)(66556008)(50226002)(66476007)(476003)(6436002)(8936002)(446003)(2501003)(11346002)(2616005)(6486002)(14454004)(486006)(54906003)(99286004)(81166006)(8676002)(81156014)(110136005); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB4672; H:VE1PR08MB5006.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: fr4sq5cyeDTqUyanruBlqcfjFbzp+rl5EPRQIcJtfKkD3L9k8Jy2fHsHAvN36ut3U8Nhf2SDhbDOTJCpqHOkkuY4u7exGsNS/J6zbGfUMXZfM/XNxrzP2eUBy+4QcyvaznW6IgFFJcNU3pAGQqZZsy4QwBl09gqML31+eeroGQQDDsNabuzQhFYpN09fT6i+GdI0LtS6VagiAUcx8mnx7Goaa/qdS9Zrb5w3N5WkQrmAxSYIwRm+BjouO55tZXYRBPxUInY3hSmjg1FDQg3Ilx2FYV145I7ulaP0kOBbyvURA68EdN7MDIpKpYnavuz18eUcTWHOKgHOuVxBWRqF1DZjh2Qbke/mXhuWAK8UWYKdMlXiO/qdpCP4uvfqUOB42ZGnLbZAjhPrCY7RNpgkwdM9NEmxUfo3bFT317LUvE4= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4672 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT023.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; IPV:CAL; SCL:-1; CTRY:IE; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(396003)(136003)(376002)(346002)(39860400002)(1110001)(339900001)(199004)(189003)(66066001)(8676002)(25786009)(47776003)(3846002)(2501003)(110136005)(316002)(356004)(50226002)(81166006)(6116002)(36756003)(5660300002)(81156014)(8936002)(8746002)(2906002)(2171002)(14444005)(22756006)(1076003)(26005)(186003)(105606002)(70206006)(103116003)(476003)(86362001)(102836004)(2201001)(76130400001)(26826003)(7736002)(4326008)(76176011)(336012)(386003)(70586007)(486006)(6512007)(23756003)(36906005)(14454004)(6506007)(54906003)(305945005)(478600001)(99286004)(126002)(2616005)(11346002)(446003)(50466002)(6486002); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB4895; H:64aa7808-outbound-1.mta.getcheckrecipient.com; FPR:; SPF:Fail; LANG:en; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; A:1; MX:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: fdc9e2a7-bc07-41eb-ac1c-08d7578448e9 NoDisclaimer: True X-Forefront-PRVS: 019919A9E4 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LBLoUpDTiaabnc7dUFYWDcRQHf1B6SXe6DZgCmXn5SpvWTZ8UqwmLlDblj9PY0YI53t+DztQwJ6shI/FQdEY6yAdBCMXmRUULJfBMYDQya34yULX7ntWSQarkvDX7BRSDwROpzdSwc/XPtlQWEe2wSjXEJN6NsOD0n7CA2EZL3zm2xBzaG9TEh+6eW1bp6zzLQ+LGchdjFRnbPna5loNJiHvvvtQLnzN2hDIVQ1buK7uQPQG2aDQyF952hZ3WPzXwXFw2Dmq7/MCjVxqGDlPutpebpkzWkExNsCxuUCx4qD5NWA7UUG1YDfUdAxq21PpAdHisoDI2G2vANBTWqXj9dXXkWxZbAQEoFGzIm9fGU7LfxxIPrvI64pbAlxUJa8jWs0laKOxKjm8IL7/EGOpWU+D3ggZyNTKYiz45wV6l/MRRxzqIK82BO0pQgsstP3t X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2019 06:43:26.8027 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a4d36d65-dad0-472e-f57a-08d757844f02 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4895 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9TQq3bHNRrYQiNPP2nRVJpod47h6p3GxLvGsKKnTnHo=; b=u0Vxxxn19sEdzZ575YT13vQ6Fo+s4PIqdft6DWrL65FMiFFGAG+SnGMPqcByiQIvuobVl63i9HDFfDpy/BVMdG/d8L5Oz9L2v/GnvHAR/YX0xV7yLfadxr/P3/CxKLmBM7yq1IfmF6JxUfhlXVVKPIR+WV/rRBwBjf5+RVCL8v8= X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9TQq3bHNRrYQiNPP2nRVJpod47h6p3GxLvGsKKnTnHo=; b=u0Vxxxn19sEdzZ575YT13vQ6Fo+s4PIqdft6DWrL65FMiFFGAG+SnGMPqcByiQIvuobVl63i9HDFfDpy/BVMdG/d8L5Oz9L2v/GnvHAR/YX0xV7yLfadxr/P3/CxKLmBM7yq1IfmF6JxUfhlXVVKPIR+WV/rRBwBjf5+RVCL8v8= X-Mailman-Original-Authentication-Results: spf=fail (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.freedesktop.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.freedesktop.org; dmarc=none action=none header.from=arm.com; X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nd , Ayan Halder , "Oscar Zhang \(Arm Technology China\)" , "Tiannan Zhu \(Arm Technology China\)" , Mihail Atanassov , "Jonathan Chai \(Arm Technology China\)" , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "Julien Yin \(Arm Technology China\)" , "Channing Chen \(Arm Technology China\)" , "Yiqi Kang \(Arm Technology China\)" , "Thomas Sun \(Arm Technology China\)" , "Lowry Li \(Arm Technology China\)" , Ben Davis Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: "Lowry Li (Arm Technology China)" Adds gamma and color-transform support for DOU-IPS. Adds two caps members fgamma_coeffs and ctm_coeffs to komeda_improc_state. If color management changed, set gamma and color-transform accordingly. v5: Rebase with drm-misc-next Signed-off-by: Lowry Li (Arm Technology China) Reviewed-by: Mihail Atanassov --- .../arm/display/komeda/d71/d71_component.c | 20 +++++++++++++++++++ .../gpu/drm/arm/display/komeda/komeda_crtc.c | 2 ++ .../drm/arm/display/komeda/komeda_pipeline.h | 3 +++ .../display/komeda/komeda_pipeline_state.c | 6 ++++++ 4 files changed, 31 insertions(+) diff --git a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c index f0ba26e282c3..b6517c46e670 100644 --- a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c +++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c @@ -1044,7 +1044,9 @@ static int d71_merger_init(struct d71_dev *d71, static void d71_improc_update(struct komeda_component *c, struct komeda_component_state *state) { + struct drm_crtc_state *crtc_st = state->crtc->state; struct komeda_improc_state *st = to_improc_st(state); + struct d71_pipeline *pipe = to_d71_pipeline(c->pipeline); u32 __iomem *reg = c->reg; u32 index, mask = 0, ctrl = 0; @@ -1055,6 +1057,24 @@ static void d71_improc_update(struct komeda_component *c, malidp_write32(reg, BLK_SIZE, HV_SIZE(st->hsize, st->vsize)); malidp_write32(reg, IPS_DEPTH, st->color_depth); + if (crtc_st->color_mgmt_changed) { + mask |= IPS_CTRL_FT | IPS_CTRL_RGB; + + if (crtc_st->gamma_lut) { + malidp_write_group(pipe->dou_ft_coeff_addr, FT_COEFF0, + KOMEDA_N_GAMMA_COEFFS, + st->fgamma_coeffs); + ctrl |= IPS_CTRL_FT; /* enable gamma */ + } + + if (crtc_st->ctm) { + malidp_write_group(reg, IPS_RGB_RGB_COEFF0, + KOMEDA_N_CTM_COEFFS, + st->ctm_coeffs); + ctrl |= IPS_CTRL_RGB; /* enable gamut */ + } + } + mask |= IPS_CTRL_YUV | IPS_CTRL_CHD422 | IPS_CTRL_CHD420; /* config color format */ diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c index 252015210fbc..1c452ea75999 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c @@ -617,6 +617,8 @@ static int komeda_crtc_add(struct komeda_kms_dev *kms, crtc->port = kcrtc->master->of_output_port; + drm_crtc_enable_color_mgmt(crtc, 0, true, KOMEDA_COLOR_LUT_SIZE); + return err; } diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h index bd6ca7c87037..ac8725e24853 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h @@ -11,6 +11,7 @@ #include #include #include "malidp_utils.h" +#include "komeda_color_mgmt.h" #define KOMEDA_MAX_PIPELINES 2 #define KOMEDA_PIPELINE_MAX_LAYERS 4 @@ -327,6 +328,8 @@ struct komeda_improc_state { struct komeda_component_state base; u8 color_format, color_depth; u16 hsize, vsize; + u32 fgamma_coeffs[KOMEDA_N_GAMMA_COEFFS]; + u32 ctm_coeffs[KOMEDA_N_CTM_COEFFS]; }; /* display timing controller */ diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c index 42bdc63dcffa..0930234abb9d 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c @@ -802,6 +802,12 @@ komeda_improc_validate(struct komeda_improc *improc, st->color_format = BIT(__ffs(avail_formats)); } + if (kcrtc_st->base.color_mgmt_changed) { + drm_lut_to_fgamma_coeffs(kcrtc_st->base.gamma_lut, + st->fgamma_coeffs); + drm_ctm_to_coeffs(kcrtc_st->base.ctm, st->ctm_coeffs); + } + komeda_component_add_input(&st->base, &dflow->input, 0); komeda_component_set_output(&dflow->input, &improc->base, 0);