From patchwork Tue Oct 15 02:10:45 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: 11189587 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 2CCC11390 for ; Tue, 15 Oct 2019 02:11:11 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0EFD120873 for ; Tue, 15 Oct 2019 02:11:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0EFD120873 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 03DAB6E5D9; Tue, 15 Oct 2019 02:11:10 +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-eopbgr40087.outbound.protection.outlook.com [40.107.4.87]) by gabe.freedesktop.org (Postfix) with ESMTPS id CE30C6E5D9 for ; Tue, 15 Oct 2019 02:11:08 +0000 (UTC) Received: from AM4PR08CA0062.eurprd08.prod.outlook.com (2603:10a6:205:2::33) by VI1PR08MB3357.eurprd08.prod.outlook.com (2603:10a6:803:45::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.16; Tue, 15 Oct 2019 02:11:04 +0000 Received: from AM5EUR03FT016.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::200) by AM4PR08CA0062.outlook.office365.com (2603:10a6:205:2::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2347.16 via Frontend Transport; Tue, 15 Oct 2019 02:11:04 +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 AM5EUR03FT016.mail.protection.outlook.com (10.152.16.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.15 via Frontend Transport; Tue, 15 Oct 2019 02:11:02 +0000 Received: ("Tessian outbound 0939a6bab6b1:v33"); Tue, 15 Oct 2019 02:10:53 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: eb5f4b8550791a4d X-CR-MTA-TID: 64aa7808 Received: from 30e84cc9cbdb.2 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.9.53]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id FCCEB9F9-2B11-484C-A267-3F11C8DFBDA3.1; Tue, 15 Oct 2019 02:10:47 +0000 Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-ve1eur03lp2053.outbound.protection.outlook.com [104.47.9.53]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 30e84cc9cbdb.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Tue, 15 Oct 2019 02:10:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KQkKI0McIJUInssDoX1UckINkqsP2pVLVpKsj0PocsoDOh19B0DMaJlKoJfAUahZyL1msoFNP35QcDWstuO65iYztsgFJLSHHu1frVLTT/2Ein65Xtu6Zpq+ub1e0XDKkybmaJGMpXthsTrxbdGGZ1PEuFW+d6CXy5xelA+LI2+xASwG4cPLMjSDiy6OZ7vEkbILh5zHj/MfMN7iM1dvBC1mXZvHXVFIH+L4cFt9wEn7e/Bwjia4IrTgxDoiLw4/RUPafmeMHe3Nxm9Bd75gBn1WBvXPYV0wXNnR2RnDWbSSyvEK7AOu2PzcYBbSvKoMX/TZBjKJ65t0Zk5LdMg/Mg== 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=GyUW4Zl2E6lY9bQXwmH72tV+7kAhIQ9vDJpnPnK6F8E=; b=k9QDRv50pQoTZICdWlA6HlUZAnd2WYJPMYBDjJ/jC3pHd1JGO0ZnWZYN7hZ/biZV2sfHahe91FOKDXv1yjJu+tkRYROMKOhISbqrAaR7xgaji0gDz+yr0ifLCWapIL8R8B36jl/VTQjqmZ7pYwfCLYW32oiFJDy1/G0xl1+dHk3lhu3a55bQoo8otnHhNUWhT7pgTd4UyIbSVQhIyPBguF+KaeC6ZvFAqe43Q0Y2ArEjnov86sYBEIOjV/Jfrp+MowbZb4dTHQEc1zm1kKjOpH3F7e6cl9jupfQjaNUl09h7ZoNjhU2qsktuf/IeTffOmo6WmL4Q/pcRhrhNhyLm6A== 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 VE1PR08MB4799.eurprd08.prod.outlook.com (10.255.115.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.21; Tue, 15 Oct 2019 02:10:46 +0000 Received: from VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::40ed:7ed3:90cf:ece5]) by VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::40ed:7ed3:90cf:ece5%3]) with mapi id 15.20.2347.023; Tue, 15 Oct 2019 02:10:46 +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 v4 1/4] drm: Add a new helper drm_color_ctm_s31_32_to_qm_n() Thread-Topic: [PATCH v4 1/4] drm: Add a new helper drm_color_ctm_s31_32_to_qm_n() Thread-Index: AQHVgv3BWlwKETCEA0mEVRVx1dwUKA== Date: Tue, 15 Oct 2019 02:10:45 +0000 Message-ID: <20191015021016.327-2-james.qian.wang@arm.com> References: <20191015021016.327-1-james.qian.wang@arm.com> In-Reply-To: <20191015021016.327-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: HK0PR01CA0030.apcprd01.prod.exchangelabs.com (2603:1096:203:3e::18) To VE1PR08MB5006.eurprd08.prod.outlook.com (2603:10a6:803:113::31) Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-ms-publictraffictype: Email X-MS-Office365-Filtering-Correlation-Id: 361cfa0d-94d7-49c6-1e8e-08d75114eda0 X-MS-Office365-Filtering-HT: Tenant X-MS-TrafficTypeDiagnostic: VE1PR08MB4799:|VE1PR08MB4799:|VI1PR08MB3357: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:3276;OLM:3276; x-forefront-prvs: 01917B1794 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(136003)(39860400002)(366004)(346002)(376002)(396003)(189003)(199004)(66066001)(476003)(76176011)(110136005)(54906003)(66946007)(64756008)(66476007)(66446008)(71200400001)(66556008)(26005)(103116003)(2201001)(86362001)(6512007)(186003)(71190400001)(316002)(36756003)(6506007)(446003)(11346002)(386003)(2616005)(486006)(2906002)(256004)(52116002)(55236004)(102836004)(2171002)(8936002)(14454004)(478600001)(6486002)(81156014)(81166006)(305945005)(50226002)(2501003)(4326008)(8676002)(7736002)(5660300002)(1076003)(6116002)(3846002)(25786009)(99286004)(6436002); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB4799; H:VE1PR08MB5006.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: YvWjXFyzqCm+tq74pRLpBY80nNyqUBV0PKWsr1UCGW3qGFHwsOR8k3lv7D2VNFpuWp+mCZGiWzT0kMSlK758jNdbTmfGJMW8D15q7ic4edgbBGv6DwHio2o69yTO4lp18ZOUn/L3cR4//8uMbnZC0zAJqL4IKBS0GxqrCoU5gw/iQhr4kSuqeaFUi2gB3krl8I3PlW9YAWTXas1cle1fASTwJJH+KUnlcVQYWKF3bcBiBfqcJ1pGmIa2p9+Qiw9sQdtzwRVxZryVBjIa9f2sHkeePEVn/Aq015VsG9D6ZKjgGJpKMPDAhppatQLu12bN25E5s4SW9dbHU9iMeQOJn702tj2Ku0CJVR2nwSRRfnOctvRuCRH2LU74nWm148SU4ui3/J43ii/xs+SZDfa3f5grQDkyaI4Gq2Vt9GqGoAw= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4799 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT016.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; IPV:CAL; SCL:-1; CTRY:IE; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(396003)(346002)(136003)(39860400002)(376002)(199004)(189003)(2906002)(2501003)(70206006)(356004)(5660300002)(76130400001)(70586007)(103116003)(36756003)(23756003)(36906005)(305945005)(316002)(54906003)(8746002)(81156014)(81166006)(6512007)(8676002)(6486002)(110136005)(7736002)(3846002)(50226002)(8936002)(76176011)(6116002)(99286004)(63350400001)(186003)(26005)(50466002)(386003)(6506007)(26826003)(86362001)(476003)(11346002)(66066001)(2616005)(107886003)(4326008)(336012)(446003)(47776003)(2171002)(126002)(486006)(102836004)(2201001)(25786009)(22756006)(1076003)(478600001)(14454004); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR08MB3357; 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: 6c26dfc5-12b1-4e5f-ba3a-08d75114e385 NoDisclaimer: True X-Forefront-PRVS: 01917B1794 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lLJmY2hhJJyhLRc8/b6VVEVXxQmiBz/4zkSKN9jBvD4HqUaCBAfrZbPcI4C+C8e22McvLBA7TGRUiSMlT5AcXhusPEou3N2P40Drg0VXTX45XMmcIGCzZ+3Vgsav7ZEKB9syvLltLn+qsksk8OgrBDI8yYb42VoSuEo+auiKdbdOOww8NbqtPRLQ2tGr6tu8xYAV4Agu2kJ0pHHZDlvvZWdjrxzI+NqvCR7QvWxLaU8PM+Jj+PEJ94v+263SUadNIJ6neF2eQ0u9vighz5ZLnOu6v8JpNluzH9uV4BPm7xRux9Wls5R+FDgSs9t0zfEovPGlOeOubMenqU7eQb5xf6fTsbGabIRWlVwRhMGgXKDeS+pJuHK8nndPKaDw7E1x4OhsdZrESR32ODr6wSUKIknfPtmzim9EB1MWKShwiA4= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2019 02:11:02.3373 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 361cfa0d-94d7-49c6-1e8e-08d75114eda0 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: VI1PR08MB3357 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=GyUW4Zl2E6lY9bQXwmH72tV+7kAhIQ9vDJpnPnK6F8E=; b=VvBzXKS3AJbdg3FvOp59ypxot0pIzwlA2HJsF8G8XD5BL0nEbRVLD8wzZt6v8YTYWZ0yxLDS6n/RR19BpEgP0+A6k1Myc8wdV7YpvOu78F/O7dOmvzMTAn/sUpBlRuxkjXVPVwAR1T5XtJ2zVTao7mj/0z2bVih6NYGdk5MwAKU= 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=GyUW4Zl2E6lY9bQXwmH72tV+7kAhIQ9vDJpnPnK6F8E=; b=VvBzXKS3AJbdg3FvOp59ypxot0pIzwlA2HJsF8G8XD5BL0nEbRVLD8wzZt6v8YTYWZ0yxLDS6n/RR19BpEgP0+A6k1Myc8wdV7YpvOu78F/O7dOmvzMTAn/sUpBlRuxkjXVPVwAR1T5XtJ2zVTao7mj/0z2bVih6NYGdk5MwAKU= 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. Signed-off-by: james qian wang (Arm Technology China) Reviewed-by: Mihail Atanassov Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_color_mgmt.c | 26 ++++++++++++++++++++++++++ include/drm/drm_color_mgmt.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c index 4ce5c6d8de99..a6d78b247713 100644 --- a/drivers/gpu/drm/drm_color_mgmt.c +++ b/drivers/gpu/drm/drm_color_mgmt.c @@ -132,6 +132,32 @@ 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, doesn't include sign-bit, only support m <= 31 + * @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 + 1 are equal or cleared to sign-bit BIT(m+n+1). + */ +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 > 31 || n > 32); + + /* the range of signed 2's complement is [-2^n+m, 2^n+m - 1] */ + val = clamp_val(mag, 0, negative ? BIT_ULL(n + m) : BIT_ULL(n + m) - 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 Tue Oct 15 02:10:53 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: 11189589 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 7B53C1390 for ; Tue, 15 Oct 2019 02:11:14 +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 62D7220873 for ; Tue, 15 Oct 2019 02:11:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 62D7220873 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 689A36E5DA; Tue, 15 Oct 2019 02:11:13 +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-db3eur04on0600.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0c::600]) by gabe.freedesktop.org (Postfix) with ESMTPS id 88BF16E5DA for ; Tue, 15 Oct 2019 02:11:11 +0000 (UTC) Received: from VI1PR08CA0103.eurprd08.prod.outlook.com (2603:10a6:800:d3::29) by VI1PR08MB4366.eurprd08.prod.outlook.com (2603:10a6:803:fe::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.16; Tue, 15 Oct 2019 02:11:06 +0000 Received: from DB5EUR03FT039.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::201) 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.2347.17 via Frontend Transport; Tue, 15 Oct 2019 02:11:06 +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 DB5EUR03FT039.mail.protection.outlook.com (10.152.21.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.15 via Frontend Transport; Tue, 15 Oct 2019 02:11:05 +0000 Received: ("Tessian outbound 0939a6bab6b1:v33"); Tue, 15 Oct 2019 02:11:01 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 1ea56d70985e14a7 X-CR-MTA-TID: 64aa7808 Received: from 67c7e3bd8aa3.2 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.9.56]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 82CD08CE-DCEF-46A6-AAE7-FD7736A85D7E.1; Tue, 15 Oct 2019 02:10:56 +0000 Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-ve1eur03lp2056.outbound.protection.outlook.com [104.47.9.56]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 67c7e3bd8aa3.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Tue, 15 Oct 2019 02:10:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U5GCFt8S9ZbVVQLQkPJ5Q8JAYjUBXpPOWLnsfaha+28Cltyj6C1UVOxbeDzuMltN6V5WNnzkGL1sl7YKnsS/xaLYV3rbqAJb8HUkeXkentzqWRV2OpQDS5AsOa8eX2DuckiF1K/lGH+pn4cZ1Yjuvc7GykyW9JUho6bIWSsXA1FULM8t0xPBG7zkKl4Byt/SN9gaSBXeR4GkP8FsK2mPexsCXR87L0rXTFrFe0QXlDht2Gvpt2nU+cM1519zvBvpZqt5iGNpi1s1JjtqU9t3AYjgjPF/HY2nL6b5VBQxk6PCM80uwGM+soAwmCjxTMvo0asIo4GQ3kHMvM/S1LUryg== 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=2+CVUl4qWxenCBixN/jWd32qUXnMZcRNCV0P3x8wYzk=; b=gb2CgO027n2vz1EmLZq60cdLiuQ4stbjR9MoDEssugnatDZZvdu+ylNhHJYSVl84bnTVykSP5vTgPUPY66q41stpnpk9vfulcOeqNbLA0FMeQ0bXhHIE37yGQxbpWg+dlZEG3Q/KawfPjQFtt8P3iMS7ZCCroIuy5rsd1VFsFbMnL1COXvXc7/r+kFcTF+J+wrNalGW1CSL31Nebbep0vjf0UjWuhq3ViQr08TaRjyhCNub1vU2+VrfrdYl88M3t1IVtsJwBm4EiiVFOyVk7JjBV/942zAM//YkXKQVkiICVozWzmPO5xCNjWTZYFoVsSnGEv7kfwSt3Vd5uOyBEaA== 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 VE1PR08MB4799.eurprd08.prod.outlook.com (10.255.115.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.21; Tue, 15 Oct 2019 02:10:54 +0000 Received: from VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::40ed:7ed3:90cf:ece5]) by VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::40ed:7ed3:90cf:ece5%3]) with mapi id 15.20.2347.023; Tue, 15 Oct 2019 02:10:54 +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 v4 2/4] drm/komeda: Add drm_lut_to_fgamma_coeffs() Thread-Topic: [PATCH v4 2/4] drm/komeda: Add drm_lut_to_fgamma_coeffs() Thread-Index: AQHVgv3GI0L46yKgNUGru0epkUV1dw== Date: Tue, 15 Oct 2019 02:10:53 +0000 Message-ID: <20191015021016.327-3-james.qian.wang@arm.com> References: <20191015021016.327-1-james.qian.wang@arm.com> In-Reply-To: <20191015021016.327-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: HK0PR01CA0030.apcprd01.prod.exchangelabs.com (2603:1096:203:3e::18) To VE1PR08MB5006.eurprd08.prod.outlook.com (2603:10a6:803:113::31) Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-ms-publictraffictype: Email X-MS-Office365-Filtering-Correlation-Id: 17285621-1f38-4222-ca91-08d75114ef36 X-MS-Office365-Filtering-HT: Tenant X-MS-TrafficTypeDiagnostic: VE1PR08MB4799:|VE1PR08MB4799:|VI1PR08MB4366: 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: 01917B1794 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(136003)(39860400002)(366004)(346002)(376002)(396003)(189003)(199004)(66066001)(476003)(76176011)(110136005)(54906003)(66946007)(64756008)(66476007)(66446008)(71200400001)(66556008)(26005)(103116003)(2201001)(86362001)(6512007)(186003)(71190400001)(316002)(36756003)(6506007)(446003)(11346002)(386003)(2616005)(486006)(2906002)(256004)(52116002)(14444005)(55236004)(102836004)(2171002)(8936002)(14454004)(478600001)(6486002)(81156014)(81166006)(305945005)(50226002)(2501003)(4326008)(8676002)(7736002)(5660300002)(1076003)(6116002)(3846002)(25786009)(99286004)(6436002); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB4799; H:VE1PR08MB5006.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: cfKYnAsGCVJorudqwrhl2d7VJ7+/yWklsxh2CWOpj/VaB4F8b93xUFNR3HjS/vQ6PbhVtUHez5H5V+/OmgwtY2HWTUOmCk1aRsqB6ezsT740USWkGWhpfG/dklQ0vla9XNkzyNtSzlNQWD3RwILqjfwdU+gOmbt6gCDzHOfBJCawaPvo1Fkq0S1+UU7U4tUwiyeSlQG5hqPb83nc3535iHNPn2n4fx1+nCJMlS4vsq0tk8DyHTedKoAdOgh4Ft7c/wONs4j6JRyNSuV0KjKc49Dszi3z9LF3wf3R8K+KarXFIt+nlK65ALgwanRq3vJ4r8ldIdQ3TJzT5KvNuQshpL9/1ebtD3fikpEhkeUQ+CQZAoK5Oqb9q9a1vEzmKg9lH75LJIbu8OqQ4lWH/yM5v7uxdFtrigB4fW4HEu7Agvc= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4799 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT039.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)(376002)(39860400002)(199004)(189003)(99286004)(50466002)(7736002)(26005)(386003)(316002)(76176011)(486006)(4326008)(1076003)(54906003)(110136005)(5660300002)(305945005)(356004)(336012)(25786009)(63350400001)(2906002)(103116003)(2616005)(476003)(126002)(11346002)(22756006)(446003)(6506007)(6116002)(3846002)(186003)(86362001)(102836004)(2201001)(478600001)(26826003)(50226002)(70586007)(81156014)(8676002)(81166006)(8746002)(14454004)(6512007)(8936002)(14444005)(2501003)(70206006)(76130400001)(2171002)(66066001)(6486002)(47776003)(23756003)(36756003); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR08MB4366; 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: 4800d94f-3272-43bb-2a78-08d75114e867 NoDisclaimer: True X-Forefront-PRVS: 01917B1794 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5FOuwIsdzibVBy+aSzp0N606ryLs1+HFSR3/rYApIDy/OzueHcUKeEsLsa6sbM52CE1fpK0fCLV1Bs6L0jUO7isHrcK70CP+xBM7zj2eZIIEgMvivh5/DnDaBD5eCkblFMwERFwnZU/BcDmkEM4RbJ/iWXpZBLmPa/UrBUe/u2bngmFJ4q9X6vFaObvUSZRA0zGYfSYRBfa34W9uvlOysC9XkS0CmCRot2mhWQ8jWMBhB3zZ321D5/yicWfauZqTGIk/JO/mVezoLVuY0UC7nH4oa49W77tmqtO1gCPvshS27FEQJiH2XiD8gWXcKVYL39g4mqhM6ToK4K/Ebr41lPUGa9iO8PNzflqjwEANhHL3nlDQh+3s9yVRWWyr/SnvN7Zl1I90Kk8zrvz6HxtjLFnpi/OrdVdNrNGx3NQYoco= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2019 02:11:05.0245 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 17285621-1f38-4222-ca91-08d75114ef36 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: VI1PR08MB4366 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=2+CVUl4qWxenCBixN/jWd32qUXnMZcRNCV0P3x8wYzk=; b=RyP3qy9lmz3B6X+mVDqdsXTc9pLR19quzSSv2uVAJdTAXoPCK2i3VGfNp7EQ/EfIqi88z9KMW1KaM4KR+4rxYvZm0PzX4pPr0+CySnXkaMoKqrcG/dO/b2CiTPI3CMCBAtFkQEXKNH+gRucOpu9KQnk696fXUfuY5xcjC2NOrU4= 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=2+CVUl4qWxenCBixN/jWd32qUXnMZcRNCV0P3x8wYzk=; b=RyP3qy9lmz3B6X+mVDqdsXTc9pLR19quzSSv2uVAJdTAXoPCK2i3VGfNp7EQ/EfIqi88z9KMW1KaM4KR+4rxYvZm0PzX4pPr0+CySnXkaMoKqrcG/dO/b2CiTPI3CMCBAtFkQEXKNH+gRucOpu9KQnk696fXUfuY5xcjC2NOrU4= 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 3dlut to komeda HW required 1d 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 Oct 15 02:11:01 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: 11189591 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 6B0C21668 for ; Tue, 15 Oct 2019 02:11: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 5129321835 for ; Tue, 15 Oct 2019 02:11:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5129321835 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 8E0796E5DB; Tue, 15 Oct 2019 02:11:23 +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-eopbgr60068.outbound.protection.outlook.com [40.107.6.68]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4E29F6E5DB for ; Tue, 15 Oct 2019 02:11:21 +0000 (UTC) Received: from VI1PR08CA0094.eurprd08.prod.outlook.com (2603:10a6:800:d3::20) by AM5PR0802MB2579.eurprd08.prod.outlook.com (2603:10a6:203:98::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.16; Tue, 15 Oct 2019 02:11:17 +0000 Received: from AM5EUR03FT021.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::209) by VI1PR08CA0094.outlook.office365.com (2603:10a6:800:d3::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.16 via Frontend Transport; Tue, 15 Oct 2019 02:11:17 +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 AM5EUR03FT021.mail.protection.outlook.com (10.152.16.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.15 via Frontend Transport; Tue, 15 Oct 2019 02:11:15 +0000 Received: ("Tessian outbound 927f2cdd66cc:v33"); Tue, 15 Oct 2019 02:11:08 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 1049427a500a475b X-CR-MTA-TID: 64aa7808 Received: from f09d0f69effc.2 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.9.51]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id A93CFC27-508E-44BE-967D-04F6648B714E.1; Tue, 15 Oct 2019 02:11:03 +0000 Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-ve1eur03lp2051.outbound.protection.outlook.com [104.47.9.51]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f09d0f69effc.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Tue, 15 Oct 2019 02:11:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GN20tlCqrkTxICy6dSiApX1k7KOQ9/oYTbBahFb2h/apFYzbvC8x9DVZCmj8cp0H6n0mBZ/eAXyahNWhgTbSeeZXAIK4K84xTVMoXIavGbMzc13hb5X78bSgQIz5MWlCBoU83BSEbyjU97Hqgt5Q8lYLUmJdGfC477MPtulW2vHDbOEPSCpBQfjbfuf7KKz0VRQWYDGdtOvEQATXgSfyEPmvp5poNuFsHnf3lQu7xEfSSYBaGOQDvCD0IYvyQ8ujre2a0P0s3oe7vEy8bgtyostn675f4g4Xn23xWqIENZCLjIyh5o/hTMsBwYyZ0DE9ufzCUYHTb6VKkYO9KxV6bw== 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=zNGXLdi+Pb1SSmWtgl3GmMopU1EC0Z2mssefcs3oA9Y=; b=esiL8ON/K3FDnG+Ak77u6X9s3M23yOEwokXlplm5y5B5UIRUHvTHM/NQYcswJv3fkAjN1xf8PRPcR8bGBSZsR2bc4hiJj0wVYoXMDKIXHdIbZ3lR1OwwnkXuRb5z/SQWUfDvEUnJPTPg3oI66fH0Hwb3827A/jkzj6c89OFk7c9C/bbn8T0b9/gxfL19AJPYBrdNJtPUjVSlLSv02XYxZDO0uFoeonu+pgTNoLOFfgSvgi5Y0BENRji0UuhIIBo2ftCpewHJMgHxOMa59lv8ht2O+T/+YJ0ZwZOcoZ14nnESBFcuICVzz6jUVWRRQ2ITQf2t2yPlgT5TlkAv5Jmfsw== 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 VE1PR08MB4799.eurprd08.prod.outlook.com (10.255.115.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.21; Tue, 15 Oct 2019 02:11:01 +0000 Received: from VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::40ed:7ed3:90cf:ece5]) by VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::40ed:7ed3:90cf:ece5%3]) with mapi id 15.20.2347.023; Tue, 15 Oct 2019 02:11:01 +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 v4 3/4] drm/komeda: Add drm_ctm_to_coeffs() Thread-Topic: [PATCH v4 3/4] drm/komeda: Add drm_ctm_to_coeffs() Thread-Index: AQHVgv3K+gTD1TOgJkesN8hoYuRc/Q== Date: Tue, 15 Oct 2019 02:11:01 +0000 Message-ID: <20191015021016.327-4-james.qian.wang@arm.com> References: <20191015021016.327-1-james.qian.wang@arm.com> In-Reply-To: <20191015021016.327-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: HK0PR01CA0030.apcprd01.prod.exchangelabs.com (2603:1096:203:3e::18) To VE1PR08MB5006.eurprd08.prod.outlook.com (2603:10a6:803:113::31) Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-ms-publictraffictype: Email X-MS-Office365-Filtering-Correlation-Id: 8dd81b59-cd8b-4bc5-dce7-08d75114f5ab X-MS-Office365-Filtering-HT: Tenant X-MS-TrafficTypeDiagnostic: VE1PR08MB4799:|VE1PR08MB4799:|AM5PR0802MB2579: 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: 01917B1794 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(979002)(4636009)(136003)(39860400002)(366004)(346002)(376002)(396003)(189003)(199004)(66066001)(476003)(76176011)(110136005)(54906003)(66946007)(64756008)(66476007)(66446008)(71200400001)(66556008)(26005)(103116003)(2201001)(86362001)(6512007)(186003)(71190400001)(316002)(36756003)(6506007)(446003)(11346002)(386003)(2616005)(486006)(2906002)(256004)(52116002)(55236004)(102836004)(2171002)(8936002)(14454004)(478600001)(6486002)(81156014)(81166006)(305945005)(50226002)(2501003)(4326008)(8676002)(7736002)(5660300002)(1076003)(6116002)(3846002)(25786009)(99286004)(6436002)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB4799; H:VE1PR08MB5006.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: EEYDHKvmldHpZ9RTMKyOnlnd1odOSUE+q+Y598+4M13CugwtaRq/oBQmRuYjxK2T1sMqjijZ3fY/usKXkXFLn4243BnNLyUb3N1UXKOyx+7pKjEAdmpGOeDDsIoGg+WllmYg7tNei1GmP78Ce+QbM6hMimy5/oma0YjZJi+54oi6toWxn9St7rBOBO3X3zNWWvHwECnDseDgkLixpdNVF+3gP7bLzNr60f+NHk19swcWEwjBEnwRml+oOaHqrqFD2ZxVVWOIKpZwGchOdJljbXw3PQZw1U4M3BOT0b6Xoxx0U+3wlGvC8ut8L5mNyI56Ub6G0HC2RduVtesLJIOM5f8pxLUyLCaGVqxsgD7W/KwkFFpMKN3mHT5qsbtcpOWcWoDAEL0RXDOZvID97f5NLJvGbY2Sl4dC/Qf2I22cudM= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4799 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT021.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; IPV:CAL; SCL:-1; CTRY:IE; EFV:NLI; SFV:NSPM; SFS:(10009020)(979002)(4636009)(39860400002)(346002)(136003)(376002)(396003)(199004)(189003)(305945005)(7736002)(11346002)(336012)(2171002)(26005)(186003)(103116003)(6506007)(386003)(102836004)(6512007)(50226002)(26826003)(8936002)(2906002)(14454004)(63350400001)(2201001)(446003)(8746002)(86362001)(66066001)(70206006)(478600001)(70586007)(4326008)(50466002)(2616005)(76176011)(486006)(126002)(6486002)(23756003)(6116002)(99286004)(47776003)(476003)(3846002)(36756003)(1076003)(2501003)(81156014)(81166006)(8676002)(356004)(25786009)(36906005)(54906003)(316002)(110136005)(5660300002)(22756006)(76130400001)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0802MB2579; 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: adb12df8-1c4e-40a3-abcd-08d75114eccf NoDisclaimer: True X-Forefront-PRVS: 01917B1794 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FSQwCZQyQD9y7PpceXndGrkSpAmij1HT4ZJPE95DBmf8nC5yF8hGHiyKIV3XYDbqqfZxx/ItWY5+njRRdRNh7WlQ4SDWngmq9J7nseLjuQVXpGaAlycDlpJidEfynaDuK9oWJzThv2VYNSBZqm0J3FcscT7Yi4Ky/JSMmVgk0sEWAuhyh3fl3FDdGgqEAoaTRlUI+zsl31tv0gTZ/IHlBY9NcwAHJFWttM/cN8qmNPQWFBuADEriwJBzEwe0Z55pTJL8Wv+hKIZ1/pt8mOgKlWHUpZMvBXyERv+tIEVlrIAxd7DdNRpCzYQ9V5U2BL6hX1+d5dth1zEQW7CkQTSbxE1AlKnIfFoW+xDnthSu5sAv5GVeQOgfz92BuZ8bSqfg2KLOkyV3aryy6VPV6Aidtb2sj4LbvHNCMc3bU0bVKZY= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2019 02:11:15.8530 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8dd81b59-cd8b-4bc5-dce7-08d75114f5ab 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: AM5PR0802MB2579 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=zNGXLdi+Pb1SSmWtgl3GmMopU1EC0Z2mssefcs3oA9Y=; b=UeGGyF+roAj8bBhVeKxNTe6wM4DZZLIyU2RC48IJUnu5Pec8c0VNLEW/FZJ/QVey1x4hWco6zoS+qcjwNIKZaIm6aT/EleFyKQ3w5MxbdKNcgv5maPIiuTtu8QhZtP1N1VjGo/XylZKREnyJyokq3rJYAELZRLwcvZFR/xowxlw= 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=zNGXLdi+Pb1SSmWtgl3GmMopU1EC0Z2mssefcs3oA9Y=; b=UeGGyF+roAj8bBhVeKxNTe6wM4DZZLIyU2RC48IJUnu5Pec8c0VNLEW/FZJ/QVey1x4hWco6zoS+qcjwNIKZaIm6aT/EleFyKQ3w5MxbdKNcgv5maPIiuTtu8QhZtP1N1VjGo/XylZKREnyJyokq3rJYAELZRLwcvZFR/xowxlw= 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..ad668accbdf4 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], 2, 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 Oct 15 02:11:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Qian Wang X-Patchwork-Id: 11189593 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 C9E661668 for ; Tue, 15 Oct 2019 02:11:32 +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 AFF6921835 for ; Tue, 15 Oct 2019 02:11:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AFF6921835 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 E7FC96E5DE; Tue, 15 Oct 2019 02:11:31 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10063.outbound.protection.outlook.com [40.107.1.63]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6578B6E5DE for ; Tue, 15 Oct 2019 02:11:29 +0000 (UTC) Received: from HE1PR0802CA0019.eurprd08.prod.outlook.com (2603:10a6:3:bd::29) by DBBPR08MB4678.eurprd08.prod.outlook.com (2603:10a6:10:dc::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.16; Tue, 15 Oct 2019 02:11:24 +0000 Received: from VE1EUR03FT019.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::208) by HE1PR0802CA0019.outlook.office365.com (2603:10a6:3:bd::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2347.16 via Frontend Transport; Tue, 15 Oct 2019 02:11:24 +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 VE1EUR03FT019.mail.protection.outlook.com (10.152.18.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.15 via Frontend Transport; Tue, 15 Oct 2019 02:11:23 +0000 Received: ("Tessian outbound 0cf06bf5c60e:v33"); Tue, 15 Oct 2019 02:11:16 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 5207e13f6e540a4c X-CR-MTA-TID: 64aa7808 Received: from 95c9ceaedac9.2 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.9.50]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 58242113-226D-4520-99A7-6E8607A998AF.1; Tue, 15 Oct 2019 02:11:10 +0000 Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-ve1eur03lp2050.outbound.protection.outlook.com [104.47.9.50]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 95c9ceaedac9.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Tue, 15 Oct 2019 02:11:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CmNDq2ljwI5XYS/ljhzybAhAzXek7cIjeDnWIVo8Zxr92w5d7r4h+IKwSOb+/NMFvNqPDov5R9ty5BHpGC3r7oaAEagkVryc9n7X4G89hvYF5psh5mnuKqNL3qaRgk+LJPP1Wic0E9uy51c6KjexaDQ4T5mavGU1szjK2DyrFL930a7gZFnxj51CpzJeYBpR3oBBniLaIGTF6rDKbjOeZra5xl+HqvZ/2jwm3Ga9XHSRr31rtb2CM1ywxboGMJPL4vBYy8S16hCelkynXTNiplOeF9JSGLxmWeAH6JIY0jzAQEA7T5NlmbHTd/9gj4gIbqiNDTUy9s2SlCFJktBzOw== 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=fIUGSIoTFS+rG3rkaZCUgjh5FrULV5M3gll9vYVFpDA=; b=BeOgIcjRlQG9FUqo7+ad6TchX/EV09Wt17KPBWo5ww085/dvB5kNECFI9W1II8UIeqaRw+Y4PzH08AHeH4YEk2CwIpePlvInrLHCdPVURBfIycDkLTFHluyjyK4yEGukFa3QlvbGxx3LlIsK3afkaAeL6cFoOIzZ4xBGhSMA2RYBqOIMOcnWyXXvwtEx3IC/u3Dox6qprzzuqCRW8FWj5gnJ/ro3zLJ85PWIKXELKxKNfhqfbdPJ8XGXCnaF0gp7Pq9xv2TVqAMhxR/9oU6HyPF6BfoD64U/ExAEV409sSwinx7dbNSgnTYsTh69+X2NavmXqs8NUhQUIwRMSH75eA== 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 VE1PR08MB4799.eurprd08.prod.outlook.com (10.255.115.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.21; Tue, 15 Oct 2019 02:11:08 +0000 Received: from VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::40ed:7ed3:90cf:ece5]) by VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::40ed:7ed3:90cf:ece5%3]) with mapi id 15.20.2347.023; Tue, 15 Oct 2019 02:11:08 +0000 From: "james qian wang (Arm Technology China)" To: Liviu Dudau , "airlied@linux.ie" , Brian Starkey , "maarten.lankhorst@linux.intel.com" , "sean@poorly.run" , "imirkin@alum.mit.edu" Subject: [PATCH v4 4/4] drm/komeda: Adds gamma and color-transform support for DOU-IPS Thread-Topic: [PATCH v4 4/4] drm/komeda: Adds gamma and color-transform support for DOU-IPS Thread-Index: AQHVgv3OQ34D7f1MHkmhb7Kvw8BM2g== Date: Tue, 15 Oct 2019 02:11:08 +0000 Message-ID: <20191015021016.327-5-james.qian.wang@arm.com> References: <20191015021016.327-1-james.qian.wang@arm.com> In-Reply-To: <20191015021016.327-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: HK0PR01CA0030.apcprd01.prod.exchangelabs.com (2603:1096:203:3e::18) To VE1PR08MB5006.eurprd08.prod.outlook.com (2603:10a6:803:113::31) Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-ms-publictraffictype: Email X-MS-Office365-Filtering-Correlation-Id: 2d0347c2-523f-45ba-4766-08d75114fa32 X-MS-Office365-Filtering-HT: Tenant X-MS-TrafficTypeDiagnostic: VE1PR08MB4799:|VE1PR08MB4799:|DBBPR08MB4678: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:2958;OLM:2958; x-forefront-prvs: 01917B1794 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(136003)(39860400002)(366004)(346002)(376002)(396003)(189003)(199004)(66066001)(476003)(76176011)(110136005)(54906003)(66946007)(64756008)(66476007)(66446008)(71200400001)(66556008)(26005)(103116003)(2201001)(86362001)(6512007)(186003)(71190400001)(316002)(36756003)(6506007)(446003)(11346002)(386003)(2616005)(486006)(2906002)(256004)(52116002)(14444005)(55236004)(102836004)(2171002)(8936002)(14454004)(478600001)(6486002)(81156014)(81166006)(305945005)(50226002)(2501003)(4326008)(8676002)(7736002)(5660300002)(1076003)(6116002)(3846002)(25786009)(99286004)(6436002); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB4799; H:VE1PR08MB5006.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: keCgo9PdbWh8XH5/sjRCzsoLoqmmIpEBKyZfqKwzO52d98qzxPfGIX3LTEi/nlWAMfPq5x9dd4Pw+rC00Delayp6RzPPe7ky9iXeP561OLMwsrY5Tv88BY2SUcYT9dDeAyxnic+lmlv1vAEm9dTWXJHfd1ex7C4J8+YxQ9fSTH5Gbx3V8iS+lFXN0ZlqlyWWIEHPcPL2JJndgPy0eJ3iEV6NgcUlsyqthoPhWN/Ndttinl2tMY3JgtLmSOOBt08AwbwGmDP3ye7Q7uwe4z11xDUk1kA+WKIHv/hWq+wRJXCuzoHTUPbK+nMa2KbU95lmSXRe/CwVODc2SfAXT2jSyQ9+3WB7gf1oNlPc4X8khKygszJcZ483EOgtLs1aUX5VcEds/HVZtWsBA/ZV7OO2uJ3gaApsHB+SHUgfQpjJocw= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4799 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT019.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; IPV:CAL; SCL:-1; CTRY:IE; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(376002)(346002)(396003)(39860400002)(136003)(199004)(189003)(36906005)(23756003)(25786009)(26826003)(316002)(4326008)(2616005)(478600001)(336012)(22756006)(50226002)(486006)(5660300002)(47776003)(1076003)(126002)(66066001)(11346002)(476003)(63350400001)(2171002)(6512007)(6486002)(446003)(54906003)(110136005)(50466002)(99286004)(76176011)(356004)(8746002)(186003)(103116003)(8936002)(102836004)(6506007)(81166006)(70586007)(70206006)(8676002)(81156014)(26005)(76130400001)(386003)(305945005)(6116002)(7736002)(3846002)(2906002)(14454004)(86362001)(2201001)(36756003)(2501003)(14444005); DIR:OUT; SFP:1101; SCL:1; SRVR:DBBPR08MB4678; 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: ad8006b6-c105-4f81-275b-08d75114f10f NoDisclaimer: True X-Forefront-PRVS: 01917B1794 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ROl5hPEq5fwtYUlj+ttxUzKGfVgg79dOkFguDQZS39vV1bqo6efR6BHYq7x0dUeVJmy6xaWJmjNiDISfvNqPCRNULhzsG82AK+lV0wrTEXfwohzN3Ux2ThTUNv283A3Rk/+g8SkMksJrP2Aa519NVyW5QA4g5A89xOjdsjJpc652FWRTLmtVqRguT3D28NMz+2SbOB+bcqFBywLDMmAvg4gMQcUzH5pYwMzAw8U2ZoYXcCxz6IPnZ+U3j6KKVl/TUfyvxVHUjYndEtpA0s+UbW9zdgdBvddIRs4ZUsIvwp1t5bKJX8p0sCQjQJXVix6t4N9lnRxr1MgLEAvnzIBxIjAHz2c96/BMqVp0oc6Ldr6G93Xb7vv0zyuwE1EL/gCCIG7z59JTtDM8c1K159m6FJACclsBr2egyGL+7Vkn4po= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2019 02:11:23.3958 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2d0347c2-523f-45ba-4766-08d75114fa32 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: DBBPR08MB4678 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=fIUGSIoTFS+rG3rkaZCUgjh5FrULV5M3gll9vYVFpDA=; b=WnLgaVsaIfA3o7Iyjfl7HOYrLzw01XOgkMge8v/GSZ/wwMSHLv1q2yax4SN9kP+qgZiazdcx2tHzt4d/r3nkbd9fUipWhU7akTucJXePk2F8I7rR8JIpsQXeIi5tt5Z0p9M5TjXcxmZMf+5H/Z4veVa72Zl/CuXEUbCtd/eqthg= 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=fIUGSIoTFS+rG3rkaZCUgjh5FrULV5M3gll9vYVFpDA=; b=WnLgaVsaIfA3o7Iyjfl7HOYrLzw01XOgkMge8v/GSZ/wwMSHLv1q2yax4SN9kP+qgZiazdcx2tHzt4d/r3nkbd9fUipWhU7akTucJXePk2F8I7rR8JIpsQXeIi5tt5Z0p9M5TjXcxmZMf+5H/Z4veVa72Zl/CuXEUbCtd/eqthg= 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. Signed-off-by: Lowry Li (Arm Technology China) --- .../arm/display/komeda/d71/d71_component.c | 24 +++++++++++++++++++ .../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, 35 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 c3d29c0b051b..e7e5a8e4430e 100644 --- a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c +++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c @@ -942,15 +942,39 @@ 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; + u32 mask = 0, ctrl = 0; for_each_changed_input(state, index) malidp_write32(reg, BLK_INPUT_ID0 + index * 4, to_d71_input_id(state, index)); malidp_write32(reg, BLK_SIZE, HV_SIZE(st->hsize, st->vsize)); + + 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 */ + } + } + + if (mask) + malidp_write32_mask(reg, BLK_CONTROL, mask, ctrl); } static void d71_improc_dump(struct komeda_component *c, struct seq_file *sf) diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c index 9beeda04818b..406b9d0ca058 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c @@ -590,6 +590,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 b322f52ba8f2..c5ab8096c85d 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 @@ -324,6 +325,8 @@ struct komeda_improc { struct komeda_improc_state { struct komeda_component_state base; 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 0ba9c6aa3708..4a40b37eb1a6 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c @@ -756,6 +756,12 @@ komeda_improc_validate(struct komeda_improc *improc, st->hsize = dflow->in_w; st->vsize = dflow->in_h; + 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);