From patchwork Mon Oct 21 07:23:04 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: 11201459 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 4521C1515 for ; Mon, 21 Oct 2019 07:23:28 +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 1E98F2070B for ; Mon, 21 Oct 2019 07:23:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1E98F2070B 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 6D78E899DE; Mon, 21 Oct 2019 07:23:27 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130083.outbound.protection.outlook.com [40.107.13.83]) by gabe.freedesktop.org (Postfix) with ESMTPS id DF780899DE for ; Mon, 21 Oct 2019 07:23:25 +0000 (UTC) Received: from DB7PR08CA0030.eurprd08.prod.outlook.com (2603:10a6:5:16::43) by VE1PR08MB4765.eurprd08.prod.outlook.com (2603:10a6:802:a5::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.18; Mon, 21 Oct 2019 07:23:19 +0000 Received: from AM5EUR03FT039.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::207) by DB7PR08CA0030.outlook.office365.com (2603:10a6:5:16::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2367.21 via Frontend Transport; Mon, 21 Oct 2019 07:23:19 +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 AM5EUR03FT039.mail.protection.outlook.com (10.152.17.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.15 via Frontend Transport; Mon, 21 Oct 2019 07:23:19 +0000 Received: ("Tessian outbound 0939a6bab6b1:v33"); Mon, 21 Oct 2019 07:23:13 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 28a8ee9281b6052d X-CR-MTA-TID: 64aa7808 Received: from 456afc599ee0.2 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.13.53]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 4A6EA28C-A1ED-4DEE-97E0-03A795C9CCA7.1; Mon, 21 Oct 2019 07:23:08 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04lp2053.outbound.protection.outlook.com [104.47.13.53]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 456afc599ee0.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 21 Oct 2019 07:23:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QzvYfTKOHjppEG3iQ19HC+AeCS1cewHJDDGbglKOoAGAEPKHIloXsSi4kCuA4CimlxMN8pfna0WZuKZ67mDWHlqM1y2TM10V8QFz0vlx8o5zAVI38OqRBKHoyf7C+CUGXHQQjNyBrq51cu9L0CwcqvBla4oJJMmjcbp1QGPOHue00vX8OJ8SjT8XLRpreFyjG7xiiP0QI7aTUJmM177Z1PSsLryIk9unhUqhR3Z6RS7woeDluQbDUr8mTA6rb2fwhS3jFtKMWnxLdc3BwNqrl4jE188QBNujio/h23kkoNelM+LtdsTF+W89pwF3vPM2nhg1f4/bHI+kPryqv2OrOw== 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=020OchYj8JijBAHrdWnnn2VDtH8VH1V9dp9hCVh+FOI=; b=FDtaLFi032/u6iVX8q6BqWqvoUfngqcRK9HSeMwyYndfj6PQi20MDLcO6Xc6uW9NBcH79CtR2+mCsNwQI0fgze3sit7LsEb+47tCRmwCT8hBp3AO0U9DuoZlP7c6gU7NuDC/Tnu+UsvVcCV76iDLs2ZhLRK1bklhCR+7tYOsmKAZbWHo7tI41bpffX9xQ4djV47gTOhcNgeAX/OZCmD7elU/uO11/3Fy/dg2X/UaihZ+r+lpz08f2b5x2Vmnv99ICaqeEfFmNcP2+ddmZ14Q7ZrPi5yqZ9ceSqFxoFN0scrnNkGfXvq1J9HkUIVcZdKEJ6ZlHQNGGNYb3gtkqDVSzg== 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 VE1PR08MB4831.eurprd08.prod.outlook.com (10.255.115.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.21; Mon, 21 Oct 2019 07:23:04 +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.028; Mon, 21 Oct 2019 07:23:04 +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 v6 1/4] drm: Add a new helper drm_color_ctm_s31_32_to_qm_n() Thread-Topic: [PATCH v6 1/4] drm: Add a new helper drm_color_ctm_s31_32_to_qm_n() Thread-Index: AQHVh+Bgb3FMRWa44UmY+hx9enDm4A== Date: Mon, 21 Oct 2019 07:23:04 +0000 Message-ID: <20191021072215.3993-2-james.qian.wang@arm.com> References: <20191021072215.3993-1-james.qian.wang@arm.com> In-Reply-To: <20191021072215.3993-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: HK2PR0401CA0019.apcprd04.prod.outlook.com (2603:1096:202:2::29) 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: f85587ba-508d-42bf-00a0-08d755f78c06 X-MS-Office365-Filtering-HT: Tenant X-MS-TrafficTypeDiagnostic: VE1PR08MB4831:|VE1PR08MB4831:|VE1PR08MB4765: 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: 0197AFBD92 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(346002)(366004)(39850400004)(396003)(136003)(376002)(199004)(189003)(110136005)(6506007)(6486002)(386003)(66066001)(4326008)(8676002)(66946007)(54906003)(99286004)(103116003)(36756003)(6512007)(6436002)(66446008)(64756008)(66556008)(66476007)(55236004)(2171002)(102836004)(2501003)(26005)(14454004)(186003)(81156014)(81166006)(2201001)(478600001)(11346002)(446003)(316002)(2906002)(7736002)(86362001)(71190400001)(71200400001)(256004)(6116002)(25786009)(305945005)(486006)(3846002)(76176011)(52116002)(5660300002)(8936002)(2616005)(476003)(1076003)(50226002); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB4831; 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: 3WWo5SJgScHodatl5YBdY/DvIHZmhF0p+ouACCv/LDiv4iH1s7JHtK0maMaCHYqMbuM36Jp9A+UDIAqCF3MUuOl8BfZxIdoj8hgu654K5ks8+NImXoI9mln6eTIXTz4vqB+ZdLjSOH/0QCxguboPWL29zeMh+781jopwcoyVW3zY4xnnlHmhPHLeCsAS2aPcnumb2JWait4FaUgWEl49MDAwSAxhorePxiCsYgNHjVYnKef7hoi+6WoKpRbRd6Im8Wl0gy1fPdHK46iGM8BhDObpLYOCHPupJTiI2aycsJ0tig3zYZOKxDwwQam+LpepeYZ18pn8RixVNAYblnsK5xTDsOkDgefRaQb2BOfRywckvR36QHQ2yI403Tgg72s8Ojbtahax6Mxt1Vjmr9VOi4567LWVNnq1ZFtNauK7Gw4= Content-ID: MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4831 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT039.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)(1076003)(50466002)(316002)(107886003)(103116003)(54906003)(26826003)(8936002)(2501003)(47776003)(36906005)(5660300002)(356004)(70586007)(76130400001)(110136005)(70206006)(2171002)(2906002)(25786009)(86362001)(36756003)(63350400001)(436003)(126002)(6486002)(3846002)(486006)(102836004)(26005)(2201001)(6116002)(476003)(2616005)(11346002)(446003)(23676004)(2486003)(76176011)(81166006)(81156014)(22756006)(6512007)(336012)(478600001)(66066001)(50226002)(14454004)(186003)(7736002)(305945005)(386003)(6506007)(4326008)(99286004)(8676002); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB4765; 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: 736cf389-191b-4bc0-96dd-08d755f782d9 NoDisclaimer: True X-Forefront-PRVS: 0197AFBD92 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gb1fL4sW0x+yXWJlC8XW5sL+QgRniINiTntW3/VM/LghNlV2a3uWqGhmmtvPbEinIFg5kQj+FwCz+eNQNWOAkCMJBiUNzvUtznTxh7zgSgl1QUByqU2G8lWC/JiCPA8XeW4DyKMvRuhfpO4uHbrShDzR38YJaYzwr4Lgd23nZGS3ebvinHu2CR1N6NfWrKcuW8013hINCkE346Qb2Ii0Oi3AUZ9nroPS1JdCExM18ugtyeglt2aT04LMzLb+0kIFb0iWAzjA/ZLBSrYZ++sPs6qrBdTnW+eD/WcuWlXlRJhChzMBR7uFrz5BsdTm/TT0ywB0XF0+exzDWPAUxEAWBE9mVRu0T0T0MdF8Jf5sOaAbF8Yd7O8LbZIbdvrBHbJwhXqfEy+xMom9qhcbXl0gOm/iecTjsnx9N/qVWUHk754= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2019 07:23:19.0131 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f85587ba-508d-42bf-00a0-08d755f78c06 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: VE1PR08MB4765 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=020OchYj8JijBAHrdWnnn2VDtH8VH1V9dp9hCVh+FOI=; b=vXQeeRw3ZyCbhNI+z9WrEIS42R0jBbrH08+W3L5Eo8k0BbnJHkzV9ZSqOmuCys7FLPlrpnePBEWY3FoCclgC/jwPa33Xfgf7eoicRRGkrdYoCIoP6MiSvAqr6/FGqA1qQf9eKeKBql6n20763K/gfMyc1XVDvrbhZvNfxnY8zEU= 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=020OchYj8JijBAHrdWnnn2VDtH8VH1V9dp9hCVh+FOI=; b=vXQeeRw3ZyCbhNI+z9WrEIS42R0jBbrH08+W3L5Eo8k0BbnJHkzV9ZSqOmuCys7FLPlrpnePBEWY3FoCclgC/jwPa33Xfgf7eoicRRGkrdYoCIoP6MiSvAqr6/FGqA1qQf9eKeKBql6n20763K/gfMyc1XVDvrbhZvNfxnY8zEU= 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). V6: Allows m == 0 according to Mihail's comments. Signed-off-by: james qian wang (Arm Technology China) Reviewed-by: Mihail Atanassov Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_color_mgmt.c | 36 ++++++++++++++++++++++++++++++++ include/drm/drm_color_mgmt.h | 2 ++ 2 files changed, 38 insertions(+) -- 2.20.1 diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c index 4ce5c6d8de99..0f833470d049 100644 --- a/drivers/gpu/drm/drm_color_mgmt.c +++ b/drivers/gpu/drm/drm_color_mgmt.c @@ -132,6 +132,42 @@ uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision) } EXPORT_SYMBOL(drm_color_lut_extract); +/** + * drm_color_ctm_s31_32_to_qm_n + * + * @user_input: input value + * @m: number of integer bits, only support m <= 32, include the sign-bit + * @n: number of fractional bits, only support n <= 32 + * + * Convert and clamp S31.32 sign-magnitude to Qm.n (signed 2's complement). The + * higher bits that above m + n are cleared or equal to sign-bit BIT(m+n). + * the range of value is [-2^(m-1), 2^(m-1) - 2^-n] + * + * For example + * A Q3.12 format number: + * - required bit: 3 + 12 = 15bits + * - range: [-2^2, 2^2 - 2^−15] + * + * NOTE: the m can be zero if all bit_precision are used to present fractional + * bits like Q0.32 + */ +uint64_t drm_color_ctm_s31_32_to_qm_n(uint64_t user_input, + uint32_t m, uint32_t n) +{ + u64 mag = (user_input & ~BIT_ULL(63)) >> (32 - n); + bool negative = !!(user_input & BIT_ULL(63)); + s64 val; + + WARN_ON(m > 32 || n > 32); + + + val = clamp_val(mag, 0, negative ? + BIT_ULL(n + m - 1) : BIT_ULL(n + m - 1) - 1); + + return negative ? -val : val; +} +EXPORT_SYMBOL(drm_color_ctm_s31_32_to_qm_n); + /** * drm_crtc_enable_color_mgmt - enable color management properties * @crtc: DRM CRTC diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h index d1c662d92ab7..60fea5501886 100644 --- a/include/drm/drm_color_mgmt.h +++ b/include/drm/drm_color_mgmt.h @@ -30,6 +30,8 @@ struct drm_crtc; struct drm_plane; uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision); +uint64_t drm_color_ctm_s31_32_to_qm_n(uint64_t user_input, + uint32_t m, uint32_t n); void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc, uint degamma_lut_size, From patchwork Mon Oct 21 07:23:12 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: 11201461 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 E49131515 for ; Mon, 21 Oct 2019 07:23:35 +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 C5C392089C for ; Mon, 21 Oct 2019 07:23:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C5C392089C 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 10A9C899E9; Mon, 21 Oct 2019 07:23:35 +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-eopbgr80074.outbound.protection.outlook.com [40.107.8.74]) by gabe.freedesktop.org (Postfix) with ESMTPS id ED4CD899E9 for ; Mon, 21 Oct 2019 07:23:33 +0000 (UTC) Received: from VI1PR08CA0232.eurprd08.prod.outlook.com (2603:10a6:802:15::41) by DB8PR08MB5084.eurprd08.prod.outlook.com (2603:10a6:10:38::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.18; Mon, 21 Oct 2019 07:23:29 +0000 Received: from AM5EUR03FT034.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::203) by VI1PR08CA0232.outlook.office365.com (2603:10a6:802:15::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2367.22 via Frontend Transport; Mon, 21 Oct 2019 07:23:29 +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 AM5EUR03FT034.mail.protection.outlook.com (10.152.16.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.15 via Frontend Transport; Mon, 21 Oct 2019 07:23:27 +0000 Received: ("Tessian outbound 0cf06bf5c60e:v33"); Mon, 21 Oct 2019 07:23:21 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 7eafda87506444b9 X-CR-MTA-TID: 64aa7808 Received: from 73989a51e813.2 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.13.50]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id EC0A171C-D314-4E7B-89FE-5D5D8F8BAB27.1; Mon, 21 Oct 2019 07:23:16 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04lp2050.outbound.protection.outlook.com [104.47.13.50]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 73989a51e813.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 21 Oct 2019 07:23:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HyxXP9X7LBRNJmytOUaju3IBymj10TS9WC5AGf8duQRwsguJ7f22730RsykTBsPzgM3X5Rp9It3b3dvJJomksjcRbyiuGYDGD96jIGcEzA5HjgWPz2LuHsTvkxzLdkRQpKVo520xELxQmeRyj0xf907ekKFbvAfnpysM0XMUMfMHcvt24tcFj13fKsHOQhbcxMVazA9Szt6p9yQhCGPQcgc9c2lD0AOp8+KfCx2eY0d55WEbln1UYNEcvX2Vqae/RrFg2fl/248mk7hfeib7Oz9qh0ab+T+UMgyie+xYNlqv/OHvme8Aj3ulrTQMWNr1gRXM8VyA+c1Ly7py7vM1kA== 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=bbcrNtHVcGVsvNKohsG+dSik7Nfojqr06gbZpzk5DxLEwqhGK4vOH5zkh+hB73kHUdwJTBSkMoOB9noIozFaugmn9tc7MtVk5IPV8ONINfr7Ip9FpvAMoHKuZdbibWZNa5plhj+9dLHJUdtm5En+7rCAKGq5Tw2oUy/+JttHqiiP8n5fEm+N2ofEibVEw3RYDVJIbtosYtu0nGxCqzMAlRKKwIK07cq0iLRn8/0f1WRdDSrsaWIlEl5tBI02Qs2mf27RG8I1TcUkPW2qDt6BLjIErowGHqva2ZPvRW9dk2EAF55uZ34zh8d3DFFJQvvhpBpPHzY4iI3SbNMUjezIXA== 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 VE1PR08MB4831.eurprd08.prod.outlook.com (10.255.115.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.21; Mon, 21 Oct 2019 07:23:12 +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.028; Mon, 21 Oct 2019 07:23:12 +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 v6 2/4] drm/komeda: Add drm_lut_to_fgamma_coeffs() Thread-Topic: [PATCH v6 2/4] drm/komeda: Add drm_lut_to_fgamma_coeffs() Thread-Index: AQHVh+BlOncB8sw6wk+4WVNM6w1Zjg== Date: Mon, 21 Oct 2019 07:23:12 +0000 Message-ID: <20191021072215.3993-3-james.qian.wang@arm.com> References: <20191021072215.3993-1-james.qian.wang@arm.com> In-Reply-To: <20191021072215.3993-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: HK2PR0401CA0019.apcprd04.prod.outlook.com (2603:1096:202:2::29) 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: 2572eb8f-7889-47a1-6354-08d755f7915d X-MS-Office365-Filtering-HT: Tenant X-MS-TrafficTypeDiagnostic: VE1PR08MB4831:|VE1PR08MB4831:|DB8PR08MB5084: 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: 0197AFBD92 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(346002)(366004)(39850400004)(396003)(136003)(376002)(199004)(189003)(110136005)(6506007)(6486002)(386003)(66066001)(4326008)(8676002)(66946007)(54906003)(99286004)(103116003)(36756003)(6512007)(6436002)(66446008)(64756008)(66556008)(66476007)(55236004)(2171002)(102836004)(2501003)(26005)(14454004)(186003)(81156014)(81166006)(2201001)(478600001)(11346002)(446003)(316002)(2906002)(7736002)(86362001)(71190400001)(71200400001)(256004)(6116002)(25786009)(305945005)(14444005)(486006)(3846002)(76176011)(52116002)(5660300002)(8936002)(2616005)(476003)(1076003)(50226002); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB4831; 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: ALri2EBbuhxCABmXnTVF9PhiSWmGD8ZwycnPKPfflyrPpuxaAalzosPy1riG5duGdRQprhIJ+vDhKgO2WxNa/A6nOAZIxjvvq2b1mmu9Fmia/pCGm20mioBLWHnhOz8M9fzzLpiO5j1Si6aPqMfldZqNqvltC+JwW5soYSy8i+48ocLdC9cKr2Ocdu91FBjCQzwwnKu3bv/O2/ejyuyIBhVqBweJIT13qLbr+I4Wz8HLfBI6dQBxUEEc382lnFlE9P5pChPtofwyfGprnJRWO7rE5dGq4jWhEpu8ZEcR2O9y+TMlbcWXK2E0rU3eIzB51hhm7mLdfWAoRhVImaSj9LBnyFXzc7GQTJkPYzr7+xJZE7VqQR+hX3Tcb9OqnOTL+4RXq+8T7kI4s9lO1IrHECV86sKMWIPNc6IVonKXKb0= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4831 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT034.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)(396003)(346002)(39860400002)(136003)(199004)(189003)(36756003)(6486002)(86362001)(5660300002)(2906002)(70206006)(4326008)(2171002)(50466002)(6512007)(3846002)(6116002)(66066001)(2501003)(2201001)(76130400001)(1076003)(316002)(70586007)(36906005)(47776003)(14444005)(2616005)(476003)(23756003)(356004)(50226002)(22756006)(26005)(110136005)(11346002)(126002)(478600001)(446003)(8746002)(7736002)(54906003)(305945005)(25786009)(386003)(103116003)(6506007)(486006)(99286004)(102836004)(186003)(26826003)(81166006)(8936002)(8676002)(14454004)(336012)(81156014)(63350400001)(76176011); DIR:OUT; SFP:1101; SCL:1; SRVR:DB8PR08MB5084; 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: 645e2568-bbdd-49cf-32cf-08d755f787ed NoDisclaimer: True X-Forefront-PRVS: 0197AFBD92 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3gTffOL44Luu5nCIkEnuERgghE5qW9oAv7KVWIEaHYegsOYclSr3t0XPsRXeUXSellvb9RUgPM51UezKLQKce12hjY6wFBT6zpIEi0WFPwOhDkbbRvVwSCalWqhfpxxOadtYnz/6tCE5gz9brW91TahW/HAJcb605sNTkmo1BzWWeXMhj+BMCGx/YZYrpkjOJUp2H6htW2kfVI9wZY31yyuK4ThPRw+cGqLc5BoJekuoBJRHCJ8EDcGyZezJH5yMW6IZkjaaCY6W7KRqmKdM+naAcz7L/zeJ5EZDMrE+5fWrMRPStWvHvoOyZzypvheuQ1y8lkvv+BZbgevfm3Cq+c9u+fzyWAzctVHpcZpyTZebhc/N+vM223RwpDgkXemItcXKq/EbpQIXswxRlbqTiX+OQwGz+U5ThLIBDqi6V/EsTYbcxRU4cKkBBa79EJGY X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2019 07:23:27.9773 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2572eb8f-7889-47a1-6354-08d755f7915d 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: DB8PR08MB5084 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=k1Gi4kU6Af9s09nSoybt04gZWl4g5NNZDHuFxLt0/evWrL+fxBYjm7lWLHG31DxljzVFe/ozdfYqQY2eX5E44iLIp2rDeK4OKtmuJIphqqVtivk0XOWzCVrKtcF3JiyCISraStgaQ7Nn5OV1YOJ3jjQt5sknhDz2zynzeTO+YNk= 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=k1Gi4kU6Af9s09nSoybt04gZWl4g5NNZDHuFxLt0/evWrL+fxBYjm7lWLHG31DxljzVFe/ozdfYqQY2eX5E44iLIp2rDeK4OKtmuJIphqqVtivk0XOWzCVrKtcF3JiyCISraStgaQ7Nn5OV1YOJ3jjQt5sknhDz2zynzeTO+YNk= 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 Mon Oct 21 07:23:20 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: 11201463 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 428AC14E5 for ; Mon, 21 Oct 2019 07:23: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 28BC420B7C for ; Mon, 21 Oct 2019 07:23:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 28BC420B7C 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 5EA3F899F2; Mon, 21 Oct 2019 07:23:40 +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-eopbgr60049.outbound.protection.outlook.com [40.107.6.49]) by gabe.freedesktop.org (Postfix) with ESMTPS id B8F5A899F2 for ; Mon, 21 Oct 2019 07:23:37 +0000 (UTC) Received: from VI1PR0802CA0046.eurprd08.prod.outlook.com (2603:10a6:800:a9::32) by AM6PR08MB3605.eurprd08.prod.outlook.com (2603:10a6:20b:48::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2367.20; Mon, 21 Oct 2019 07:23:34 +0000 Received: from AM5EUR03FT043.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::206) by VI1PR0802CA0046.outlook.office365.com (2603:10a6:800:a9::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2367.21 via Frontend Transport; Mon, 21 Oct 2019 07:23:34 +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 AM5EUR03FT043.mail.protection.outlook.com (10.152.17.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.15 via Frontend Transport; Mon, 21 Oct 2019 07:23:32 +0000 Received: ("Tessian outbound 927f2cdd66cc:v33"); Mon, 21 Oct 2019 07:23:28 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 770fbb7ace524f3e X-CR-MTA-TID: 64aa7808 Received: from fae602638719.2 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.8.58]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 9791980E-354E-46AC-846C-91DFE96FBF6F.1; Mon, 21 Oct 2019 07:23:22 +0000 Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-am5eur03lp2058.outbound.protection.outlook.com [104.47.8.58]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id fae602638719.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Mon, 21 Oct 2019 07:23:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oQz6ScPRp49Sou41ysKSM5FvnXaCfEmsDYw6TzXqOKh9PyLXanuXW+IMvH/Fawo+c+GwsyYzKWTPYal/WxJFmJouYoytJkA9CfsfewZdDJWPof/K0eBtle2tBkHZ1gTWlo+avBPivEaH/0Y50nlJo5eSMoDVtGyrfTUroMe5A47XulR86ICmNk1VE+46XrAxSvgE1Z5DuR/EwxqFUmu6AddPBGVkZa2kULNthwgCfwKvqwtOrQFxX8cKJy79TkunwqczbNbJ5gr+W8yHlGm7/1QGgoHl62Wo+zOk3148ZTUMpIgMUOtldpaUMTKs4DAMM8rwHhGV9BNh32WLt+DLhQ== 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=RytdKtUpRG+RmgqI6xuAKm27LOZ/YYETg82RtMZpej4Z7FcjAm+FwOkeWwTubDPDQd0YWZEnHULBqOjMewdG2AgO2J17jgXFla8P4PBxmwHVQBlJJAdRcbCLwFjscVySdzC19eTBeUYF0dski8slxePRdBo+HYggYwACS9W0FJvU0+XuJ/IM6M+PKiNkTohAkqH0PiSgzODA86F1D36tWXyOy/A5HaGVYNFLJqfINzjMT9uojh6Ig++mr3qb6KuY145SfMOaN3ZOwoZs+lz7GijSLyMpCH09V/npTKGm2lT2dlM7jCQTiCdAYwNOmOg4nC/lBpZVSOR/5Rxa13R1WA== 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 VE1PR08MB4831.eurprd08.prod.outlook.com (10.255.115.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.21; Mon, 21 Oct 2019 07:23:21 +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.028; Mon, 21 Oct 2019 07:23:21 +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 v6 3/4] drm/komeda: Add drm_ctm_to_coeffs() Thread-Topic: [PATCH v6 3/4] drm/komeda: Add drm_ctm_to_coeffs() Thread-Index: AQHVh+BqsLSH/wZFl0yjO/mZcFyErw== Date: Mon, 21 Oct 2019 07:23:20 +0000 Message-ID: <20191021072215.3993-4-james.qian.wang@arm.com> References: <20191021072215.3993-1-james.qian.wang@arm.com> In-Reply-To: <20191021072215.3993-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: HK2PR0401CA0019.apcprd04.prod.outlook.com (2603:1096:202:2::29) 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: 8fc5c24b-31e4-46b0-309d-08d755f79440 X-MS-Office365-Filtering-HT: Tenant X-MS-TrafficTypeDiagnostic: VE1PR08MB4831:|VE1PR08MB4831:|AM6PR08MB3605: 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: 0197AFBD92 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(346002)(366004)(39850400004)(396003)(136003)(376002)(199004)(189003)(110136005)(6506007)(6486002)(386003)(66066001)(4326008)(8676002)(66946007)(54906003)(99286004)(103116003)(36756003)(6512007)(6436002)(66446008)(64756008)(66556008)(66476007)(55236004)(2171002)(102836004)(2501003)(26005)(14454004)(186003)(81156014)(81166006)(2201001)(478600001)(11346002)(446003)(316002)(2906002)(7736002)(86362001)(71190400001)(71200400001)(256004)(6116002)(25786009)(305945005)(486006)(3846002)(76176011)(52116002)(5660300002)(8936002)(2616005)(476003)(1076003)(50226002); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB4831; 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: JYP/2F8ql3ReP+WqFtop8aEapL76Fmdpf8q9t7VZKb31uJGA8KDyL9KYIU2yLCi4b+ttkTNXXXPaXaSQV52siaOAuwbPtZ3Yf7AfU47ML91pNADPiqGeWDrwuZI0GerIDdxfVS6mZzwPsBkoANOETqP6UMhC2K+uV7cqFMoj2d4JsJj0EDMhkC+YUuImbJY2NP0jq8yuwdJxEGVQy9LkOPEc28PLDvWtzkp4fb6PQvlq+9tzunQmFSPd04P/x2fTwqupNU1EQpGaSXaxwY6x3/yI0niqbPAVcmguAe9jKiFiHf7c1ScEa2Q3gtKpJlIuQDiIaYzyW4+wXB4Qyw4EWRmQL2X/UThvwJ2pTBtvVlSuWbwDAuG2KK4dv5pWL/1tfz8U58B4OQ1gaWv29Kth5u+xCtLPb2v2cffG1VtscU4= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4831 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT043.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)(396003)(136003)(39850400004)(346002)(199004)(189003)(6116002)(76130400001)(110136005)(3846002)(99286004)(476003)(6486002)(47776003)(63350400001)(486006)(126002)(50226002)(305945005)(6512007)(22756006)(11346002)(8936002)(2906002)(8746002)(5660300002)(446003)(1076003)(7736002)(8676002)(50466002)(86362001)(2616005)(81166006)(66066001)(81156014)(186003)(2201001)(36906005)(70586007)(316002)(2171002)(6506007)(336012)(2501003)(36756003)(4326008)(103116003)(70206006)(386003)(25786009)(14454004)(54906003)(478600001)(26826003)(356004)(26005)(23756003)(76176011)(102836004); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR08MB3605; 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: a8de9c36-8413-4d50-57c1-08d755f78cde NoDisclaimer: True X-Forefront-PRVS: 0197AFBD92 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Nizm30HN7/VQcEDBMUnJ8HZegHfIyZE0TccD7ivKWQ5KYMwwtj3FC8XUGziEIAhjmmW2N3jWCny/Bo/SgDVKPDagFsNf5Q+Ek7rG0l+AEnnnUnsVpAz2lEaB1/qaPb8LfkkrTuIQOhKPkWW+pzR0GwZiD+DW9xcUa9LR8PhcN2Q/+3dR6JinXuuUMLeoKTkTVpOR01GcoF57N/f8hJCTteWgbtKrM9Qdwk9d/P5fShSIshGDnfU2Fqq9/QT8ipw2Ii2c6C8qPhdCxX6w8PRehhHHUmtMfKGo/m1zIke9I4dTpud7EC/5Jv0xvkPEtrIr8+dcLPER+kXXoArhdRlo9egvV+GTq4qgP/qRzDcv2Ibtoi07H+aWtK9IEWyb8KhG813Ofqn38OuOMg4Nfxb3+glBD0Rl4mRvgc5KwO+Xd2pA5Bivhl1nh4HWLzPA+Wai X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2019 07:23:32.8141 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8fc5c24b-31e4-46b0-309d-08d755f79440 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: AM6PR08MB3605 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=T1NX/4te0E46cFTcYzomNTVVtxWriVcYq2fOLauQ4Pv6BDfm1QW8lxm03b/NW1U5eIMZBYTans/PQHzziVjRb07lssV5lVqZPJs7qRBFH6cAENTEYhFRHdl1qnbZXdG6fRIbgMMIOFy5e0TsboH3HVf6sh9WoV/wN5Tm8PqmU2s= 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=T1NX/4te0E46cFTcYzomNTVVtxWriVcYq2fOLauQ4Pv6BDfm1QW8lxm03b/NW1U5eIMZBYTans/PQHzziVjRb07lssV5lVqZPJs7qRBFH6cAENTEYhFRHdl1qnbZXdG6fRIbgMMIOFy5e0TsboH3HVf6sh9WoV/wN5Tm8PqmU2s= 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 Mon Oct 21 07:23:29 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: 11201465 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 3FE871515 for ; Mon, 21 Oct 2019 07:23:49 +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 26FCA214D9 for ; Mon, 21 Oct 2019 07:23:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 26FCA214D9 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 03FCB899FF; Mon, 21 Oct 2019 07:23:48 +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-eopbgr70071.outbound.protection.outlook.com [40.107.7.71]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0E2F0899FF for ; Mon, 21 Oct 2019 07:23:47 +0000 (UTC) Received: from VI1PR08CA0103.eurprd08.prod.outlook.com (2603:10a6:800:d3::29) by DB8PR08MB5194.eurprd08.prod.outlook.com (2603:10a6:10:e8::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2367.21; Mon, 21 Oct 2019 07:23:42 +0000 Received: from VE1EUR03FT039.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::203) by VI1PR08CA0103.outlook.office365.com (2603:10a6:800:d3::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2367.21 via Frontend Transport; Mon, 21 Oct 2019 07:23:42 +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 VE1EUR03FT039.mail.protection.outlook.com (10.152.19.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.15 via Frontend Transport; Mon, 21 Oct 2019 07:23:42 +0000 Received: ("Tessian outbound 3fba803f6da3:v33"); Mon, 21 Oct 2019 07:23:36 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: c6431d9452722dc9 X-CR-MTA-TID: 64aa7808 Received: from 2dca2d14250f.2 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.8.56]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 9E25DFA7-8A86-47C2-BFAB-E534FC3623DB.1; Mon, 21 Oct 2019 07:23:31 +0000 Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-am5eur03lp2056.outbound.protection.outlook.com [104.47.8.56]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 2dca2d14250f.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Mon, 21 Oct 2019 07:23:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=erdC2wv+Sk068iTSZKwt1ZIs8ZI1m1m5wL+ZNiXzOARLB/kaxFjCmDYQ6BM4ODpRim1c7vjIbgwHwa8DMTfpr6+a3esxW0eTJKOPvXPHcgXEAiFItyKzKCoucrShVEYG8UhMIk8ykgN1Fq/abbduGQn5MvvK9vLVW3r9o/t/9sNqqOKL7iYXCpfVBCZsQdOi9uuy/G2TM6+Lu+7DtswkF3qv/aSJYSlMUn5Wyrl5r2jiIfmFPGANXl75AVy6NgcGSFYC+giXdwiN675OUd2yHe9+AamScNNo9kaZu1SwKlFP6ftaSfHJZxIuWzq4nWCfTAvodYhIbZU0MffgRWRf7A== 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=vC99I3Z56ZuZCx4QJHgqK2QJ3GtYUvtyOKpAuzBHzXI=; b=Kd+Vk53rxD9uyUg86err7dQdA2R+bsOMSbbCCjxoeBsgOiL5N+b/Na8VZXPSyMaDoFog9kDWv8KnGHjJHaotXNW+Bwny0K7KmXiftOlbyJMT0pGWgxTiE15Ii7O5rVrZ99sEwp66gwrSTC3YqhmfhCIl6vQzEUh+7/bDHiloHrIOp1s2HYVH6sSUwq9i/CbJxsEv8PTCW4Ifse0Wj3A/AcgLuOrY3k/TbNvHRmhTSNe4cJK97zgEc9KkRbLad37yZOy/go8hSYQsSaQwtNZinnmhfjo9cNSiF4GLm0gvPyYEAVyWkICRIx3QlsWgfkZzLulf1LHWnJ9537Ptrc/W0g== 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 VE1PR08MB4831.eurprd08.prod.outlook.com (10.255.115.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.21; Mon, 21 Oct 2019 07:23:29 +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.028; Mon, 21 Oct 2019 07:23:29 +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 v6 4/4] drm/komeda: Adds gamma and color-transform support for DOU-IPS Thread-Topic: [PATCH v6 4/4] drm/komeda: Adds gamma and color-transform support for DOU-IPS Thread-Index: AQHVh+Bv2LYjVeuTFU+5R6eahc8s7w== Date: Mon, 21 Oct 2019 07:23:29 +0000 Message-ID: <20191021072215.3993-5-james.qian.wang@arm.com> References: <20191021072215.3993-1-james.qian.wang@arm.com> In-Reply-To: <20191021072215.3993-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: HK2PR0401CA0019.apcprd04.prod.outlook.com (2603:1096:202:2::29) 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: da36ee62-4549-4579-a02d-08d755f799c3 X-MS-Office365-Filtering-HT: Tenant X-MS-TrafficTypeDiagnostic: VE1PR08MB4831:|VE1PR08MB4831:|DB8PR08MB5194: 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: 0197AFBD92 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(346002)(366004)(39850400004)(396003)(136003)(376002)(199004)(189003)(110136005)(6506007)(6486002)(386003)(66066001)(4326008)(8676002)(66946007)(54906003)(99286004)(103116003)(36756003)(6512007)(6436002)(66446008)(64756008)(66556008)(66476007)(55236004)(2171002)(102836004)(2501003)(26005)(14454004)(186003)(81156014)(81166006)(2201001)(478600001)(11346002)(446003)(316002)(2906002)(7736002)(86362001)(71190400001)(71200400001)(256004)(6116002)(25786009)(305945005)(14444005)(486006)(3846002)(76176011)(52116002)(5660300002)(8936002)(2616005)(476003)(1076003)(50226002); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB4831; 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: Lu2D4UUses/4lCKQk721tUCiG6ME66/kITIOaXGNE7My1e4U4EGFNiiIezn1NGdj0chHNuSrkj4kOzNqjgxYDGJK10Wxptz1ECMKGTKCstY7cDQBxggLFDMgOQYz15SVMHAEtCNcHUUB3lg7q8gC1Es3OZNtEpX3swU+kzvWdxK19D9vFRBLz3/2/eKMduXfwLHuA3iW7Ve4qpWUwX/Ua2sAVqSDz6par/8SChZtELHaMZ3uXhbM9mtyH0JBsKjxg8hH5dsjcm4xOzpJeOIYhyXpMyipyhb18a7kEkEd3cOKGsffmIguB0WPqA3z9ezGc5FchA9kg5tqUnHrAbG6J11IOwe6XeGrrxqbedYL6bFEjilI/kAxfl5PVbojb1Y9XgoFFvB0l3r4Gy7aaDeHmh6t3JJ3exejgMecnJKCrjo= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4831 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT039.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)(39860400002)(136003)(376002)(396003)(346002)(199004)(189003)(3846002)(50226002)(76176011)(316002)(8676002)(81166006)(6506007)(386003)(8746002)(102836004)(1076003)(446003)(8936002)(25786009)(50466002)(81156014)(6486002)(6116002)(126002)(110136005)(476003)(11346002)(14444005)(2616005)(99286004)(486006)(356004)(54906003)(22756006)(36906005)(14454004)(2501003)(23756003)(186003)(26005)(26826003)(76130400001)(305945005)(7736002)(103116003)(336012)(2171002)(2201001)(86362001)(70586007)(5660300002)(6512007)(4326008)(70206006)(36756003)(2906002)(47776003)(63350400001)(66066001)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB8PR08MB5194; 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: 6071ebe0-6ddb-4be9-6bf8-08d755f791c5 NoDisclaimer: True X-Forefront-PRVS: 0197AFBD92 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7w35rtaYnh93uRku6cDlXTiCEZH5u1o6wVdVdy6OhUJt8/xy6Dk0jB6+6ETgc2iSkzXZL1IYhdl7OMzWRfXYdaSyMZjWoqRAzgxZWaKSYXb4H8oJF6t3JhFPQHpMJ8wGVsBciq7tfSRS09VhWQT8dlVnJO5cZe73ybKruiW5CJspwzmh43Qt9/w57XdcnaGq4K0DjkeYbedNBWRbhHpvJSV1thMWUKei+9uqVq2CYA/ZxzaFYluMJcDAkc82WTjGBWKpfLSPnavt16grQ4J3HczXz2zArxIONIIcR0/mun7ZNV+E2Z+VNRmxxJC81NLCkpIzGmDuw+LfZXpLP6nBPAH63XX8r3SGm3Qo9x/BToVRLu/7/TvPwq62u6MOMCUWZO0a/DBnsEJBFIzYBzXXARGZMWtdmNWF6I+2WJzMTmBdBdKxlKIjLAAPTzaAVLEB X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2019 07:23:42.0161 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: da36ee62-4549-4579-a02d-08d755f799c3 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: DB8PR08MB5194 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=vC99I3Z56ZuZCx4QJHgqK2QJ3GtYUvtyOKpAuzBHzXI=; b=j3k6pGn1gP80nCdACc3YDwKlcmyiLaEVALHjz0b7PI4IqPE1vZ33HG71eh9TyUgZmK9FRcc7SSM+GGalkvGjTit1ToLwxAkMiIHy+sEyY0dSSZGhZwmuq1stOA0KYKL7Me+qxYAwTnsTUAPihSxKzDPRYjcVindif7Cx/tydxXk= 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=vC99I3Z56ZuZCx4QJHgqK2QJ3GtYUvtyOKpAuzBHzXI=; b=j3k6pGn1gP80nCdACc3YDwKlcmyiLaEVALHjz0b7PI4IqPE1vZ33HG71eh9TyUgZmK9FRcc7SSM+GGalkvGjTit1ToLwxAkMiIHy+sEyY0dSSZGhZwmuq1stOA0KYKL7Me+qxYAwTnsTUAPihSxKzDPRYjcVindif7Cx/tydxXk= 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);