From patchwork Tue Nov 12 10:40:24 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: 11239041 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 B64A11515 for ; Tue, 12 Nov 2019 10:40:40 +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 9DACC21783 for ; Tue, 12 Nov 2019 10:40:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9DACC21783 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 EB2976EB03; Tue, 12 Nov 2019 10:40:39 +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-he1eur02on060d.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe05::60d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6B0066EB03 for ; Tue, 12 Nov 2019 10:40:37 +0000 (UTC) Received: from VI1PR0801CA0068.eurprd08.prod.outlook.com (2603:10a6:800:7d::12) by AM5PR0802MB2402.eurprd08.prod.outlook.com (2603:10a6:203:a1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.22; Tue, 12 Nov 2019 10:40:34 +0000 Received: from AM5EUR03FT029.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::207) by VI1PR0801CA0068.outlook.office365.com (2603:10a6:800:7d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2430.20 via Frontend Transport; Tue, 12 Nov 2019 10:40:34 +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 AM5EUR03FT029.mail.protection.outlook.com (10.152.16.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2430.21 via Frontend Transport; Tue, 12 Nov 2019 10:40:34 +0000 Received: ("Tessian outbound 0939a6bab6b1:v33"); Tue, 12 Nov 2019 10:40:31 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 0223c4c3e8757ecc X-CR-MTA-TID: 64aa7808 Received: from de65cc25b090.2 (cr-mta-lb-1.cr-mta-net [104.47.10.51]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id F759FE6A-C118-4ADD-B299-F8CF3F1BE2B2.1; Tue, 12 Nov 2019 10:40:26 +0000 Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-db5eur03lp2051.outbound.protection.outlook.com [104.47.10.51]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id de65cc25b090.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Tue, 12 Nov 2019 10:40:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oLzOZrLe+GNCkmAUFv7kFffBcSZ9epXDbttamNCXgD7oDrmVKsTzsfWgD6pxAdoT4gScY311G0o5oAgJHPrNnMxQXRQeE74lRkRPOuuRe/u1lF1agKeFRpSb/SVNX5ECj0hJbiqDSGVFz+zc7ZQnBDt9WLJEu6xF9fqzZlRfkgtsOfB3aJU7fmiE7QflcES+IZ1RSx3EVtolR7F9V1cdOjrcf4BuFtbybn9jCYBsUsSixhSN3sFwAR+PmTQF6THmge3vHYbHSZFdApqw6YYlWWPww1+Kmik1dJ74g3BKlilMePr1HxMxJZ4autZC0F1B7N57cJ7p1VezH9Ht8BwiYA== 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=5xvTegslMD5L2ZURhngFfxlrPcslIxpmCTDULZVxcYM=; b=KqFg0vtulZoKcY3rAUtPXwRLL8t6VsRXhphh1OFG+6PyhUMWmc7LmgHMGyeItCiMs80/EvbUoQiOYBQe0f4GOEQBthhU/23X1jqrRujJ6gxM3+Uj7SoCAQJc26bA6SK8IXeADu/QMQVyQ6TUjDZbaHXaKW2aHELcEYgg1n8zDcLA1SVF/wqbLtsUvs4NoNi9YFPeWdnoeEf58/hRdD9CUINtJVWEhdn18P/ZJq0vA+Q0zYNdt1rZKixUReuwse2c0U9y6hX88Oxi99W/WBK7vpFQKiLkGY7C2r0i4avBVlXoXFE0OVgAeQiKEEmzykp1Oo6/mTi1uq+9D3fFdJmhWA== 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 AM0PR08MB4995.eurprd08.prod.outlook.com (10.255.30.207) by AM0PR08MB4082.eurprd08.prod.outlook.com (20.178.119.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.23; Tue, 12 Nov 2019 10:40:24 +0000 Received: from AM0PR08MB4995.eurprd08.prod.outlook.com ([fe80::3c0c:3112:ccbf:13d0]) by AM0PR08MB4995.eurprd08.prod.outlook.com ([fe80::3c0c:3112:ccbf:13d0%6]) with mapi id 15.20.2430.027; Tue, 12 Nov 2019 10:40:24 +0000 From: "james qian wang (Arm Technology China)" To: Liviu Dudau , "airlied@linux.ie" , Brian Starkey , "maarten.lankhorst@linux.intel.com" , "sean@poorly.run" , Mihail Atanassov , "imirkin@alum.mit.edu" Subject: [PATCH v9 1/4] drm: Add a new helper drm_color_ctm_s31_32_to_qm_n() Thread-Topic: [PATCH v9 1/4] drm: Add a new helper drm_color_ctm_s31_32_to_qm_n() Thread-Index: AQHVmUWWuw5SiCc2fkWBYrtItjbs1w== Date: Tue, 12 Nov 2019 10:40:24 +0000 Message-ID: <20191112103956.19074-2-james.qian.wang@arm.com> References: <20191112103956.19074-1-james.qian.wang@arm.com> In-Reply-To: <20191112103956.19074-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: HK0PR03CA0087.apcprd03.prod.outlook.com (2603:1096:203:72::27) To AM0PR08MB4995.eurprd08.prod.outlook.com (2603:10a6:208:162::15) 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: a17d7899-1e41-4200-cab4-08d7675cbf57 X-MS-TrafficTypeDiagnostic: AM0PR08MB4082:|AM0PR08MB4082:|AM5PR0802MB2402: 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: 021975AE46 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(376002)(366004)(346002)(396003)(136003)(39860400002)(199004)(189003)(86362001)(6512007)(478600001)(66066001)(54906003)(110136005)(316002)(5660300002)(6486002)(14454004)(2171002)(11346002)(446003)(2616005)(6436002)(25786009)(476003)(2201001)(5024004)(1076003)(6506007)(8936002)(386003)(99286004)(2906002)(4326008)(55236004)(102836004)(103116003)(256004)(66946007)(66556008)(66476007)(64756008)(66446008)(6116002)(3846002)(52116002)(26005)(81166006)(81156014)(8676002)(186003)(7736002)(486006)(71190400001)(71200400001)(36756003)(305945005)(76176011)(50226002)(2501003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR08MB4082; H:AM0PR08MB4995.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: ReJv4jvD7YQLbC0YnVJnn44xbYNi/jreBYFSKCUPDERxW6BYEVnTbfKfzuvIuwcOlQwa3WBAFr3tx/1jbCPU36cuQmE4qbQq4RYeGWlhC99Wd6ZH8w5rozz1xaBWsttThognlCVnN8fBlehCtj7ELL9JI+vkwvK+DNbVqUuuFlWnxd4/66HRw9aL16ahl9R6/oExbhJtP2oN8Ey6MEGBz5B/+CUDLPwnziKrhSb7CofYSxt+NLZVKH/ULXbtDqvgBsxKZx+WmdDTtDOWRyamxR9Y+Zy8ohEn1Jctrn7Smk8YXH+yBCUx4U2zNa+jnOd8vAKhVBkvi1G4n3SIsfnqOxPMNHJY4Kg8Ldyf6t2ZC7DarguxahpShWkhZQTZNWWxxAtC4tzWuUEHzs7UZubtbfR3MU9ePBdGeQJssqWq0cESobbWavLbE+JauN/IuOK5 Content-ID: MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4082 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT029.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)(396003)(39860400002)(376002)(1110001)(339900001)(189003)(199004)(103116003)(86362001)(26826003)(2201001)(478600001)(22756006)(6486002)(107886003)(81166006)(81156014)(8676002)(6512007)(105606002)(2171002)(4326008)(36756003)(186003)(14454004)(66066001)(47776003)(99286004)(70206006)(356004)(1076003)(70586007)(102836004)(6506007)(386003)(26005)(2906002)(2501003)(126002)(2616005)(11346002)(476003)(5660300002)(50226002)(446003)(486006)(5024004)(336012)(436003)(54906003)(8936002)(76130400001)(316002)(305945005)(7736002)(23676004)(2486003)(36906005)(25786009)(3846002)(76176011)(110136005)(50466002)(6116002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0802MB2402; 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: 8aa1d5c2-c8ce-41c6-da6a-08d7675cb94f NoDisclaimer: True X-Forefront-PRVS: 021975AE46 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4L4V1nW02LywWohksim4KOqOSrQvCF//Hvy+oEeNNUKV+mFLTxo2YSdaPMsUhDWW7RfZwtWEvDayvIi2Ilov2kCeJRc2YVOv7Z1QfLzgqu3BCR3RC96tJS13JgZ54ZQtREfB63M/YcucPDJzbbfDKLAs+6uHWK6ZwN5XjmJlvo96LvafQBGtspphou3kW3pK9Qq1e3WeMqVMIvGoI8nKgF4XDHawWv9zJhTLLF8gdG42i79ZVeybtOQkcSdsuwEvMy4WF17aLp6D2E6O3gDvHKemURoym7P5AkOXzn2yQ0B5j/kmh+lgitZaeR4bMT1U5VAvrhl06bqZMe7tn1ARVWPDM3M5BdmfdFrcgA7eAu7rdN0V+LIlcLU+XQRI29021faUVta3+N5cx3f99YzfpZBx/JfOpy1e6TsloNsUbCobkBUL6D02sdkpIyAa4os/ X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Nov 2019 10:40:34.0407 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a17d7899-1e41-4200-cab4-08d7675cbf57 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: AM5PR0802MB2402 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=5xvTegslMD5L2ZURhngFfxlrPcslIxpmCTDULZVxcYM=; b=ryJcvghUMnexM7ge7eE8VundpyqFzbWEbOk9bopnKiSpStzppcSqhMFC82RU5tTWDJkNeXTndiYw59OOvpAEnarwQ3dqoqET/EatuoTlLfyFwIm8bS1vJ06i68MfhFL6uc3w64x3wtlrClnrZKINUhQ7ynir1Bk+tar+9Jnv0pY= 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=5xvTegslMD5L2ZURhngFfxlrPcslIxpmCTDULZVxcYM=; b=ryJcvghUMnexM7ge7eE8VundpyqFzbWEbOk9bopnKiSpStzppcSqhMFC82RU5tTWDJkNeXTndiYw59OOvpAEnarwQ3dqoqET/EatuoTlLfyFwIm8bS1vJ06i68MfhFL6uc3w64x3wtlrClnrZKINUhQ7ynir1Bk+tar+9Jnv0pY= 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\)" , 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. V7: Address Mihail's comments. V8: Use type 'u32' to replace 'uint32_t' v9: Rebase Signed-off-by: james qian wang (Arm Technology China) Reviewed-by: Mihail Atanassov Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_color_mgmt.c | 35 ++++++++++++++++++++++++++++++++ include/drm/drm_color_mgmt.h | 1 + 2 files changed, 36 insertions(+) -- 2.20.1 diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c index 4ce5c6d8de99..9de10abc7a96 100644 --- a/drivers/gpu/drm/drm_color_mgmt.c +++ b/drivers/gpu/drm/drm_color_mgmt.c @@ -132,9 +132,44 @@ 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-1) 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 + */ +u64 drm_color_ctm_s31_32_to_qm_n(u64 user_input, u32 m, u32 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 + * * @degamma_lut_size: the size of the degamma lut (before CSC) * @has_ctm: whether to attach ctm_property for CSC matrix * @gamma_lut_size: the size of the gamma lut (after CSC) diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h index d1c662d92ab7..997a42ab29f5 100644 --- a/include/drm/drm_color_mgmt.h +++ b/include/drm/drm_color_mgmt.h @@ -30,6 +30,7 @@ struct drm_crtc; struct drm_plane; uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision); +u64 drm_color_ctm_s31_32_to_qm_n(u64 user_input, u32 m, u32 n); void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc, uint degamma_lut_size, From patchwork Tue Nov 12 10:40:31 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: 11239043 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 1C289139A for ; Tue, 12 Nov 2019 10:40:48 +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 F385E206BA for ; Tue, 12 Nov 2019 10:40:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F385E206BA 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 3378A6EB04; Tue, 12 Nov 2019 10:40:47 +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-eopbgr20046.outbound.protection.outlook.com [40.107.2.46]) by gabe.freedesktop.org (Postfix) with ESMTPS id 090D06EB04 for ; Tue, 12 Nov 2019 10:40:46 +0000 (UTC) Received: from VI1PR0802CA0033.eurprd08.prod.outlook.com (2603:10a6:800:a9::19) by AM0PR08MB3634.eurprd08.prod.outlook.com (2603:10a6:208:d6::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.22; Tue, 12 Nov 2019 10:40:42 +0000 Received: from AM5EUR03FT019.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::205) by VI1PR0802CA0033.outlook.office365.com (2603:10a6:800:a9::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2430.23 via Frontend Transport; Tue, 12 Nov 2019 10:40:42 +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 AM5EUR03FT019.mail.protection.outlook.com (10.152.16.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2430.21 via Frontend Transport; Tue, 12 Nov 2019 10:40:42 +0000 Received: ("Tessian outbound 3fba803f6da3:v33"); Tue, 12 Nov 2019 10:40:38 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: b9988feed9b57917 X-CR-MTA-TID: 64aa7808 Received: from eebcda1cfdc6.2 (cr-mta-lb-1.cr-mta-net [104.47.10.54]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 85B22660-2E5E-4997-BD9A-D9C91F06BD67.1; Tue, 12 Nov 2019 10:40:33 +0000 Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-db5eur03lp2054.outbound.protection.outlook.com [104.47.10.54]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id eebcda1cfdc6.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Tue, 12 Nov 2019 10:40:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TBg0CEXLzW7JPTajW6rvaUgGk9barZtq1prZG+3b4ZEREFeTJYay85kDmrfgr+iuIL0CJX7mv1vczfhiHlfV2mxNCXJ+rQvyJ6trHdQZm78AmDhgZbVG67k3vWaG2IFT3PvVsl5wQ9bJge0448dDWzgssM5x3ThR7XiL+M4t8XetufgTQ6SdZqDf3bdfMZEi537NBfGRr2LFBrY5CHI+1UWemixCooJdJAkKOOy2tmhcgZCNYKjGBkx7mwOHrMju/v08emaHA6O/PpjmHF0XsdDeIOQjnfXNIzv6BGteA4+vvF0rLX1W7cNHemhhRKo0V5EnGOvGo9tEhBbZCS31aQ== 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=evPEEmoEwP5tfRzEvXOhFboOHEYcGaKwO9Y6SBqRzSBlnUCqkASMK732cxNklB5oZOQ2RF1RHmQ6fVIx8xG3w7/Z6STxkw423kpnsRdxrQvtOvEtfJ4SjO39/mE5FN3JpTY5bSNWUJ9gDfb2mnRMYHX26lYG7UdKdkY6hPBBDG8gr85F1z2f1WIeH2VblPLNeT735n7YWy9hnMWRHmvR5vM+UaVyv62kR44LRBCfTpRwTn7GnfvhD29CxqXmUqs4Ui5B5nhcGraY5uojArhwBOBbbUBZCSLgfcHmtsU/+20Jk5tG7Mo8CDUlEQ5maSZmNhKdHL39K9HCPNcAOi3b4w== 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 AM0PR08MB4995.eurprd08.prod.outlook.com (10.255.30.207) by AM0PR08MB4082.eurprd08.prod.outlook.com (20.178.119.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.23; Tue, 12 Nov 2019 10:40:31 +0000 Received: from AM0PR08MB4995.eurprd08.prod.outlook.com ([fe80::3c0c:3112:ccbf:13d0]) by AM0PR08MB4995.eurprd08.prod.outlook.com ([fe80::3c0c:3112:ccbf:13d0%6]) with mapi id 15.20.2430.027; Tue, 12 Nov 2019 10:40:31 +0000 From: "james qian wang (Arm Technology China)" To: Liviu Dudau , "airlied@linux.ie" , Brian Starkey , "maarten.lankhorst@linux.intel.com" , "sean@poorly.run" , Mihail Atanassov , "imirkin@alum.mit.edu" Subject: [PATCH v9 2/4] drm/komeda: Add drm_lut_to_fgamma_coeffs() Thread-Topic: [PATCH v9 2/4] drm/komeda: Add drm_lut_to_fgamma_coeffs() Thread-Index: AQHVmUWbKgyTbmPF30mDCSrJAJAYVQ== Date: Tue, 12 Nov 2019 10:40:31 +0000 Message-ID: <20191112103956.19074-3-james.qian.wang@arm.com> References: <20191112103956.19074-1-james.qian.wang@arm.com> In-Reply-To: <20191112103956.19074-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: HK0PR03CA0087.apcprd03.prod.outlook.com (2603:1096:203:72::27) To AM0PR08MB4995.eurprd08.prod.outlook.com (2603:10a6:208:162::15) 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: 40c58122-e8b4-435b-8670-08d7675cc455 X-MS-TrafficTypeDiagnostic: AM0PR08MB4082:|AM0PR08MB4082:|AM0PR08MB3634: 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: 021975AE46 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(979002)(4636009)(376002)(366004)(346002)(396003)(136003)(39860400002)(199004)(189003)(86362001)(6512007)(478600001)(66066001)(54906003)(110136005)(316002)(5660300002)(6486002)(14454004)(2171002)(11346002)(446003)(2616005)(6436002)(25786009)(476003)(2201001)(14444005)(1076003)(6506007)(8936002)(386003)(99286004)(2906002)(4326008)(55236004)(102836004)(103116003)(256004)(66946007)(66556008)(66476007)(64756008)(66446008)(6116002)(3846002)(52116002)(26005)(81166006)(81156014)(8676002)(186003)(7736002)(486006)(71190400001)(71200400001)(36756003)(305945005)(76176011)(50226002)(2501003)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR08MB4082; H:AM0PR08MB4995.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: a3v/DQSfKb9ZZFqlQ2LipZjWy8dFhQAnHCkcn8pf0fi6AHxYczSwTGPAOb4RoCIGQOkSvD9HLZ9jHk4CA0mxXodCeWpgvv3IPBfESGVxOz/6ZM5QzzHM6vBVUtNZAozTueldrJaZtNsS2pB3NQ97bZb4KUaZGYkN1f+aZxCrDuSR/i7RmfNtmjNFimIbpvs9DrOMwFsFYbJNcoWjliiVlH4NbsJkHe5uxRFK5+K/qFEE+zgcf9ar2rJpKSDls/dG57Y2Phg7qr99/dN8Qo8LXH05wPtl3Lxj6yqt7r+q5dBk2vizPFOcYznQ+sN3nBAvrxtxXioYiK70TledlUPuwnXraXIlyeb7tpf51va5WyMsu0zvB2RXSyl5UfEEaW+Q9FV57dx41iJsvl4i1CDZUPk8Tcq9imkDYDrjDjM5WKPgcrZ/X6sCzMpiCOknWStt MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4082 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT019.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)(979002)(4636009)(39860400002)(136003)(396003)(376002)(346002)(1110001)(339900001)(189003)(199004)(4326008)(478600001)(14454004)(26005)(6512007)(99286004)(336012)(2171002)(103116003)(66066001)(23756003)(11346002)(446003)(54906003)(25786009)(186003)(26826003)(6486002)(36756003)(14444005)(36906005)(316002)(356004)(110136005)(47776003)(3846002)(6116002)(50226002)(305945005)(2201001)(7736002)(1076003)(81166006)(81156014)(486006)(2501003)(102836004)(86362001)(50466002)(386003)(2616005)(5660300002)(6506007)(76176011)(2906002)(105606002)(76130400001)(126002)(70206006)(22756006)(476003)(8676002)(70586007)(8936002)(8746002)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR08MB3634; 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: 5aaa2bfe-eacc-40e4-cf60-08d7675cbd74 NoDisclaimer: True X-Forefront-PRVS: 021975AE46 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zkK2ZVwNTqpFAmM6H7PF/NQqct7YBhSH/22xK8D7lart0bOl79tCHRkUU3huHx/ZP0mB2XJTTbrISG/u+Ukb5e9A1eWnNdBLyG+Wtw7K+QC1sxUIb5gIEq7rWcdNID6IJO65WT8D6O5LVS01I0IJmpc/jZ6ksqvT4nMQxpY8DWXwSZprP58phD6rS15OXlwOaW1zyFGiFdX7Fp3EGy9ErShWtBHCUDyKTL4by8QMK5XQQjW5orOstW2rg8SnVWPTa180tPWov7r9wiVegUVjLWash9flS4SprQBePfzyuDNeENZW3amy4/axtwldbPveuwfdxreDG7fO0BiKjjngt4VRh9cCFCHyjb0Hzi9m8YlkCEkr1ylD05Y9W4e5j6dW8wuWrmVWW5fxEPJTumpIKrb9fweWiaSE2rK26+J0VLVWTW4HxabEgpOSWx4ioBYQ X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Nov 2019 10:40:42.4055 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 40c58122-e8b4-435b-8670-08d7675cc455 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: AM0PR08MB3634 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=+Pgg5dtCZX15W2ngjSFIKapDfjxtJOhi4FimOi578ORS9OHEXdzezp5gRyCy42S3x8btny2crv8qnTdU40lWejK233hJmEOYzJENO6rxHuM418u5Tmgv2MdKuWXxINScCCKoI7oh/YKz1ZCuzXFoIGbl9rsodSHm2Db3KLqJWg8= 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=+Pgg5dtCZX15W2ngjSFIKapDfjxtJOhi4FimOi578ORS9OHEXdzezp5gRyCy42S3x8btny2crv8qnTdU40lWejK233hJmEOYzJENO6rxHuM418u5Tmgv2MdKuWXxINScCCKoI7oh/YKz1ZCuzXFoIGbl9rsodSHm2Db3KLqJWg8= 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\)" , "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 Tue Nov 12 10:40:38 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: 11239045 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 C46F91515 for ; Tue, 12 Nov 2019 10:40:54 +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 AAA772196E for ; Tue, 12 Nov 2019 10:40:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AAA772196E 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 E9BF86EB06; Tue, 12 Nov 2019 10:40:53 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-db5eur03on062c.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0a::62c]) by gabe.freedesktop.org (Postfix) with ESMTPS id D8D766EB06 for ; Tue, 12 Nov 2019 10:40:52 +0000 (UTC) Received: from VI1PR08CA0234.eurprd08.prod.outlook.com (2603:10a6:802:15::43) by AM6PR08MB4691.eurprd08.prod.outlook.com (2603:10a6:20b:cc::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2430.20; Tue, 12 Nov 2019 10:40:50 +0000 Received: from AM5EUR03FT030.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::200) by VI1PR08CA0234.outlook.office365.com (2603:10a6:802:15::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2430.20 via Frontend Transport; Tue, 12 Nov 2019 10:40:50 +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 AM5EUR03FT030.mail.protection.outlook.com (10.152.16.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2430.21 via Frontend Transport; Tue, 12 Nov 2019 10:40:50 +0000 Received: ("Tessian outbound e4042aced47b:v33"); Tue, 12 Nov 2019 10:40:47 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: cce31c35067135f7 X-CR-MTA-TID: 64aa7808 Received: from d981cce78eee.2 (cr-mta-lb-1.cr-mta-net [104.47.9.59]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id A5F06376-502B-421F-8A7B-8FEBFE531604.1; Tue, 12 Nov 2019 10:40:42 +0000 Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-ve1eur03lp2059.outbound.protection.outlook.com [104.47.9.59]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d981cce78eee.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Tue, 12 Nov 2019 10:40:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n92d6PvBTLOYVxR/ZTs3g7pD1M7PctfgQEF4HZExbBbewosiWjavSYGY4HTlCf7VnCZiUSaLX7uncj6sHvuNwiSY8BXmmhY8CqepD4ZqQuKrXYzT4ytYaDRuYMG5Iatk1GtULLEqHk7uNlU7YL5quKW8qX6zwluVLv74SGURRpz+FUWVp4q7LRwczaAZNg2k/ztq6oLeKluYVGNOKZflMM1VHpKQUaJXafsU7aWoUhLbSAEuySha9HrbzKWxvfv8qc0UPrwzX3O39LpwUVWdlfl86f+JVwxU3i3bbiRNua51T980w102i6pU+cZlmB/a8JN4lr4ghI6C6Nqxn22jaQ== 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=WPBgaqoOVlyhfGuyJx7/vH9o//7S0zc4brTayxxOMFRQZU7niufLx/235/iZtmv2ck3KYzZ1blbxXJPoGZK7Uy+70Kwz845fiEWEdcH97gzqZ1mz14ZmJQo1HpfX6lLG0uEHYKuheFSIgKu7gNxNJOQYRWnh8xmA1EeHulJoA3dVWoJF/QgaYJB7ANKkUNtVUVwB5IBciiq5WxLff/e3qCU4Hy1AmXHq6oA9VeZa+R7QDPR8UVVMhKPl9GiStnFlR4x8rvUFdFkp27zhUeRrusweNU1GEhmsrmZQ+tN4Wr/4nvkgMWjzCmDSBSHDN1ydvMG5Fo3rA7tKfcDY7bB34g== 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 AM0PR08MB4995.eurprd08.prod.outlook.com (10.255.30.207) by AM0PR08MB3313.eurprd08.prod.outlook.com (52.134.92.156) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2430.22; Tue, 12 Nov 2019 10:40:38 +0000 Received: from AM0PR08MB4995.eurprd08.prod.outlook.com ([fe80::3c0c:3112:ccbf:13d0]) by AM0PR08MB4995.eurprd08.prod.outlook.com ([fe80::3c0c:3112:ccbf:13d0%6]) with mapi id 15.20.2430.027; Tue, 12 Nov 2019 10:40:38 +0000 From: "james qian wang (Arm Technology China)" To: Liviu Dudau , "airlied@linux.ie" , Brian Starkey , "maarten.lankhorst@linux.intel.com" , "sean@poorly.run" , Mihail Atanassov , "imirkin@alum.mit.edu" Subject: [PATCH v9 3/4] drm/komeda: Add drm_ctm_to_coeffs() Thread-Topic: [PATCH v9 3/4] drm/komeda: Add drm_ctm_to_coeffs() Thread-Index: AQHVmUWfqKXksz1BtEuyt+x5WWTWPg== Date: Tue, 12 Nov 2019 10:40:38 +0000 Message-ID: <20191112103956.19074-4-james.qian.wang@arm.com> References: <20191112103956.19074-1-james.qian.wang@arm.com> In-Reply-To: <20191112103956.19074-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: HK0PR03CA0087.apcprd03.prod.outlook.com (2603:1096:203:72::27) To AM0PR08MB4995.eurprd08.prod.outlook.com (2603:10a6:208:162::15) 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: 4a37dedc-b421-40cb-02da-08d7675cc8f1 X-MS-TrafficTypeDiagnostic: AM0PR08MB3313:|AM0PR08MB3313:|AM6PR08MB4691: 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: 021975AE46 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(396003)(136003)(376002)(39860400002)(346002)(366004)(189003)(199004)(305945005)(8676002)(102836004)(476003)(2616005)(5660300002)(11346002)(99286004)(55236004)(81166006)(81156014)(7736002)(2906002)(50226002)(6506007)(66066001)(386003)(76176011)(26005)(186003)(71190400001)(71200400001)(2501003)(52116002)(8936002)(1076003)(25786009)(36756003)(256004)(6116002)(3846002)(4326008)(2171002)(66476007)(6512007)(446003)(478600001)(54906003)(486006)(6486002)(103116003)(64756008)(66946007)(66446008)(6436002)(14454004)(86362001)(316002)(110136005)(66556008)(2201001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR08MB3313; H:AM0PR08MB4995.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: 5nPUsM/sEumHnGKHMxynTlM/yrvf6V2IsxcPPQ6bE8hOmL/ms1UK9pWpDK/YGCO+B+PaSk5r4wTeg34B/qrvFaa8oMEcQJXpPeSpicLPB5ugSZKhhV3S1gJmFryw6Z50CX2tW/lSIURLRHMG7WywiRm8n10JWOoy/Qic7OGUNZLV4XSKHqR57VzgknsgsGLrDu0gcJi43rbqVlHbAowrl/C8O4iMIKtQKRsRiwtO9/Awtgllar4UzRzN5Hh4p0GX8io0vySJpycuttFFk4cNI8SWNKWAi2bj006l0Aoh1or5b6sqpXcSaRQr9JALYSDnwoH2SBXdkV5HzL1mlI/Nye1rQ+pFyhZRho5Fuo2BmrbJbxE9H84Vw3ig5rxAU2b7t8TJ/LVb1DTFTmuZAj6BDqXyvZ5h7BT2nJMkt0glAw0baM3tLeJbHIBjkNGf1Bge MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3313 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT030.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)(39860400002)(376002)(396003)(1110001)(339900001)(199004)(189003)(6486002)(6512007)(36756003)(2201001)(186003)(2171002)(102836004)(6506007)(54906003)(478600001)(25786009)(36906005)(99286004)(386003)(4326008)(446003)(7736002)(26005)(476003)(336012)(11346002)(486006)(305945005)(76176011)(316002)(86362001)(126002)(2616005)(110136005)(14454004)(26826003)(3846002)(356004)(8746002)(8936002)(2906002)(70206006)(5660300002)(50466002)(70586007)(50226002)(22756006)(47776003)(6116002)(76130400001)(23756003)(1076003)(2501003)(66066001)(8676002)(103116003)(81156014)(105606002)(81166006); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR08MB4691; 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: 8346d92d-9665-4d5c-bc98-08d7675cc18b NoDisclaimer: True X-Forefront-PRVS: 021975AE46 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rFC+nd+774Quh2BQzdrqCidYqYoUTdIfbFi+1LIhFcuvebmk+QlIi6hRRS20Q6KD2IiNCnbD5z7LjGayFEndeGrKfOTlIsALrnsFVpuOSHclEJl1Iol+WK9V/a085ABfQtf+7VbXMmcD0hH1sRAqIRrRy7e1t1aRGvZb2LNrMA3Us8u2C/CoA/ElJDLMa6ig5pBbu9zRGhEDNWbEvbtRsKmRLrJAVONn/jvBPZKEbT74ld0Xvsu4yRuXvLSFWSEvN4eglbkUtqAc0XvD4Yl3qWHThSSCUjKPhCuF7HMuIsMBQPD//BbXYqpc5Mco+U8v9l0jztRjwQ4Nl1mdxpjRprwnzEDc1ABgN4cIArIo+nFFJd+j8cgxCy+bY7c5P7gwz8hvh1zF3oEkx8HioWxfGwWpqH5PBX/69OEeK1+Hed/NA0/DWLAsaP2Tml7+bQFy X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Nov 2019 10:40:50.1454 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4a37dedc-b421-40cb-02da-08d7675cc8f1 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: AM6PR08MB4691 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=3viNEZC7HJOZbeLf+UCIaKL2UR7my6B2ub48hVwaHTTwt0BsWnbOwIlV3MDFjMW/c81PPBZyu5MyqO0lhLLZX51USHwZvhyYsk1dbyI9IZYoIfkTbkaza3CUMFhTMzoEkbjp5CMj686kj9dLxC/VDCtf4dp3Fp01kVVsytIT7yM= 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=3viNEZC7HJOZbeLf+UCIaKL2UR7my6B2ub48hVwaHTTwt0BsWnbOwIlV3MDFjMW/c81PPBZyu5MyqO0lhLLZX51USHwZvhyYsk1dbyI9IZYoIfkTbkaza3CUMFhTMzoEkbjp5CMj686kj9dLxC/VDCtf4dp3Fp01kVVsytIT7yM= 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\)" , "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 Tue Nov 12 10:40:44 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: 11239047 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 689131515 for ; Tue, 12 Nov 2019 10:41:01 +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 4FBFC2196E for ; Tue, 12 Nov 2019 10:41:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4FBFC2196E 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 87F346EB08; Tue, 12 Nov 2019 10:41:00 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50083.outbound.protection.outlook.com [40.107.5.83]) by gabe.freedesktop.org (Postfix) with ESMTPS id CD03F6EB08 for ; Tue, 12 Nov 2019 10:40:58 +0000 (UTC) Received: from AM6PR08CA0001.eurprd08.prod.outlook.com (2603:10a6:20b:b2::13) by VI1SPR00MB254.eurprd08.prod.outlook.com (2603:10a6:800:5c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.23; Tue, 12 Nov 2019 10:40:55 +0000 Received: from VE1EUR03FT037.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::207) by AM6PR08CA0001.outlook.office365.com (2603:10a6:20b:b2::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2451.23 via Frontend Transport; Tue, 12 Nov 2019 10:40:55 +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 VE1EUR03FT037.mail.protection.outlook.com (10.152.19.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2430.21 via Frontend Transport; Tue, 12 Nov 2019 10:40:54 +0000 Received: ("Tessian outbound e4042aced47b:v33"); Tue, 12 Nov 2019 10:40:52 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 16091eeb146b9c36 X-CR-MTA-TID: 64aa7808 Received: from a79b2280da58.2 (cr-mta-lb-1.cr-mta-net [104.47.10.53]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 8719C66A-E6A7-461B-A2DA-38CA8FCF4D23.1; Tue, 12 Nov 2019 10:40:46 +0000 Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-db5eur03lp2053.outbound.protection.outlook.com [104.47.10.53]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id a79b2280da58.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Tue, 12 Nov 2019 10:40:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HrFuMHW7ZgK2nUdg2qsI8Sq6A//y971CxGSIvdh9+8HHfm1blvIbAPxsKDSEbK2OwkpgEnmlej+wIkfaMhexD4XP92ucO4R6dZxtCNuJE/NMGmOOdhprcEkR4cdU8jr+J3MzanQT+75U842qhcps40H32MusJk4Q+TToYBWrISNPfMl7LiOV00xYBsM9Hwf3H5bGO6RQyWwgN+pWZZ2nrJvAe6B2m8hY5Y4ZaacLjTJWAmmdxap79lFc5utj/FzyNa7uY2h55qZm7Y3uNmTXy1U/r7HjsciNcmi2YHwS7FYNdvkdjteL07FBQoPgm7Nt9bdK9WtqELl2aDpEurT7VA== 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=lN73BnBUZv+ZjU9GmObLyFfTMOa+O++A3o/OpizfzB7zum/DHdBuw1vfggVULim4BSD5bZc4AMYZt3j1Hpfba1PQY2itDYotj8z+mwH2FTUSxSUPXm2E9c4dtsenPaFZiwET/qNG/yhBFiaouAtzbquuAbzVCPPAMp5r3bHqH2TdYk8bWKxJHi6npDMuiYqgH3UB4FPf1+BJK83thIyhOCgA8wilTVbukz9LvpM6M4lhQJysxIimT9t+P1jIARcmwgpkNvFhS/yInhv3/1X1fp23ya4xW6tQYDwH2vR63GKXvH4305WN+Lu+P3yF3V6iriZpquk7bq4WhNx2i53uOA== 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 AM0PR08MB4995.eurprd08.prod.outlook.com (10.255.30.207) by AM0PR08MB4082.eurprd08.prod.outlook.com (20.178.119.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.23; Tue, 12 Nov 2019 10:40:45 +0000 Received: from AM0PR08MB4995.eurprd08.prod.outlook.com ([fe80::3c0c:3112:ccbf:13d0]) by AM0PR08MB4995.eurprd08.prod.outlook.com ([fe80::3c0c:3112:ccbf:13d0%6]) with mapi id 15.20.2430.027; Tue, 12 Nov 2019 10:40:45 +0000 From: "james qian wang (Arm Technology China)" To: Liviu Dudau , "airlied@linux.ie" , Brian Starkey , "maarten.lankhorst@linux.intel.com" , "sean@poorly.run" , Mihail Atanassov , "imirkin@alum.mit.edu" Subject: [PATCH v9 4/4] drm/komeda: Adds gamma and color-transform support for DOU-IPS Thread-Topic: [PATCH v9 4/4] drm/komeda: Adds gamma and color-transform support for DOU-IPS Thread-Index: AQHVmUWjWKw2oVnDAEWCPL8R/YV3Ug== Date: Tue, 12 Nov 2019 10:40:44 +0000 Message-ID: <20191112103956.19074-5-james.qian.wang@arm.com> References: <20191112103956.19074-1-james.qian.wang@arm.com> In-Reply-To: <20191112103956.19074-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: HK0PR03CA0087.apcprd03.prod.outlook.com (2603:1096:203:72::27) To AM0PR08MB4995.eurprd08.prod.outlook.com (2603:10a6:208:162::15) 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: 4b4ec4e4-66af-4e1a-6964-08d7675ccbd4 X-MS-TrafficTypeDiagnostic: AM0PR08MB4082:|AM0PR08MB4082:|VI1SPR00MB254: 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: 021975AE46 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(39860400002)(136003)(396003)(346002)(366004)(376002)(199004)(189003)(64756008)(66476007)(66556008)(66946007)(6116002)(66446008)(3846002)(256004)(386003)(8936002)(6506007)(99286004)(2906002)(1076003)(14444005)(102836004)(103116003)(55236004)(4326008)(36756003)(71200400001)(71190400001)(486006)(305945005)(2501003)(76176011)(50226002)(81156014)(81166006)(26005)(8676002)(52116002)(7736002)(186003)(110136005)(54906003)(5660300002)(316002)(86362001)(66066001)(6512007)(478600001)(2616005)(11346002)(446003)(2201001)(6436002)(25786009)(476003)(6486002)(2171002)(14454004); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR08MB4082; H:AM0PR08MB4995.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: JVUoa+QCXbQh6WlEr+6RggSotbccpTZmzuLQow8rfBD4g3/sGuHCEYDIdIX3Y5zXqtqimBrZZt5KFY0xWbQHb+UXmvisMLXyyIJ8fBbgfF9BsZxWFDzomM0NxbKTF0JcAAiqETXt4dW7c9FY65e02D8w2FlyO+fsA6eneuCTXJR0vQ9o3oZEyu3InmGGCUF8IeRY9/VOe8tZhnCILkKB9MzUxewIh+fMilgTbi3wUo6Qzq7kv9OQxsSNkF9sTLImzdRdI5c0gBQdAjpFnYhxiQmNdocEMJY69lNO6DmEE6ReHktcdXECIBt7uPvd32xMp20FBV8Mm0Ylt8TN8e7EP5QNwrBjwNlzwFdCuGIJMMh176U4ywBLHn/TftNjvh2s0+xtfK3sf/AWtuqGj8SZdaZitfBVVeZ6itHiw0NDc2cmZ5sFb6o5ZguGM0bd35gH MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4082 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT037.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)(39860400002)(396003)(376002)(136003)(1110001)(339900001)(199004)(189003)(102836004)(50466002)(86362001)(2201001)(305945005)(7736002)(6116002)(3846002)(50226002)(486006)(2501003)(81156014)(81166006)(1076003)(476003)(8676002)(22756006)(126002)(76130400001)(8936002)(8746002)(70586007)(70206006)(386003)(6506007)(5660300002)(2616005)(2906002)(76176011)(105606002)(99286004)(26005)(6512007)(103116003)(2171002)(336012)(4326008)(14454004)(478600001)(36756003)(6486002)(14444005)(26826003)(36906005)(47776003)(110136005)(356004)(316002)(11346002)(23756003)(66066001)(186003)(446003)(25786009)(54906003); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1SPR00MB254; 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: 317e8938-a06e-45a2-a0de-08d7675cc5a6 NoDisclaimer: True X-Forefront-PRVS: 021975AE46 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: o8qNU0IRlX5S3AOHri/yoF9Sz5FQ3NtsmroztO8voiB+4gGbiqaMgsmUva2slr54xlvubM/v6fmjcsenGfcfupmYNWjwF50se9CwO4bZxR3gAa3zsZzjqpO2xCzINaD/sUD+TItI6l+DeQix1HNz5LZKrb3UIVgMlw4i4oRikpPEABVF81Ndz9wsWjZO0oDPuiz8xThp5avODYpa8CEYVlRoCHdzT5x1zrEPLBjGCPYtewbidQdQ8/ErsTndJZsIsbMDvnK4x3Qo3FN0wMkbAlWnVnySxFQZWhq8bFpEhUXUwzmZSh0quiDxqrT68jC1laxAJKK8qxpDJ8QftvIxKRI6cc6jcmswvwJGjorlntbfEN2OwYy7SSh/W5W6YsLDQcy85njhSuE/fjfgTlU6vHnPOR1l1nmywRRdT05QnJIzi6wjlsQ6reXfgPfVEsiX X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Nov 2019 10:40:54.8990 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4b4ec4e4-66af-4e1a-6964-08d7675ccbd4 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: VI1SPR00MB254 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=DGoHfE+hYMD4cT2wlzqS2XtmlAGKLxThc/wqMgP3ZqYdAl54CZ4r+IojipD33GDDTD7/WexZF0g7XTRQ9ecijFgbGaI8+3kEb8gKRtG3bJd1CIcEcog7ejVl2oM+XyK5zJ0KhbMXJmWaaKQwuH1OQmra0huQphRM8RnDxWv+Ss4= 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=DGoHfE+hYMD4cT2wlzqS2XtmlAGKLxThc/wqMgP3ZqYdAl54CZ4r+IojipD33GDDTD7/WexZF0g7XTRQ9ecijFgbGaI8+3kEb8gKRtG3bJd1CIcEcog7ejVl2oM+XyK5zJ0KhbMXJmWaaKQwuH1OQmra0huQphRM8RnDxWv+Ss4= 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\)" , "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);