From patchwork Tue Nov 12 11:09:59 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: 11239093 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 D326914ED for ; Tue, 12 Nov 2019 11:10:24 +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 B9D8221783 for ; Tue, 12 Nov 2019 11:10:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B9D8221783 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 A9BB36E22A; Tue, 12 Nov 2019 11:10:20 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80041.outbound.protection.outlook.com [40.107.8.41]) by gabe.freedesktop.org (Postfix) with ESMTPS id A79A96E22A for ; Tue, 12 Nov 2019 11:10:13 +0000 (UTC) Received: from VI1PR08CA0197.eurprd08.prod.outlook.com (2603:10a6:800:d2::27) by VE1PR08MB4912.eurprd08.prod.outlook.com (2603:10a6:802:a9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2430.24; Tue, 12 Nov 2019 11:10:11 +0000 Received: from VE1EUR03FT043.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::206) by VI1PR08CA0197.outlook.office365.com (2603:10a6:800:d2::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2430.23 via Frontend Transport; Tue, 12 Nov 2019 11:10:11 +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 VE1EUR03FT043.mail.protection.outlook.com (10.152.19.122) 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 11:10:11 +0000 Received: ("Tessian outbound 851a1162fca7:v33"); Tue, 12 Nov 2019 11:10:07 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 8c1b62e43d8bdea4 X-CR-MTA-TID: 64aa7808 Received: from 4b70c4a1f660.1 (cr-mta-lb-1.cr-mta-net [104.47.6.54]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 71930C17-C8E2-4B5B-8258-16B6696CBCBB.1; Tue, 12 Nov 2019 11:10:01 +0000 Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-ve1eur02lp2054.outbound.protection.outlook.com [104.47.6.54]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 4b70c4a1f660.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Tue, 12 Nov 2019 11:10:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AzosQRvGR0ujEQlIIoyKrrUK5Gz96sfNZttRoq6xfKGSSNaMaCVtBlDaVkSMbCmwYkDGetkMDnyPORsUVQhbQpnzfaU+9Kg8KSr2jYd+25ng0yNGHXWgfaAJgaZX7S6CIf7MahxxPSr+xOcEIWbmN3u5Q91qUwqRC+xO23v5AusjeIIV3ktR8KeJUfvxr/f82iL1C/IvLfD5+bM8lNNiQuaUEJqGIIqHj1dLepVBZmjC8EsIaH7ihJUhCaomE8Y27AlaRAGQjy17oqNWFvpMkQd4DWACAKPphJxnBhISrP417BpuvgJdIpO38ibtBgnQtbZKYBCl1sY0g06oBDnUIw== 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=4cVA01VPTm34igIPoloOoMRrAW1GGU6jFUdYSaPiuuk=; b=hY3CzOq7RXygXd7jfDlrzAeu/Jg+eko4WDS3oAWkC2MzrdDVnESnudIK4Gnl+DTMMePw72Yvbs0vY0FjNju0WRYUo5lVXsjN6wrXLWicHHJlf1X/ovoR02XEc3F831psD6OjfbaLpl5VM1Hcyms7F7iMt8NwiJQ0o/K/HwCVcYoKo8oEiqQOXVebv83p3Ga74rSVWE1INvDvYuliredYVFHr9kAjtoSCFfMGOgrLJLFyZcPCQ/MLrInhlc/w08iCvkskA0M0CcBpf8LJIcuA7yvPvNMv0INnzMnNLz50rvG2bQUuwpGn6JNWAErabAoowVs20LzRD2igNHhsiQjoUA== 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 AM0PR08MB3636.eurprd08.prod.outlook.com (20.177.43.89) 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 11:10:00 +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 11:10:00 +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 v10 1/4] drm: Add a new helper drm_color_ctm_s31_32_to_qm_n() Thread-Topic: [PATCH v10 1/4] drm: Add a new helper drm_color_ctm_s31_32_to_qm_n() Thread-Index: AQHVmUm5GoYUWOqrlUaBroU+1xdxlw== Date: Tue, 12 Nov 2019 11:09:59 +0000 Message-ID: <20191112110927.20931-2-james.qian.wang@arm.com> References: <20191112110927.20931-1-james.qian.wang@arm.com> In-Reply-To: <20191112110927.20931-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: HK0PR03CA0106.apcprd03.prod.outlook.com (2603:1096:203:b0::22) 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: 41e05263-a2e0-4503-f887-08d76760e2a6 X-MS-TrafficTypeDiagnostic: AM0PR08MB3636:|AM0PR08MB3636:|VE1PR08MB4912: 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)(136003)(346002)(396003)(39860400002)(376002)(366004)(199004)(189003)(2906002)(99286004)(446003)(2616005)(476003)(7736002)(66066001)(6512007)(6436002)(6486002)(11346002)(54906003)(256004)(305945005)(103116003)(110136005)(316002)(2201001)(14454004)(6116002)(2501003)(86362001)(3846002)(486006)(71200400001)(71190400001)(186003)(386003)(36756003)(1076003)(6506007)(5660300002)(81166006)(8676002)(4326008)(50226002)(26005)(76176011)(66946007)(2171002)(52116002)(81156014)(66446008)(102836004)(66476007)(64756008)(8936002)(66556008)(25786009)(55236004)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR08MB3636; 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: tYu4chbxV2kejrJxKtWJI4gl3py26hLDymUJOBXoo92pdmVZqcIauhquIHPT20GYGAbJXLnzbfaM3yTz0M7sef/eNwhCmnRD0fJXkY+QopME+N5Rd75PMcDKvgxTILyLRpOaYUVEMe9kiewbVSg4IRzN8to8vzQxvmasF1Z3xrhyCPTSzn+Bw5FvxylDuKRdS4bReT6W4KYOzWRmjjwI3uby2sTdGvHhdMvccySZjMyrSApFDhJh90Z38jsvwCJmA9/Bei5rhSJmijcfrPXZXow+6ht0mAXUEzsPm+k2LEqVPlCGBzpQKgnWAhexuyDhoyKj5JqBnpQKI1JVLHe7jXq6Mj7YAG2+TgAhWgozkXi5QIGFT8G7hydscisBXFt74lWOBKRn/w0DaUd/gzeoh+exYIertVHHBtDTdna2nlDj7cwKkdP7FMIePvGqeQ2G Content-ID: <4A2532144974164FB0D33DCB16C5AE24@eurprd08.prod.outlook.com> MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3636 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT043.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; IPV:CAL; SCL:-1; CTRY:IE; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(136003)(346002)(396003)(39860400002)(376002)(1110001)(339900001)(189003)(199004)(50466002)(2501003)(36756003)(2486003)(23676004)(76176011)(486006)(26005)(25786009)(110136005)(1076003)(446003)(11346002)(54906003)(476003)(2616005)(7736002)(76130400001)(22756006)(356004)(86362001)(305945005)(70206006)(336012)(436003)(14454004)(36906005)(386003)(6506007)(2201001)(50226002)(99286004)(105606002)(3846002)(6116002)(107886003)(66066001)(81166006)(4326008)(5660300002)(478600001)(103116003)(70586007)(8676002)(102836004)(81156014)(8936002)(2906002)(2171002)(126002)(6512007)(26826003)(6486002)(316002)(186003)(47776003); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB4912; 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: ff22d156-645f-4d84-f095-08d76760dbb1 NoDisclaimer: True X-Forefront-PRVS: 021975AE46 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1ek3i3rdUuqHO999/OcFTzkGhc5k35FLOg137e4rWaFe1r6+b9TmBbjoM5T6y0CinaijNflz1rkvTvrPAIOFftsiKJXmwYqaXyhE4PVh9wMxYHOd2+W2XTg8zhMxfnVQkFPRG0xJS8/cbVM9zgtkdxB4KdRitF0H3VpRHWi9HAmQUcUgX9bbWJcxt3s3dN0qW8MJMJQx1QuccaEiPmpjUPGZ7frhosSHDm4FivOA0shki9Y0BoL5YD1nzolyDj2c+gDe9FmXKPCs2cOUvZFc156/62Al9l5abNhNl/LmCYYVWqS0JqRGoM3cf7bxQNTM9MbliOvSjtc5wx5oVRAfr3n2tdY3dTDa4EKHdayzWFRva/yAV8xT2mEgot+MnWQLMzATHeEt6hJ7RNQe94uSLQEMEZlx+X/XSopPOJR1BWQ66lPeYzUtbkP040YXzwE0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Nov 2019 11:10:11.1798 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 41e05263-a2e0-4503-f887-08d76760e2a6 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: VE1PR08MB4912 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=4cVA01VPTm34igIPoloOoMRrAW1GGU6jFUdYSaPiuuk=; b=a7S8FA0ZNG+RFrvG7J9emCFOZWaTb+z/L/Kd4PePaCk4iMbgxgBCYJQSw0/fMEqd0wBBgQpKJqvMnC7nj6Ur2rniob/EDV+4JE1JR/02dCn3IUJ7BNIDxzY0HoejZQxltuDSCvD/QdXRqPeL4HO/WGavxF9c539tr2GP4lld6wQ= 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=4cVA01VPTm34igIPoloOoMRrAW1GGU6jFUdYSaPiuuk=; b=a7S8FA0ZNG+RFrvG7J9emCFOZWaTb+z/L/Kd4PePaCk4iMbgxgBCYJQSw0/fMEqd0wBBgQpKJqvMnC7nj6Ur2rniob/EDV+4JE1JR/02dCn3IUJ7BNIDxzY0HoejZQxltuDSCvD/QdXRqPeL4HO/WGavxF9c539tr2GP4lld6wQ= 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 | 34 ++++++++++++++++++++++++++++++++ include/drm/drm_color_mgmt.h | 1 + 2 files changed, 35 insertions(+) diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c index 4ce5c6d8de99..ba71e3b827f1 100644 --- a/drivers/gpu/drm/drm_color_mgmt.c +++ b/drivers/gpu/drm/drm_color_mgmt.c @@ -132,6 +132,40 @@ 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 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 11:10:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Qian Wang X-Patchwork-Id: 11239095 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 3715414ED for ; Tue, 12 Nov 2019 11:10:30 +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 1E55D222C1 for ; Tue, 12 Nov 2019 11:10:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1E55D222C1 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 6A8D06EB10; Tue, 12 Nov 2019 11:10: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-eopbgr20057.outbound.protection.outlook.com [40.107.2.57]) by gabe.freedesktop.org (Postfix) with ESMTPS id CBC8F6EB10 for ; Tue, 12 Nov 2019 11:10:22 +0000 (UTC) Received: from VI1PR0802CA0016.eurprd08.prod.outlook.com (2603:10a6:800:aa::26) by AM5PR0802MB2436.eurprd08.prod.outlook.com (2603:10a6:203:a1::13) 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 11:10:19 +0000 Received: from VE1EUR03FT059.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::203) by VI1PR0802CA0016.outlook.office365.com (2603:10a6:800:aa::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.22 via Frontend Transport; Tue, 12 Nov 2019 11:10:19 +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 VE1EUR03FT059.mail.protection.outlook.com (10.152.19.60) 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 11:10:19 +0000 Received: ("Tessian outbound 927f2cdd66cc:v33"); Tue, 12 Nov 2019 11:10:16 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: f0f9c5476530ba08 X-CR-MTA-TID: 64aa7808 Received: from d79f0f428efc.2 (cr-mta-lb-1.cr-mta-net [104.47.4.51]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 4F2DC11C-75F8-4723-8DD8-4A6F944CC0E3.1; Tue, 12 Nov 2019 11:10:11 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-am5eur02lp2051.outbound.protection.outlook.com [104.47.4.51]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d79f0f428efc.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 12 Nov 2019 11:10:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DHjqLln0srUgmvvp53WCZtvy0+C+NEgo86+CRTkbO6SddJrN82kKdyeAodoNg9u74MN0Pav0oeRH/T5DCihbJdneW4ylmZtrlfOuBbkTSgOk4YqFvMenVaXQn4DAVAECdCdSE5D6mbDivmUHLKbG0J5Zw/b3JP8UaWPx/2RWC4H2B3IA1EJ75j95SEBZnchlpz0YSqTtx1ZIQWsodMlDQTUrNZOKJrCPAS+Fuvmwml8YstBpUt9w89I2ui4Dk8l6DXNkeU9/9J5fU1kF52ARjfJ1ZXUaBcWtBe+4Pg1wT1do1sTirS8YF7uFBofAgM71CBlAcpQyhkl/ifQeTODDTQ== 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=PtBi0Mq6vG6CnKvSibborgddR4FZG41OJD+8tSNo/KH0NFP4EqzjfSgKUZRiqOfds/ETin62ySFFa60clBeCnmtrJ0ONYFirq1bp/JTcb9Y9XeCn9Ho+arLr1JDI5/c08p9HlfYiNQ8EyyetWG5r1vDYqSHDRIN4o13x1aWvQv8+FWvwGzw6jeQmi4sN0RL3bTxsGmxd5ccwKIkhDlwAEztuyj4YcCzXqfBU814aMuBQjSYY76KH5lJIdIFo7qRfapp/uTkfQvo6ZvxZsMysz0srlU5LGqC8H938uFVpPb9DfJatzG9/JzAT4+c58t3wMs7WkqRGy2Ev3M7YXPQq5A== 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 AM0PR08MB3636.eurprd08.prod.outlook.com (20.177.43.89) 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 11:10:10 +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 11:10:09 +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 v10 2/4] drm/komeda: Add drm_lut_to_fgamma_coeffs() Thread-Topic: [PATCH v10 2/4] drm/komeda: Add drm_lut_to_fgamma_coeffs() Thread-Index: AQHVmUm+oipHNsw4FUeM3rml3PnnBg== Date: Tue, 12 Nov 2019 11:10:09 +0000 Message-ID: <20191112110927.20931-3-james.qian.wang@arm.com> References: <20191112110927.20931-1-james.qian.wang@arm.com> In-Reply-To: <20191112110927.20931-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: HK0PR03CA0106.apcprd03.prod.outlook.com (2603:1096:203:b0::22) 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: 9e505c51-a944-4cac-993b-08d76760e785 X-MS-TrafficTypeDiagnostic: AM0PR08MB3636:|AM0PR08MB3636:|AM5PR0802MB2436: 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)(4636009)(136003)(346002)(396003)(39860400002)(376002)(366004)(199004)(189003)(2906002)(99286004)(446003)(2616005)(476003)(7736002)(66066001)(6512007)(6436002)(6486002)(11346002)(54906003)(256004)(305945005)(103116003)(14444005)(110136005)(316002)(2201001)(14454004)(6116002)(2501003)(86362001)(3846002)(486006)(71200400001)(71190400001)(186003)(386003)(36756003)(1076003)(6506007)(5660300002)(81166006)(8676002)(4326008)(50226002)(26005)(76176011)(66946007)(2171002)(52116002)(81156014)(66446008)(102836004)(66476007)(64756008)(8936002)(66556008)(25786009)(55236004)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR08MB3636; 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: efgPPhW1sIC+T2J3ud2UUGeRox9h2yMuqqqjAoHAwkPC0VELuJamMjU2TdOt2LM+MTxvtZo0wW8xi4NJAGepDA3vNNstuLhaXM5bm9zrgHLIO2Lm6paZhaYgdnLk1p+Kx0GGYI5nJ7em6Uy49sXmjGZ6cKYpmbgs4mLC+uBwZ+267ogL0eT0/WAwEBzGekuefn3eLiy7qIA8wDT5kTk+yUw/Kx+tkGKcyexLeyr1wFFcRMbKuyxnkrauroBPqQ2Q8uKwdHZS1r1z6e3HuQKWJ/i3DVeOJMw960pghVJ+n/giDek4WRjvd2YT99mV/7eTxDvtH4H28Y3edT9TjYIKpaQ22IiledFJ73aVG3o9oz3v8Yh10bXEVOQmZPpAan8caghZrp6datxVXlWDaC00gApCY2mSkO19s/DJTNdRHy5Hv0LfH2tr3gwjcda/C67p MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3636 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT059.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)(1110001)(339900001)(199004)(189003)(6512007)(76176011)(446003)(11346002)(26005)(336012)(2906002)(66066001)(356004)(76130400001)(186003)(102836004)(50466002)(22756006)(476003)(486006)(386003)(6506007)(2171002)(2201001)(3846002)(103116003)(4326008)(126002)(99286004)(6116002)(14454004)(478600001)(2501003)(47776003)(86362001)(2616005)(26826003)(70586007)(105606002)(305945005)(23756003)(316002)(8936002)(36906005)(8676002)(8746002)(7736002)(36756003)(54906003)(1076003)(50226002)(5660300002)(110136005)(6486002)(14444005)(70206006)(81156014)(81166006)(25786009); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0802MB2436; 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: e693d14d-60ac-493b-320b-08d76760e14e NoDisclaimer: True X-Forefront-PRVS: 021975AE46 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: INocy86hmmRMDToQADivMg6OdlgpMcx4fppWshJTpudTeBcEdxkhuO7p2pL114GSDxPH7Xy57XfIkCy7DoJHDRNpzztw6b0R5vpSZB4KgJofNHS8oegcI+g3IAAOoMYXMlIwdUDFYTwyH+prEreCDlDGyAg5/aWhUzvRCM5JbIyh1xXcBPy3cB1vcD20jdRwl0DUuZwx32xaEJmJn3R12ftrs1R6OZnBhB05Y+uJcE/gZGT7bwiMzXBYsR+theyFZ2H0c4CHnBJD99/teWbP6zM+oWiKXu4gDa3bFRPNKfo19SpoEaHrw9ZdLiMjc6MEUu7U3iuEeoSNpCXtzhelw4Fs9qHSnth58Dvaw4sjbtUP68LQIxXnVO8WZBeicW15bPB78I+pFeJVtqir2JVltx7wwSKO4XrbeeRpS92gg/P3tZ33cSwPWclg32SQFLcz X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Nov 2019 11:10:19.3897 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9e505c51-a944-4cac-993b-08d76760e785 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: AM5PR0802MB2436 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=Jai0NsqsHq59Sg27RJ9TlmHDByYltbZHgyuUXWYUIllQokoFCUpRsHD8iIgadgpYuW9kak7vRL2ONd4VV19OVm9qEOUnjEqlPeqN/+h4gJz8ZB+cfle4wSkh0PGb0duIZY4fSxc3pZzN5UA7ZxpC98YAONjljUWz9T8GU1N/SX0= 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=Jai0NsqsHq59Sg27RJ9TlmHDByYltbZHgyuUXWYUIllQokoFCUpRsHD8iIgadgpYuW9kak7vRL2ONd4VV19OVm9qEOUnjEqlPeqN/+h4gJz8ZB+cfle4wSkh0PGb0duIZY4fSxc3pZzN5UA7ZxpC98YAONjljUWz9T8GU1N/SX0= 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 11:10:18 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: 11239097 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 A81151747 for ; Tue, 12 Nov 2019 11:10:41 +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 8F8A1214E0 for ; Tue, 12 Nov 2019 11:10:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8F8A1214E0 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 74B516EB0D; Tue, 12 Nov 2019 11:10:40 +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-eopbgr20081.outbound.protection.outlook.com [40.107.2.81]) by gabe.freedesktop.org (Postfix) with ESMTPS id DD0986EB12 for ; Tue, 12 Nov 2019 11:10:36 +0000 (UTC) Received: from VI1PR08CA0131.eurprd08.prod.outlook.com (2603:10a6:800:d4::33) by HE1PR08MB2698.eurprd08.prod.outlook.com (2603:10a6:7:34::28) 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 11:10:31 +0000 Received: from VE1EUR03FT050.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::203) by VI1PR08CA0131.outlook.office365.com (2603:10a6:800:d4::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2430.22 via Frontend Transport; Tue, 12 Nov 2019 11:10:31 +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 VE1EUR03FT050.mail.protection.outlook.com (10.152.19.209) 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 11:10:30 +0000 Received: ("Tessian outbound 6481c7fa5a3c:v33"); Tue, 12 Nov 2019 11:10:25 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 027fd423d32f3d12 X-CR-MTA-TID: 64aa7808 Received: from ce5f38f6e7fd.2 (cr-mta-lb-1.cr-mta-net [104.47.4.59]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 8501F687-5FC8-47C7-A37C-12BEA18BA52A.1; Tue, 12 Nov 2019 11:10:20 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-am5eur02lp2059.outbound.protection.outlook.com [104.47.4.59]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ce5f38f6e7fd.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 12 Nov 2019 11:10:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IOTYJxHtNEpwd83fJdyDyzwRCL5q1RDb7OCtxvsJCFBhqv27GIFv5IcZcKlniNmu3+aIA3/cprLp1B2RcgUmQ7+Fq9QMgDUIREK9rcdpusWY/Z6nl12U2Z9o2LPWDTDqdNT494ZCn33hJQiPYNtCzcaXwB6GI1VGGibQY/aiKfO2//ZnCfHRp2a7q6pXtzfPa+uAcYutugQdmmcP0D8NehTyg/YlfTyNjUu2E4Ioq6APoXX5vAVM+6ALAwgZxyj2QCUbtgAFVLpv3KhtvPpVavTqL3jKxCQcmUJUKixiDQFyKUgOzAyqrh+66FjjNyTyzZ9WDoanO6i/O6aL+hxd3w== 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=LGQfxE9Lk28dFr/MvuBomSM8MqYAeN29QgcjW5SyQ3JrfW2CbCvs5qdiLpcBQywr6H0kHTW5D6PE8w5W2de0f9Z707r3X6sLNRFi9UmI6wHII2Tow5hC9hrbxEgw2JLCoeBPH5ux9dNuAGUsIzA9wD7Z2AjCb1Q/dV4tRZA5PPoaD3RUhZIAe552fDbzdpn4J2guBPvCRFbiIggq6GYr5FMJ2kEANhjk3VoqRFI0BPjPQzgBAfrYMpucFVBvNKBarsi5cfRFRbwCCXC48bb8iohdOJrS+8HnaxJImYvrHWaEFXtLzRBrlsBtOsUpCSCyGdqtOG8rT2s4aqvRii28bQ== 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 AM0PR08MB3636.eurprd08.prod.outlook.com (20.177.43.89) 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 11:10:18 +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 11:10:18 +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 v10 3/4] drm/komeda: Add drm_ctm_to_coeffs() Thread-Topic: [PATCH v10 3/4] drm/komeda: Add drm_ctm_to_coeffs() Thread-Index: AQHVmUnEN7Mkw/Fd7UqlRzpEzWbLAw== Date: Tue, 12 Nov 2019 11:10:18 +0000 Message-ID: <20191112110927.20931-4-james.qian.wang@arm.com> References: <20191112110927.20931-1-james.qian.wang@arm.com> In-Reply-To: <20191112110927.20931-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: HK0PR03CA0106.apcprd03.prod.outlook.com (2603:1096:203:b0::22) 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: 9d8ac2f0-5991-4108-3e1b-08d76760ee42 X-MS-TrafficTypeDiagnostic: AM0PR08MB3636:|AM0PR08MB3636:|HE1PR08MB2698: 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)(136003)(346002)(396003)(39860400002)(376002)(366004)(199004)(189003)(2906002)(99286004)(446003)(2616005)(476003)(7736002)(66066001)(6512007)(6436002)(6486002)(11346002)(54906003)(256004)(305945005)(103116003)(110136005)(316002)(2201001)(14454004)(6116002)(2501003)(86362001)(3846002)(486006)(71200400001)(71190400001)(186003)(386003)(36756003)(1076003)(6506007)(5660300002)(81166006)(8676002)(4326008)(50226002)(26005)(76176011)(66946007)(2171002)(52116002)(81156014)(66446008)(102836004)(66476007)(64756008)(8936002)(66556008)(25786009)(55236004)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR08MB3636; 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: v6S7xoxEQ6a4ktTxsZZslhXSYoGeQFJLRixLZSXbgYToQTolzVKSVn6CNY3QKzFEgTnXvpqyvr4IEG41DgqcfvpcSk7qH3uRH1DzWPXhZPf/yHI6kMCXENbHL2a65OkclUHiHvSLi+KapOGbfCyjS9nl3FzKIU8DDLN1I4nyy9X3UNzrs5ZTcbLJb0TG7virp1Kj7uckyNANTyAntTzBx7MZ/u2v9Y+JCSaeyix+OHcE22OqDBPxpAeXvAgvA4XUxchw8TIHVDfClm8bRgZb491/Bg2+r2cEFEya6kzvsFSCXthK3UIkCpn8PsUFl6AkgdrUvWXNswtUenDbFzo45p7Vr/aaM+ntDD0eQgDG+aM68cG8katPic6RyGtD801n99GrTNUXF9Grwpu3ZiNWT8q314W9IMiyqMZ2FWS33fHAiGmPIwGjRh6vSbrDR3sf MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3636 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT050.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; IPV:CAL; SCL:-1; CTRY:IE; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(376002)(39860400002)(346002)(136003)(396003)(1110001)(339900001)(199004)(189003)(3846002)(86362001)(6116002)(22756006)(4326008)(66066001)(70586007)(70206006)(1076003)(5660300002)(478600001)(2171002)(7736002)(26826003)(50466002)(316002)(47776003)(76130400001)(305945005)(2201001)(6486002)(25786009)(356004)(336012)(99286004)(110136005)(102836004)(2906002)(486006)(6506007)(386003)(6512007)(126002)(11346002)(50226002)(23756003)(105606002)(76176011)(14454004)(2501003)(8746002)(103116003)(186003)(8676002)(81156014)(54906003)(81166006)(36756003)(2616005)(8936002)(26005)(446003)(476003); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR08MB2698; 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: 305e0879-1316-4f33-2c7b-08d76760e6c4 NoDisclaimer: True X-Forefront-PRVS: 021975AE46 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: buMSyz7TNLjoeXYluCTrcAIcP69/ALh9lIRQapr1XV8aYY+mtEYdMEpZo+kCrXINugeRSPb/bkX5vPEDLtRPBExxhlJaKw8S0nT6t5N39FefRdUC4CNONkvq3mCX9W/l0AywF3FN53VOMyelSjS5dyoaAGdf5n5KgqnFTLGPjqIJx3rcCEmuZQk1+DRJyDPRTRgAJ/azjcSsW45yaLDUFDvALxQYcxPCVBzuuVH7m9R/zhuUDVIUaLOwx6/V48XowYiVyhgWdsvaWWGDIiET+3L0L0l+WRG3FNwyY2UYZwad13Bbxc0WicROOnuImvEBaI6iis9XRAdGo0ltuuqydqlWURDcMfBMvCkvYTjHxBcpzRPTdlyyrv6X1iXVO1f1xnmvhSqrtwFgL7QAkXSjrenn7W7aRBUOq/PA2KlVE8mwPAnMzFsf3vLbi7Ta/U2b X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Nov 2019 11:10:30.6913 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9d8ac2f0-5991-4108-3e1b-08d76760ee42 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: HE1PR08MB2698 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=h8GeG11ulgLAUBiVbkVEaFhHzw1PMP086RvWRq5WnCtcbvF1HyhTGW6qWm30dBcYIMfJAdiwy8ZU1z385UNJnO9Lc0YswqeGYv10hWovJ9BWifYc92fXUj8op9uKb3SUFI3vukdWNeeRMVKnKkGZNXQ9OlWfV2vUnvEGc/Mu/qE= 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=h8GeG11ulgLAUBiVbkVEaFhHzw1PMP086RvWRq5WnCtcbvF1HyhTGW6qWm30dBcYIMfJAdiwy8ZU1z385UNJnO9Lc0YswqeGYv10hWovJ9BWifYc92fXUj8op9uKb3SUFI3vukdWNeeRMVKnKkGZNXQ9OlWfV2vUnvEGc/Mu/qE= 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 11:10:28 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: 11239099 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 1B76913BD for ; Tue, 12 Nov 2019 11:10:52 +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 024C5222CE for ; Tue, 12 Nov 2019 11:10:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 024C5222CE 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 3A7C36EB12; Tue, 12 Nov 2019 11:10:50 +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-db5eur03on0622.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0a::622]) by gabe.freedesktop.org (Postfix) with ESMTPS id 07F766EB12 for ; Tue, 12 Nov 2019 11:10:42 +0000 (UTC) Received: from VI1PR08CA0133.eurprd08.prod.outlook.com (2603:10a6:800:d5::11) by AM6PR08MB4658.eurprd08.prod.outlook.com (2603:10a6:20b:c4::18) 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 11:10:38 +0000 Received: from VE1EUR03FT044.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::202) by VI1PR08CA0133.outlook.office365.com (2603:10a6:800:d5::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.22 via Frontend Transport; Tue, 12 Nov 2019 11:10:38 +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 VE1EUR03FT044.mail.protection.outlook.com (10.152.19.106) 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 11:10:37 +0000 Received: ("Tessian outbound 081de437afc7:v33"); Tue, 12 Nov 2019 11:10:35 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: a83d946742e964e9 X-CR-MTA-TID: 64aa7808 Received: from 1f1d18babe21.2 (cr-mta-lb-1.cr-mta-net [104.47.4.50]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 386D1A82-C481-45AE-A5C2-96C1125E984D.1; Tue, 12 Nov 2019 11:10:30 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-am5eur02lp2050.outbound.protection.outlook.com [104.47.4.50]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 1f1d18babe21.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 12 Nov 2019 11:10:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NGKYJbqpRpOr7fI9BHGsHaY9ebh7C5DP2v33xm0Yu8L8FAUPEXDs9z3hTv9prLqd+yYeVP2EABdWbXg0F2BdfCe3TEbIOZi/0OnwgHb8dmJ6TAkR1vtlpXWkbQnJJ3lLPt9FyzrQ8pxNsBfLXHLUJh/93uONRSgT3B2ZDlwcd87nrvikclSJiHv+tCbP0F69rE226unSiUqSBzIYlNhNZz7xR9ZmqBAqTdxiFsukZdTRDe07Uvpo60/8FMcXqfzjY0PPUEkb5KkGWRSbr97y69qvLqWKYNk577KvsPluy7kspgCK4bsC+lUwimKUyGV+7EhADzRtxfrgLoGKVEMfBg== 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=LREk9pGuKu4nbZt7Pcql8QVnWkhCzfkbROuwaIGLbGsC/tPTqDZdQlCD4KpCHAOAOniTY2EtxMGcUDZuTf3OAzF7bGJFnl71GXz99BIP+z49ER10ImSEb3jg3dq7QdwjV7RwXoZgZowMqOONOw2MbXVqZU3UrCJvmeJ0hWYjy/Y/5WtCVrmUL1BevelSZ4CIJDN4MtYTS3vZT1Yf3SqnrOqeZ1Dnzx4IA1nDmoKmySIqRa++/MIlU+KOKOsZRDxaC0+cyvoUAFuqfTAkLqkYOuyP7cfhIbHphl7UeZ9z+4b4ipn9U7U60nZkfPosp3u/s2n9O+0CEhD0W30ZqDDY8w== 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 AM0PR08MB3636.eurprd08.prod.outlook.com (20.177.43.89) 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 11:10:28 +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 11:10:28 +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 v10 4/4] drm/komeda: Adds gamma and color-transform support for DOU-IPS Thread-Topic: [PATCH v10 4/4] drm/komeda: Adds gamma and color-transform support for DOU-IPS Thread-Index: AQHVmUnKXB2pUdf+WkK/8QFKQOe03w== Date: Tue, 12 Nov 2019 11:10:28 +0000 Message-ID: <20191112110927.20931-5-james.qian.wang@arm.com> References: <20191112110927.20931-1-james.qian.wang@arm.com> In-Reply-To: <20191112110927.20931-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: HK0PR03CA0106.apcprd03.prod.outlook.com (2603:1096:203:b0::22) 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: 1b52562e-71cc-44ef-5404-08d76760f298 X-MS-TrafficTypeDiagnostic: AM0PR08MB3636:|AM0PR08MB3636:|AM6PR08MB4658: 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)(136003)(346002)(396003)(39860400002)(376002)(366004)(199004)(189003)(2906002)(99286004)(446003)(2616005)(476003)(7736002)(66066001)(6512007)(6436002)(6486002)(11346002)(54906003)(256004)(305945005)(103116003)(14444005)(110136005)(316002)(2201001)(14454004)(6116002)(2501003)(86362001)(3846002)(486006)(71200400001)(71190400001)(186003)(386003)(36756003)(1076003)(6506007)(5660300002)(81166006)(8676002)(4326008)(50226002)(26005)(76176011)(66946007)(2171002)(52116002)(81156014)(66446008)(102836004)(66476007)(64756008)(8936002)(66556008)(25786009)(55236004)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR08MB3636; 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: ZcQSEobQAwvDHgwghG8xPqBZs5Y9xYTiJO7DVWJSkdQU4BRD5+dmIe6ViqfluZA5NwO0yNQPorUA0jH3S9daytjE0zS5bTynhSJVQSxpkVLXGwr21BsxBStwTVOH4IfWaB8xvlwPA1nc3FsJzLLitBgg2J9Ttj3FxWPD1kh3EJgQDBbK3HRcqbyD0VThGGKsXYm7pRW/mHRTzUh+HMw2GkgaLcGvLKgjEgM1PBzExExqEk8pCBCkrkU0MtOkl3gvY5KcMo28aVHKWNy2uesZVT8Jpl2Qxl8elZCLG8u9BEAuY6WsoaVqeRIvw/buWUXdApjJhvgcLdB13WT5mXMMvlRk4kNy6szVz8HyNEMwgxBkPiK8T811Vc9ixjEX34RCsLjU8zqw3GLhe5CBa+/CO5ecGVpjg/vIWhX7c0xDO+V0we2iUnfnNHT9VEcbqRLQ MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3636 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT044.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; IPV:CAL; SCL:-1; CTRY:IE; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(136003)(39860400002)(346002)(376002)(396003)(1110001)(339900001)(199004)(189003)(70206006)(54906003)(476003)(2616005)(2171002)(486006)(23756003)(99286004)(356004)(126002)(86362001)(8936002)(2501003)(186003)(4326008)(7736002)(76130400001)(8746002)(446003)(105606002)(5660300002)(50226002)(386003)(6506007)(22756006)(26005)(110136005)(2201001)(11346002)(70586007)(305945005)(103116003)(76176011)(102836004)(336012)(2906002)(66066001)(25786009)(50466002)(478600001)(36756003)(1076003)(6512007)(6486002)(36906005)(8676002)(316002)(47776003)(81156014)(81166006)(6116002)(3846002)(14454004)(26826003)(14444005); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR08MB4658; 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: 74479d40-06fa-44af-5c4e-08d76760eca5 NoDisclaimer: True X-Forefront-PRVS: 021975AE46 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EvZjt1rvDsHvcTON6ne/wpUB/tQn77W510yxSRbZQd9N08gNVwdgrIvZfnKuzFu9JTaokKh118TNnYFbsKZj4Y+vnfvLu6cjjD0PoYKTOlzRuyk6IlcGc/N1IwFgHOdD5Xs8OkjxUDCRyoNmC5xaqVJmY2xpA7VAY/2DKMCw+gC8+UCY5QUrIGcM8fh3XlKl5+LXsZsBl6AgjR8NF7wBMztGfzVa3eIS0zz90d3jXuTthIp7KHOdgjhkkEyIX2X6r/cbYPm/mwAK79uFXpDj4ESi0Dyn4XK6CHA3r9RHMgNxSp2qUt+wv5sxuPbIjljNcz6KC9BhLFNnCYokhnJN1tKgWhDssCyJo7CIXI3cUq2cqa1Gj0r8lQAbpCwGr4L+6a5J8RaJHCDX6Lnew9MOHHOlBOh+5O/Fcoo/W8/f9OfPuJguQnByhVGrDOYMUiti X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Nov 2019 11:10:37.9694 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1b52562e-71cc-44ef-5404-08d76760f298 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: AM6PR08MB4658 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=Jg3VvbJRrIKCj3qicJQjXB8r4R7iHRiMi1Wk6dGoQBN2uPhQa69Pi3QDVVVocMJdZs3Z+XhENDMlw2WBQgJ7dvP+DVb0l4aEz9OhUjetiInVtRHYyZa0x4wNlOc/esMKqHnIfcgcZSEzCK42VIV4g2Lu1m2HuJN+scQMbNhdv/Y= 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=Jg3VvbJRrIKCj3qicJQjXB8r4R7iHRiMi1Wk6dGoQBN2uPhQa69Pi3QDVVVocMJdZs3Z+XhENDMlw2WBQgJ7dvP+DVb0l4aEz9OhUjetiInVtRHYyZa0x4wNlOc/esMKqHnIfcgcZSEzCK42VIV4g2Lu1m2HuJN+scQMbNhdv/Y= 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);