From patchwork Wed Oct 16 10:34:08 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: 11192923 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 BF3B917E1 for ; Wed, 16 Oct 2019 10:34:29 +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 A17D520872 for ; Wed, 16 Oct 2019 10:34:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A17D520872 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 E65C46E92B; Wed, 16 Oct 2019 10:34:28 +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-eopbgr20056.outbound.protection.outlook.com [40.107.2.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id 04B026E932 for ; Wed, 16 Oct 2019 10:34:27 +0000 (UTC) Received: from VI1PR08CA0146.eurprd08.prod.outlook.com (2603:10a6:800:d5::24) by DB8PR08MB5066.eurprd08.prod.outlook.com (2603:10a6:10:e4::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.16; Wed, 16 Oct 2019 10:34:23 +0000 Received: from AM5EUR03FT048.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::206) by VI1PR08CA0146.outlook.office365.com (2603:10a6:800:d5::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2347.16 via Frontend Transport; Wed, 16 Oct 2019 10:34:23 +0000 Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT048.mail.protection.outlook.com (10.152.17.177) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.15 via Frontend Transport; Wed, 16 Oct 2019 10:34:21 +0000 Received: ("Tessian outbound 0939a6bab6b1:v33"); Wed, 16 Oct 2019 10:34:16 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 99346b773049ac19 X-CR-MTA-TID: 64aa7808 Received: from 4cddd178ccbc.2 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.4.54]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 34A94619-5420-4B7C-A6B7-977AAED1B35D.1; Wed, 16 Oct 2019 10:34:10 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-am5eur02lp2054.outbound.protection.outlook.com [104.47.4.54]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 4cddd178ccbc.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 16 Oct 2019 10:34:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kXf/QUlr4G3hZYPvJDdPHGY9wideFWLUnAnXMFIBPiS87pRC7GPSCmeHOjOhVjHtMrP4X2WbV8UePddjOGeG8jfuxGpF0rcbpUf+l1VZ3WWHG/MwqfTYAyRpHrXkpHWw2kU6O9zBWQfQg5EwUq+4qZH6+ViNmvsq8KRkCxzA+H10G4wf+P+vjOcAjOhellxtbzK3qbINeLxzuXT9u14WlPOorXjIouNAXvPWB0oB+jyzz+mUMmeOvEIlmdTK6RwC/boXXQ5iO38vpAt2pyNaNxrq6loh5q4AdGtqZ3aC7nT8fh0ohDu8549KQYDCzpLXPe5P2Sg+sUoB+C9QtWQMOQ== 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=XwNLApKNkl72Wy0e6O+y5NOzqaHS2uIq08CitOENDfA=; b=gyvtHpIv4cauAZDYIDkhbMXffAIf1ncW4VLAcd9N2SSe3fiYGHfCf0v6AyOCmfqWUjH0PVcXLa5OP8aEDW4oqVXblctRmtws1B9MTX+wkT1wgjZSaGsLwcZaC7Qq/H8FGzUE0hq0iKlye8r5AooKdEo2L8wF8R46ofYtU+Y3loDOMxLYqfRQwEBpspl+vHWajM/nYCPzM3rmqmUZXnBtkJx7aIS7yny75mspJl2CuPvhmaXvnUwc9bfEW+BvFMaSJi2XghK5nPUeRO9nMgbN3DQQUNJahgmtK4m6/NLXX8UW9w9Ibas67v7yYWrX1B8K5iNPhPeT9PSDpOCBNa3lwA== 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 VE1PR08MB5182.eurprd08.prod.outlook.com (20.179.31.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.16; Wed, 16 Oct 2019 10:34:08 +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.2347.023; Wed, 16 Oct 2019 10:34:08 +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 v5 1/4] drm: Add a new helper drm_color_ctm_s31_32_to_qm_n() Thread-Topic: [PATCH v5 1/4] drm: Add a new helper drm_color_ctm_s31_32_to_qm_n() Thread-Index: AQHVhA09wVtvHgqrOkmWUho1ovfOOQ== Date: Wed, 16 Oct 2019 10:34:08 +0000 Message-ID: <20191016103339.25858-2-james.qian.wang@arm.com> References: <20191016103339.25858-1-james.qian.wang@arm.com> In-Reply-To: <20191016103339.25858-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: HK0PR04CA0006.apcprd04.prod.outlook.com (2603:1096:203:36::18) 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-Correlation-Id: 1b85811c-c757-490c-91c1-08d75224684a X-MS-Office365-Filtering-HT: Tenant X-MS-TrafficTypeDiagnostic: VE1PR08MB5182:|VE1PR08MB5182:|DB8PR08MB5066: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:4941;OLM:4941; x-forefront-prvs: 0192E812EC X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(376002)(366004)(39860400002)(396003)(346002)(136003)(199004)(189003)(1076003)(64756008)(66446008)(66946007)(66556008)(66476007)(2171002)(6486002)(66066001)(71190400001)(8676002)(2201001)(14454004)(6436002)(71200400001)(5660300002)(76176011)(81166006)(81156014)(36756003)(2501003)(52116002)(386003)(6506007)(86362001)(25786009)(256004)(476003)(2616005)(305945005)(3846002)(8936002)(186003)(103116003)(11346002)(446003)(6512007)(478600001)(6116002)(55236004)(2906002)(486006)(54906003)(50226002)(4326008)(7736002)(110136005)(26005)(316002)(102836004)(99286004); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB5182; 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: hBWEbJzky5IBufOc+HQF2LPlVDayfB7/yOzKhZfznZwRF6QawGbPfdj1f4MPREYCL4O8LG5uJMPN5rkxkSQ79Y4HlYq+JwpShnFKVYBYSCVJGVvKPsBqGikQtNuBtt0XpNBCIlKGV0byx1bX+JcLWaEDaDiOrxftbch5SdgtZKhTZBvRRmG0jiud4wTb8YoYP8qgngU7Bl8DS9w+j+7YDZJge1bAuD86+fKKRIdSUrT2umOf/YbNcGgYeLEcDD/CchpdVHjwd9vByK3bSDN+mkoyAoM1BvFxAk/WUVxnsJcTbFaRzAsBjEwJA7nWKksRgSLk3zkVPRwBCzB/8/96QWsTNfmNzkTzDiS1ap4d4ImtD+evZD6ZyxMugw1ZFP6VPLg5FcJvVVc+3sRpUpnACchwUQHnSmMnZ53J+Q8jXbA= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5182 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT048.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)(136003)(396003)(376002)(189003)(199004)(305945005)(1076003)(3846002)(22756006)(6116002)(26826003)(478600001)(2501003)(25786009)(4326008)(103116003)(23756003)(5660300002)(26005)(2906002)(356004)(110136005)(316002)(54906003)(14454004)(102836004)(36906005)(76130400001)(7736002)(186003)(6512007)(66066001)(70206006)(76176011)(6506007)(70586007)(386003)(486006)(8936002)(50466002)(36756003)(50226002)(2171002)(6486002)(336012)(81166006)(11346002)(446003)(2616005)(476003)(126002)(86362001)(81156014)(8746002)(2201001)(63350400001)(107886003)(47776003)(8676002)(99286004); DIR:OUT; SFP:1101; SCL:1; SRVR:DB8PR08MB5066; H:64aa7808-outbound-1.mta.getcheckrecipient.com; FPR:; SPF:TempError; 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: aeac93ca-8c58-47e9-a67d-08d752246034 NoDisclaimer: True X-Forefront-PRVS: 0192E812EC X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TJx0lPE0BZwsengIylt9z/80Tjp6TvH6G/aIh+IsBxFoHIYsztxA+TGWu0rarLNvaMzYAlegmwYZ4m69Adhu2f64t8r1J4c7XWjsh1sIjsubjPsoMGqMf7G5oyObA/xoofuFWTtb39PWVa3BYQ7cKVED8FXvXEHBeC1PlXD/h4URhGtGsCdmpGTUg9IpWmH4S+gsiva3YStoszYVOJ2y90+RtnYducENFzJfxm6kntiy9Z7Po4sPScRdUv2ZSriqj4wygOX8w9Sgx1QWWZePPxqQYewKv15x/YCgjgmkhe/gCAuId11aJ9sLKPXIcWJ0ETUl9pI2QfkasoDS2z+1KKr/nEms3l89G4/7X10eSEBQTBSF7vAgXj7/3sAuCK3SFXK6MYvegktU3u8kMeWhNbJTKY63HpPiGfxZcedQrSQ= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2019 10:34:21.7641 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1b85811c-c757-490c-91c1-08d75224684a 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: DB8PR08MB5066 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=XwNLApKNkl72Wy0e6O+y5NOzqaHS2uIq08CitOENDfA=; b=qyYw51jIRqHS3M75guWYLGoq3R0k0OelhTBsqbEbij1wgXcotnO2ia1p1uY7iH0PhYIHDmbaEpnChU1bZGfxgc1M33nQ4r45n82Vqse4N6zbME2xatHo2kZMp2ek4Rgqo9Lj6EJsAk61+ESk9FcNb/nwPdDiXSWrEOIcpPjGMIE= 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=XwNLApKNkl72Wy0e6O+y5NOzqaHS2uIq08CitOENDfA=; b=qyYw51jIRqHS3M75guWYLGoq3R0k0OelhTBsqbEbij1wgXcotnO2ia1p1uY7iH0PhYIHDmbaEpnChU1bZGfxgc1M33nQ4r45n82Vqse4N6zbME2xatHo2kZMp2ek4Rgqo9Lj6EJsAk61+ESk9FcNb/nwPdDiXSWrEOIcpPjGMIE= X-Mailman-Original-Authentication-Results: spf=temperror (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). Signed-off-by: james qian wang (Arm Technology China) Reviewed-by: Mihail Atanassov Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_color_mgmt.c | 27 +++++++++++++++++++++++++++ include/drm/drm_color_mgmt.h | 2 ++ 2 files changed, 29 insertions(+) diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c index 4ce5c6d8de99..d313f194f1ec 100644 --- a/drivers/gpu/drm/drm_color_mgmt.c +++ b/drivers/gpu/drm/drm_color_mgmt.c @@ -132,6 +132,33 @@ 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, include the sign-bit, support range is [1, 32] + * @n: number of fractional bits, only support n <= 32 + * + * Convert and clamp S31.32 sign-magnitude to Qm.n (signed 2's complement). The + * higher bits that above m + n are cleared or equal to sign-bit BIT(m+n). + */ +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 < 1 || m > 32 || n > 32); + + /* the range of signed 2's complement is [-2^(m-1), 2^(m-1) - 2^-n] */ + 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 16 10:34:15 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: 11192927 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 91E2418A6 for ; Wed, 16 Oct 2019 10:34:50 +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 2EB6B21D71 for ; Wed, 16 Oct 2019 10:34:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2EB6B21D71 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 3338B6E932; Wed, 16 Oct 2019 10:34:46 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70078.outbound.protection.outlook.com [40.107.7.78]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1BC766E930 for ; Wed, 16 Oct 2019 10:34:44 +0000 (UTC) Received: from VI1PR08CA0210.eurprd08.prod.outlook.com (2603:10a6:802:15::19) by AM0PR08MB3633.eurprd08.prod.outlook.com (2603:10a6:208:de::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.16; Wed, 16 Oct 2019 10:34:39 +0000 Received: from DB5EUR03FT037.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::207) by VI1PR08CA0210.outlook.office365.com (2603:10a6:802:15::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2347.22 via Frontend Transport; Wed, 16 Oct 2019 10:34:39 +0000 Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT037.mail.protection.outlook.com (10.152.20.215) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.15 via Frontend Transport; Wed, 16 Oct 2019 10:34:37 +0000 Received: ("Tessian outbound 6481c7fa5a3c:v33"); Wed, 16 Oct 2019 10:34:25 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 95c03a061108e5e6 X-CR-MTA-TID: 64aa7808 Received: from c2892146728e.2 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.5.57]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 216C8E9C-AFF0-42AD-932B-836FF78E502E.1; Wed, 16 Oct 2019 10:34:20 +0000 Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-he1eur02lp2057.outbound.protection.outlook.com [104.47.5.57]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id c2892146728e.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 16 Oct 2019 10:34:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CT0cPretCRCzHFq6+AeIpRf9o+VaIirw65k8pMDETUhyZGaIEyeM63KJINi99bf4HxQmr6cvtZF2lFCCVr0MA/gAs3+ghEBpbiPYD72c1H7FbxkF1MLNsRw8WWKaledQaHazMDjNZJ8e8rRZEV3RUPMTH35SHmM8SW7AfR2m7ezuUj+7cbmNjsDM9vBlhq4dJyPMMGVJgGDfTaAU8/4r2CuDDa2lCcu2PJPVdpe2BiKtq7xjs3EqI2y3pyYiuRdhnIkkGRUCCVLSCg2PxAq+TfP9X4FlXHTRJfFqKOZ/BhrS/2eVYDAYyUe6TVJF2qhqlMEoKBJic9YVonb2bxIxEA== 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=D0EmvRQfFeOlVPyZk35nH9xn75e90FlqpRU1zbhBfUr5ywzqUigrpQkjLicF+MrjuI0dak2fKNTzCn6xvmnqFcaPtE+hXAqtBUAO+myU5mZqCjsyftIqDFBpyNeeHRDuMoVnbRn1Upnt3LMSo+MlwIu8NCYDa8CygX45MRrP1p5bLen0Zid112GYr5PHu8fHHNGQMUZilEmqmg1mUdCd45D1W+JoRxA8O6B2YWkqwqYaLxUR57gJuALsTnUwyb5B06plyyPAk2stCECH1fv49YEJraoRhW6i0a4YGqj86ZUdF7wJ0qJXG2ZiPPfpEHjUT4UiVu5Nx73Ezf1BU1seCQ== 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 VE1PR08MB5152.eurprd08.prod.outlook.com (20.179.30.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.17; Wed, 16 Oct 2019 10:34:15 +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.2347.023; Wed, 16 Oct 2019 10:34:15 +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 v5 2/4] drm/komeda: Add drm_lut_to_fgamma_coeffs() Thread-Topic: [PATCH v5 2/4] drm/komeda: Add drm_lut_to_fgamma_coeffs() Thread-Index: AQHVhA1CCsnvZq8O7EazVvpZbV4JuQ== Date: Wed, 16 Oct 2019 10:34:15 +0000 Message-ID: <20191016103339.25858-3-james.qian.wang@arm.com> References: <20191016103339.25858-1-james.qian.wang@arm.com> In-Reply-To: <20191016103339.25858-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: HK0PR04CA0006.apcprd04.prod.outlook.com (2603:1096:203:36::18) 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-Correlation-Id: aad8f177-8059-4fb3-532d-08d7522471a9 X-MS-Office365-Filtering-HT: Tenant X-MS-TrafficTypeDiagnostic: VE1PR08MB5152:|VE1PR08MB5152:|AM0PR08MB3633: 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: 0192E812EC X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(39860400002)(346002)(396003)(366004)(136003)(376002)(189003)(199004)(6506007)(4326008)(2171002)(25786009)(478600001)(66066001)(99286004)(103116003)(76176011)(52116002)(71190400001)(64756008)(71200400001)(256004)(14444005)(66446008)(66476007)(36756003)(66946007)(14454004)(66556008)(8936002)(50226002)(8676002)(386003)(81166006)(81156014)(486006)(26005)(2501003)(186003)(55236004)(2906002)(5660300002)(110136005)(1076003)(305945005)(446003)(2201001)(6486002)(6436002)(11346002)(476003)(6512007)(316002)(6116002)(3846002)(102836004)(54906003)(86362001)(2616005)(7736002); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB5152; 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: BwlzLsYKh8XrTNZ3BgzlueqRVidK4yexoJDa4gQvQMpe7SR2RMMrvfRJbK6P9eko9NF9tWHuywL+STouNPb10pCbpayA9blmHSGHfGXHI5qHIZsA3eH7RSYJDs+mcwEQpHT2Yd4LJF8IWn8Ecx3uDF3gF8dUa+3g/c9TAoZFZep8G81VUSZjGdRt6DJjRmqvyA2RdD5RiV2Gj8UqENviL1Jakt/F27ICRDrbaZjS2OroI11gk754rc9B0ptXUNLvUaTPspes6aEzKKEErRanEWHUC9ZFM+tUsmME/hG++h6tfhhyM1GooiG41eInMwxrB+kwKQEiTrqJco+TH5iVfj/bjUVDs9YmCy9QeX+763ecM7460MTHKesuHI7F2csb/a+rbxgnbszaHp/alj3QN/5/9tktfiuuJpBbJNzTLqw= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5152 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT037.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)(396003)(39860400002)(199004)(189003)(66066001)(386003)(86362001)(2201001)(356004)(110136005)(316002)(6486002)(22756006)(336012)(14454004)(25786009)(54906003)(36756003)(2501003)(14444005)(6116002)(6512007)(6506007)(76176011)(1076003)(99286004)(5660300002)(3846002)(50466002)(2906002)(102836004)(23756003)(50226002)(2171002)(478600001)(26826003)(186003)(11346002)(446003)(81166006)(126002)(305945005)(7736002)(8676002)(81156014)(4326008)(47776003)(103116003)(76130400001)(70206006)(26005)(476003)(63350400001)(8746002)(70586007)(8936002)(486006)(2616005); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR08MB3633; H:64aa7808-outbound-1.mta.getcheckrecipient.com; FPR:; SPF:TempError; 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: fff45ce9-f407-44e3-7240-08d75224648d NoDisclaimer: True X-Forefront-PRVS: 0192E812EC X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jKl66ov51fqSM4Qby6IyYLHGRt0xAdxvwqFKjoaqCzyTvys3XF+eMqPHkF3ugv0eYW2mvbyoZixOwew6OgO7izDChcxoidBxCkBsTDV1jIHrGZP1Ginh5vu6n99x8lPqWCzGUZq456N8qqjNmcufRFhurnN3f719ldwMCz6TpHXlJ2dG5HE9PMXbaQ71tgxycOjjurp1zj49ufp+ZHcurp8hvOF2QnGoXRUTGpQOCWt5DtgQI74w37NYWLy93GOkwVjldmlaLzZ1GCJ3ZLAe2XhzufQ96Zai/TDcCYY/FREbECKTsEKTdokcY7cwBs4562FMbwJefG/ZNB7oOyt8kCRvJ6winvoKfft3e52Bqt0ZtvtHsrWLOxC1JuONkQH4UTb4ZvTyTN9g50n7vTXMBAEejCuyS5s2wwBZtKWLGVs= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2019 10:34:37.4116 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aad8f177-8059-4fb3-532d-08d7522471a9 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: AM0PR08MB3633 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=L7wkSdcN1vpuLJnXkQMX7xWpStzqRpBbrl1NLhxAlkAisQ/P3bmtKKscAsHNtiRFKEm1fr6ff95YoNu0iRBtEz9H7lpkgk12cNP+3d1Ol6wPR6Vf8purYYBdMtUSE5gNAsDxyQJKQq4e6fvpkbsjwgfjnei4ITOmDLJ7vycBVv8= 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=L7wkSdcN1vpuLJnXkQMX7xWpStzqRpBbrl1NLhxAlkAisQ/P3bmtKKscAsHNtiRFKEm1fr6ff95YoNu0iRBtEz9H7lpkgk12cNP+3d1Ol6wPR6Vf8purYYBdMtUSE5gNAsDxyQJKQq4e6fvpkbsjwgfjnei4ITOmDLJ7vycBVv8= X-Mailman-Original-Authentication-Results: spf=temperror (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 16 10:34:22 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: 11192925 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 3F1C517E1 for ; Wed, 16 Oct 2019 10:34:50 +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 862F221D7F for ; Wed, 16 Oct 2019 10:34:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 862F221D7F 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 290AD6E930; Wed, 16 Oct 2019 10:34:46 +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-db5eur03on0626.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0a::626]) by gabe.freedesktop.org (Postfix) with ESMTPS id F36846E930 for ; Wed, 16 Oct 2019 10:34:44 +0000 (UTC) Received: from VI1PR08CA0107.eurprd08.prod.outlook.com (2603:10a6:800:d3::33) by AM5PR0802MB2468.eurprd08.prod.outlook.com (2603:10a6:203:a1::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.16; Wed, 16 Oct 2019 10:34:40 +0000 Received: from VE1EUR03FT038.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::209) by VI1PR08CA0107.outlook.office365.com (2603:10a6:800:d3::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2347.18 via Frontend Transport; Wed, 16 Oct 2019 10:34:40 +0000 Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT038.mail.protection.outlook.com (10.152.19.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.15 via Frontend Transport; Wed, 16 Oct 2019 10:34:39 +0000 Received: ("Tessian outbound 851a1162fca7:v33"); Wed, 16 Oct 2019 10:34:31 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 7b89b7875e6a661f X-CR-MTA-TID: 64aa7808 Received: from 552a0589a21a.2 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.13.59]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id F6CEAD20-7757-4509-8BF8-6E164F6873B2.1; Wed, 16 Oct 2019 10:34:26 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04lp2059.outbound.protection.outlook.com [104.47.13.59]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 552a0589a21a.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 16 Oct 2019 10:34:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jb5mFZlLHB1EusT3qSYG+NQyRb7kV6x5kC+ucLmy8+sY+qO7oB1kB0yxZicZAc4lmE0xQdaTX/Lz1i/9ydCAhUV3RIZF2aqpObnn8NzdWokjJx2cyHW7h7ivxTHTkXXeWtCos0QuE7XOIIM+0UFa6DtF0F3NZJNK9hS4y4UZI8bITEexTkDjsHGKFqv4it2FbvPJ97BzPv1bCLxmXNzUBy0ZiOx0G6xTnxN4QmyHZuH2GClBwjAB0E92Vx804vNwM0RU4NRq/ukPm3kuQ2orSzGdoTpeb8R8G6wDguMdhOusgVwud3yhGOb5DK/Fv4ig48FzH0/0H1MymAAWdJN2nw== 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=ZKgSHOZhRJ7Suvge3ewzIiutWAhN2qliZYJev5ZgnNUiNbo8FLQNkWEYXjcRfcVS8bKutxi82xCN07hLldYmkalrc5kp+PFeHql0k6jVUfIaJ3DJJugM7EydMyjoyglDThX8BdVGS8uRrHAxeBriNU3AL5iBi8F6d3xsNbmweqdEfQQuQJFFsVmEFxp2mUkgJn4jc8dUWgZc7qmgA6zGwXBbeDqkSBV7NKQqrioinvOfTnLa6eDjAQ5MdgjdekfD7uARZMWmLtgkkc7MSrD9ZxRk+FH1ez7G5FU7fwYuftnNkIrAjrX7Zs6mj+M3HyGB6ky47k+/c36YU6Nr8fcPww== 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 VE1PR08MB5152.eurprd08.prod.outlook.com (20.179.30.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.17; Wed, 16 Oct 2019 10:34:23 +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.2347.023; Wed, 16 Oct 2019 10:34:23 +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 v5 3/4] drm/komeda: Add drm_ctm_to_coeffs() Thread-Topic: [PATCH v5 3/4] drm/komeda: Add drm_ctm_to_coeffs() Thread-Index: AQHVhA1Gtm4BORRiPkmxAOi2mqef/g== Date: Wed, 16 Oct 2019 10:34:22 +0000 Message-ID: <20191016103339.25858-4-james.qian.wang@arm.com> References: <20191016103339.25858-1-james.qian.wang@arm.com> In-Reply-To: <20191016103339.25858-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: HK0PR04CA0006.apcprd04.prod.outlook.com (2603:1096:203:36::18) 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-Correlation-Id: b06a949c-6e4f-4033-f651-08d7522472a6 X-MS-Office365-Filtering-HT: Tenant X-MS-TrafficTypeDiagnostic: VE1PR08MB5152:|VE1PR08MB5152:|AM5PR0802MB2468: 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: 0192E812EC X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(39860400002)(346002)(396003)(366004)(136003)(376002)(189003)(199004)(6506007)(4326008)(2171002)(25786009)(478600001)(66066001)(99286004)(103116003)(76176011)(52116002)(71190400001)(64756008)(71200400001)(256004)(66446008)(66476007)(36756003)(66946007)(14454004)(66556008)(8936002)(50226002)(8676002)(386003)(81166006)(81156014)(486006)(26005)(2501003)(186003)(55236004)(2906002)(5660300002)(110136005)(1076003)(305945005)(446003)(2201001)(6486002)(6436002)(11346002)(476003)(6512007)(316002)(6116002)(3846002)(102836004)(54906003)(86362001)(2616005)(7736002); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB5152; 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: 3RgZdF6spsqYgK4RVB7WKLLVKDKw04R1xUx+L1xTYPfTqIU5tken4iy29AWLvfqCgPDS+jPreX1QpcrYDWuv5MpYpKERUFIco1HmM4HOFPY87BYGssLT1L6mgYOlBNtvmAE9zIp8anMYuYQNF9VnOIXYAiwzYodUxQtrpYiP3zEq9EnE89vAV12i5ZLA53AODMx+Uo3nwwsinAV00G2ELk2EICseBYafN7dFxruHCk2w1N/am8KPdQlC8jjAGMNDXnqv2iTrgcgMNESz6Pvcx9h+DVSwzdsTNpBEmXToyKLD4zch12lRFtHcHv+H8R+isHSS3MC+xqxS4QGmOz25gDgHjjTlacJfVkSjWPt7kbHxzaHKf5ANaNoasDMMfweDj1lvXGKCJ7BsE+3dJEmeG6kD2+1lhW41AFAoM+MUBNg= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5152 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT038.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)(346002)(39860400002)(136003)(376002)(189003)(199004)(6116002)(26005)(76130400001)(336012)(66066001)(2201001)(86362001)(356004)(2906002)(36906005)(63350400001)(446003)(8676002)(50466002)(316002)(81156014)(81166006)(22756006)(6512007)(11346002)(3846002)(2171002)(486006)(186003)(126002)(476003)(2616005)(5660300002)(8936002)(6486002)(2501003)(8746002)(14454004)(102836004)(478600001)(25786009)(47776003)(50226002)(4326008)(386003)(70586007)(110136005)(23756003)(54906003)(99286004)(6506007)(26826003)(1076003)(70206006)(103116003)(305945005)(76176011)(7736002)(36756003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0802MB2468; H:64aa7808-outbound-1.mta.getcheckrecipient.com; FPR:; SPF:TempError; 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: f3ed9998-e2d7-49d9-031c-08d7522468cc NoDisclaimer: True X-Forefront-PRVS: 0192E812EC X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: c608D2XpV1M3TIUQiACgiFwW86/rebDofxn1L4SkfhWa7YnW6uO06Z8XqhmrIxffIDiSXRG1+vA+dLIyB2pn9OXYEdbzIoIDSurTheEYL4xRKrgNCVS2f1oEOLyG9XM6OwWPn3zVN6IAjhyOQeFmeG09Yv0c3erfuCiMeD8pQXvKw39o4bBK8QdVlYJxmF4nW6gdz1lE/TAjrYKQVNskf2xiWM6OGUuSU6IAAi3AWQHDckgUgoMGg2BhtX/MIyK8PVXyO9PAgHdL0K/n6R0np135KEeKmEWIZgmgzbBE+NS9NM57neuAge0Hk192iPxx8xr1IjKfDjOJeYk/MrkbsO8cPY3VakymrisDosA/JW2TEKXh1sYAE/xA29a14tnelLuCGBbFMZZTwrgNyjWEECq0uFDB7BfLyI/pQY4cKAE= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2019 10:34:39.1008 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b06a949c-6e4f-4033-f651-08d7522472a6 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: AM5PR0802MB2468 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=ji/J+1Zp78yAUtVtVhe1tn+kYdlPjci8ONd4VJjxkgMZixi6jJgroFmYElEGM3qFBVuHDJV3MPQJo57TwFGF/O3jXN3ZKH1CvrQQGI9e0a0a7uzGfd5jZ404Tydjl2q2EpZim3AB/xX1GvZeJXEvOU/rEq0hY2cIEQvrtE5UsU4= 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=ji/J+1Zp78yAUtVtVhe1tn+kYdlPjci8ONd4VJjxkgMZixi6jJgroFmYElEGM3qFBVuHDJV3MPQJo57TwFGF/O3jXN3ZKH1CvrQQGI9e0a0a7uzGfd5jZ404Tydjl2q2EpZim3AB/xX1GvZeJXEvOU/rEq0hY2cIEQvrtE5UsU4= X-Mailman-Original-Authentication-Results: spf=temperror (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 16 10:34:30 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: 11192929 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 229CC17E6 for ; Wed, 16 Oct 2019 10:34:55 +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 9F66521925 for ; Wed, 16 Oct 2019 10:34:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9F66521925 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 CB1C36E936; Wed, 16 Oct 2019 10:34:53 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60086.outbound.protection.outlook.com [40.107.6.86]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4AF216E935 for ; Wed, 16 Oct 2019 10:34:52 +0000 (UTC) Received: from VI1PR0801CA0079.eurprd08.prod.outlook.com (2603:10a6:800:7d::23) by DB7PR08MB3322.eurprd08.prod.outlook.com (2603:10a6:5:26::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.21; Wed, 16 Oct 2019 10:34:48 +0000 Received: from AM5EUR03FT046.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::206) by VI1PR0801CA0079.outlook.office365.com (2603:10a6:800:7d::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.16 via Frontend Transport; Wed, 16 Oct 2019 10:34:48 +0000 Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT046.mail.protection.outlook.com (10.152.16.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.15 via Frontend Transport; Wed, 16 Oct 2019 10:34:47 +0000 Received: ("Tessian outbound 081de437afc7:v33"); Wed, 16 Oct 2019 10:34:41 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: ed6632e7ef1f2c9e X-CR-MTA-TID: 64aa7808 Received: from cc6315660be6.2 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.5.51]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 647D6AB5-3CFD-4314-A2A5-1A5B8AF87251.1; Wed, 16 Oct 2019 10:34:35 +0000 Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-he1eur02lp2051.outbound.protection.outlook.com [104.47.5.51]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id cc6315660be6.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 16 Oct 2019 10:34:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VwUverQXsU/W89UymcmONmasOsobpum6QDoN7kgFJvnXYvFG21DMQhFzFGEOPOzIy8ym7MTZZgRTAk3Dp6v/SRO1P4lIDdeZLrO4RIDC9DJjke8Vo0/VtPIUwJWozU9i0D/lEu1Sa8qyrdB161Y5z+7lxPPAKWQTPax8tySwcAUFbB2VoD3ifJlB2m6KfKCxdlh4rxOcO7UU6TJvaRaw52oczyCDGVaj58t6i80DPz80vz/5v8lqO4bEt19VpMJO5CR3jnX3HOY2r3gzNoXQP0HBdhHKT9ukCLQ1HGxSVqtk+85jdRNMv6ojnEPTn7Icjpp0SZhmFEKD4tEVAL+uMw== 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=aTLIBaRIXBywulqqapRfWZZE7ga1kAVvsh5MVHvOcGM=; b=YyicKbbcNMX1Gk29GMsgNBK+baTKuBo6HFM4BMZKHmv1PJNa0CERXkVmbDliMMKHtYnzNEQsueF0gEgIZXMr/6YX/1LhhtyXAJIxlBuQ2sRtKeXQScBuAbANGhXKtlHpAys1J5V9rmC3tS3ThRnxuJ0qykoSRjShM6Y7xe4HhHTs1+5xaYsBrvX9+QfzE5eS8L5YIslkJWBs1dzYmQ/oLDnP6Gq74pMDxQQWzf5zo8sGWpdmtKmM7PLSKseK84xJF7C56tqXhkuMbD7jzMrT4PWDLkHIssW5md5tQrmJnJZ1BB4CteSUrD7S9f6Ru0ubfV+gXkrG4YTQJYKGlBA3MQ== 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 VE1PR08MB5152.eurprd08.prod.outlook.com (20.179.30.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.17; Wed, 16 Oct 2019 10:34:30 +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.2347.023; Wed, 16 Oct 2019 10:34:30 +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 v5 4/4] drm/komeda: Adds gamma and color-transform support for DOU-IPS Thread-Topic: [PATCH v5 4/4] drm/komeda: Adds gamma and color-transform support for DOU-IPS Thread-Index: AQHVhA1KKjv8+ZR4kki+4DzZfnBljg== Date: Wed, 16 Oct 2019 10:34:30 +0000 Message-ID: <20191016103339.25858-5-james.qian.wang@arm.com> References: <20191016103339.25858-1-james.qian.wang@arm.com> In-Reply-To: <20191016103339.25858-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: HK0PR04CA0006.apcprd04.prod.outlook.com (2603:1096:203:36::18) 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-Correlation-Id: 5bab6739-465f-43ac-33da-08d75224777b X-MS-Office365-Filtering-HT: Tenant X-MS-TrafficTypeDiagnostic: VE1PR08MB5152:|VE1PR08MB5152:|DB7PR08MB3322: 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: 0192E812EC X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(39860400002)(346002)(396003)(366004)(136003)(376002)(189003)(199004)(6506007)(4326008)(2171002)(25786009)(478600001)(66066001)(99286004)(103116003)(76176011)(52116002)(71190400001)(64756008)(71200400001)(256004)(14444005)(66446008)(66476007)(36756003)(66946007)(14454004)(66556008)(8936002)(50226002)(8676002)(386003)(81166006)(81156014)(486006)(26005)(2501003)(186003)(55236004)(2906002)(5660300002)(110136005)(1076003)(305945005)(446003)(2201001)(6486002)(6436002)(11346002)(476003)(6512007)(316002)(6116002)(3846002)(102836004)(54906003)(86362001)(2616005)(7736002); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB5152; 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: aqLUHqH8Rkexwy/Q+geqpVkYcQCqBlQTlXgJ8kQMtQMwXvmIt93V4vwTGHpzJflQer9pVaAhLXq2ygVREDd+QkdwNdSXgHSk4pItPHhfztur42YsS5hidsnQd9aIETBR2Gngwe95/2OIyk1G6DKsGlQWDVdHvXTj7MH7/86PNQ844wSwkCzDbzCbobBXHVMHk3cQmlk5/nStZcL3NICfc9bSwEul8EDWhFOB90jvwHmxL7eNGlYt4H+99K82fMECccQ9afyep+hKA0pDZ1XOgClSvcUJ2Q4k4KUF7cDUerCwQCjtKBZnnc33TxFLRGjyzMvMi7jvlcSU4yoQHfBXcC7a7sK7rrgR66DTdYf/ihMuKbhAueBgKS6LbDd31vn0+iJBkoC2OK2carzC/8+aIM8cc/tHETBR3JmuAhMNJy4= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5152 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT046.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)(396003)(39860400002)(136003)(376002)(189003)(199004)(36756003)(63350400001)(126002)(70206006)(50466002)(54906003)(26826003)(66066001)(8676002)(7736002)(26005)(76130400001)(4326008)(336012)(478600001)(6512007)(70586007)(22756006)(14444005)(386003)(2906002)(86362001)(6506007)(102836004)(5660300002)(103116003)(2201001)(11346002)(186003)(25786009)(446003)(356004)(14454004)(1076003)(316002)(486006)(6486002)(99286004)(36906005)(8936002)(3846002)(8746002)(2501003)(2616005)(50226002)(305945005)(476003)(47776003)(76176011)(81156014)(6116002)(81166006)(110136005)(2171002)(23756003); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR08MB3322; H:64aa7808-outbound-1.mta.getcheckrecipient.com; FPR:; SPF:TempError; 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: 4e9eaf6b-3e12-4541-972e-08d752246d1a NoDisclaimer: True X-Forefront-PRVS: 0192E812EC X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: shMxGa/fKlQJb+mA2GoPwQofT/Kma6657Ilv9k1iQ3FELDi1ORbWct/olGadLQlBFkL+z1cu+U6/XXFuVDSH22jmgKtsiAY3yjjIQc/GtLUo4HFeGcyJFIjbHVcU2R/EyA4MBlY/9vCWPu6Cj+WmvOkXgRIM7CKhxJ8gR0QI/F//+8X1TBFkX7fPqGzJnYkWsJ4t5dIq44FaVh1OABPjHYgEazTykZ5pd3KEh4WOAZj4g1I8f9e+9ZJF9L7aaTpPDKIiGK/hFhVEEghuGMaJDenrjWtUlCeQbFdbTHXBiCKdEM7tEfXpt3fNofoMjgZIupZ1XQl0giL0kFppvRNayLAfPOKnINT52/zAE8psEE5HTlCaFUS1ttn0UNlGUJQOsH93ZUE/4gUwjXBnJSL2EoPAlmR0LN4j4U5t61+VEhM= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2019 10:34:47.2537 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5bab6739-465f-43ac-33da-08d75224777b 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: DB7PR08MB3322 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=aTLIBaRIXBywulqqapRfWZZE7ga1kAVvsh5MVHvOcGM=; b=v6LlkbKrB0oh022g70bFJsEIE2XHwbYRLPWUSHmTECKpbdGwFv28zaSIxIXh8C5YccpuypsBQhJiHXCEDBeywE3PAqflPkktKsHM5fqL1LTX5I7C90PZi0ukCpkfR8yHL6Vc/ggnrOJYxaZ9tHHh/g1/BFSzXybo+lXA8zDZ6S4= 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=aTLIBaRIXBywulqqapRfWZZE7ga1kAVvsh5MVHvOcGM=; b=v6LlkbKrB0oh022g70bFJsEIE2XHwbYRLPWUSHmTECKpbdGwFv28zaSIxIXh8C5YccpuypsBQhJiHXCEDBeywE3PAqflPkktKsHM5fqL1LTX5I7C90PZi0ukCpkfR8yHL6Vc/ggnrOJYxaZ9tHHh/g1/BFSzXybo+lXA8zDZ6S4= X-Mailman-Original-Authentication-Results: spf=temperror (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 6740b8422f11..63a1b6f9cbba 100644 --- a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c +++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c @@ -1032,7 +1032,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; @@ -1043,6 +1045,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);