From patchwork Fri Nov 1 06:53:48 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: 11222445 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 573F71515 for ; Fri, 1 Nov 2019 06:54:04 +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 3DEF620862 for ; Fri, 1 Nov 2019 06:54:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3DEF620862 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 5A33B6F70B; Fri, 1 Nov 2019 06:54:03 +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-eopbgr80087.outbound.protection.outlook.com [40.107.8.87]) by gabe.freedesktop.org (Postfix) with ESMTPS id B474C6F70B for ; Fri, 1 Nov 2019 06:54:01 +0000 (UTC) Received: from VI1PR0802CA0023.eurprd08.prod.outlook.com (2603:10a6:800:aa::33) by AM6PR08MB4181.eurprd08.prod.outlook.com (2603:10a6:20b:ad::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2408.17; Fri, 1 Nov 2019 06:53:59 +0000 Received: from AM5EUR03FT063.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::204) by VI1PR0802CA0023.outlook.office365.com (2603:10a6:800:aa::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2408.19 via Frontend Transport; Fri, 1 Nov 2019 06:53:59 +0000 Received-SPF: Fail (protection.outlook.com: domain of arm.com does not designate 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT063.mail.protection.outlook.com (10.152.16.226) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.20 via Frontend Transport; Fri, 1 Nov 2019 06:53:58 +0000 Received: ("Tessian outbound 851a1162fca7:v33"); Fri, 01 Nov 2019 06:53:55 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 92d12cd53eaa3310 X-CR-MTA-TID: 64aa7808 Received: from abe47f65ad90.2 (cr-mta-lb-1.cr-mta-net [104.47.12.52]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id B3EBD2C7-9F12-4CC4-9113-C9F60B07E2B5.1; Fri, 01 Nov 2019 06:53:50 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04lp2052.outbound.protection.outlook.com [104.47.12.52]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id abe47f65ad90.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 01 Nov 2019 06:53:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ODPFK7WWenQsSKWZMXall798vNEwCaxsWbMh5Y7o06vGsIBBJOu3OGCONAbXi+5EGJZkNvsNjO+eSMnFgIWJcPt3A/CCMgsrd1NvU6Y2ShKnyn/OnBkLJn5/SluhhRi/xpuc0IKobTzeHvIv+edG40EvsX0XwHTxHEydTORgNWh5tX48biYNpPpPisY7fuopv04Gzpk6O/jh+r/NXOQHpZki3fT3/3visjNhkUUhMG8iYmcHJHi5YzFCl7TPsjLaRVEvDjM6Zr6hsz+V2gnzC3DxHTC//siPFptiQtsKY9YqHbohAEv9YgNp71dlqp0SKwKi/n0cHL25FHMBMHNHgQ== 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=pKQW6Eb95un6S0A37aPXjNKy9DHe+ZMM0AYifmcrwpU=; b=ed+pIRp1S+r6iXEMw3vJQofBCUQqk3rncq5Xw9DNQ1YeVs7jGzZqQqdcXAz0R2OTHzFc9AtY0PzhhFOoW39DCyhS3iN7Ub4G3M+wRwd9eakTF35goHJ4bkhrVCGaGhlukLi3oO4qe7cW9f5vR5DzCJx9LPKuz6V2Z+ifihGGt11JmbgkPPoN1OdO5eGVOqNxPAo70MjZd9w3crZZ/R2aeSxkP7Ko432ksjLJIqkNhrHydlP7r7gbSbwHmo9QZojxPCLFN4jU29K2P7Qc+z/NahY2YeRnA5EBoJkCpk1YwiA1VqRut2In6Dnn9mt5HzmH+t80guwrFOaziS6gG8Tfdg== 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 VE1SPR01MB0002.eurprd08.prod.outlook.com (20.179.193.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2408.17; Fri, 1 Nov 2019 06:53:48 +0000 Received: from VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::a809:417a:faf3:61a7]) by VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::a809:417a:faf3:61a7%6]) with mapi id 15.20.2387.030; Fri, 1 Nov 2019 06:53:48 +0000 From: "james qian wang (Arm Technology China)" To: Liviu Dudau , "airlied@linux.ie" , Brian Starkey , "maarten.lankhorst@linux.intel.com" , "sean@poorly.run" , Mihail Atanassov , "imirkin@alum.mit.edu" Subject: [PATCH v8 1/4] drm: Add a new helper drm_color_ctm_s31_32_to_qm_n() Thread-Topic: [PATCH v8 1/4] drm: Add a new helper drm_color_ctm_s31_32_to_qm_n() Thread-Index: AQHVkIEc5Q+Snrdv1U6+DG7E3z5ENg== Date: Fri, 1 Nov 2019 06:53:48 +0000 Message-ID: <20191101065319.29251-2-james.qian.wang@arm.com> References: <20191101065319.29251-1-james.qian.wang@arm.com> In-Reply-To: <20191101065319.29251-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: HK2PR0302CA0022.apcprd03.prod.outlook.com (2603:1096:202::32) 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-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: a03592b8-8bb5-4112-e68a-08d75e98457b X-MS-TrafficTypeDiagnostic: VE1SPR01MB0002:|VE1SPR01MB0002:|AM6PR08MB4181: 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: 020877E0CB X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(396003)(376002)(136003)(39860400002)(346002)(366004)(199004)(189003)(66066001)(446003)(11346002)(2616005)(486006)(36756003)(8676002)(14454004)(5660300002)(476003)(103116003)(2501003)(2171002)(86362001)(3846002)(6116002)(305945005)(2201001)(25786009)(1076003)(6512007)(66476007)(52116002)(71200400001)(71190400001)(386003)(55236004)(6506007)(6436002)(102836004)(6486002)(7736002)(186003)(99286004)(8936002)(110136005)(4326008)(54906003)(50226002)(478600001)(64756008)(2906002)(66446008)(81156014)(66556008)(316002)(66946007)(81166006)(76176011)(256004)(26005); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1SPR01MB0002; 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: LA3SPFQ2Lsfv6b+GKsc2dUYuNvOgCTzXZ2Zdqdx4sOW3m2dXcV6FdA5NJBbCIwhnJXNBVp3btJzOTFwVhpP/6qe8G21BLbkBCBjJ2lfrePHsDMZsuhI0Cgwj3thQxcKe5AzZu/zerThJ31NwfLrT3oe/NsCVZOrZYmPiZxlX17j43bGfSF0l0b85Ly3vD0VaHFEe5uXoxjXdk90utCz14WRZ+ugdwKvDte7WubaO65YphbhX0/L+syY2QCsQ2GCq0+LpYLo15vzPR2x4H+/YPWtEp/XO/LDTuqL+B7PinBA8W/icZNrxnUvpWJ5tim285ANzeMGt2lWuW1TcgfZBZkz/NLXld1GE7AnB3bIFH5tjibsnwCRGh3kI5BNF57FOEGfmlbYceEG40/iUQMGE03M8OlUwV1ZH1v4KFQgpLYqxAjzmudyZRGywzhnqwyih Content-ID: <50920539A9C20C47A86B9DC6F52106ED@eurprd08.prod.outlook.com> MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1SPR01MB0002 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT063.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)(346002)(39860400002)(1110001)(339900001)(199004)(189003)(3846002)(54906003)(81156014)(50226002)(70206006)(70586007)(103116003)(110136005)(105606002)(81166006)(107886003)(47776003)(66066001)(2171002)(8676002)(22756006)(26826003)(6512007)(36906005)(14454004)(305945005)(6486002)(316002)(4326008)(7736002)(36756003)(2201001)(2486003)(8936002)(99286004)(2501003)(50466002)(23676004)(486006)(5660300002)(86362001)(26005)(478600001)(356004)(386003)(6506007)(102836004)(2906002)(186003)(76176011)(1076003)(446003)(436003)(336012)(476003)(126002)(76130400001)(6116002)(25786009)(11346002)(2616005); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR08MB4181; H:64aa7808-outbound-1.mta.getcheckrecipient.com; FPR:; SPF:Fail; LANG:en; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; A:1; MX:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: 51cf4374-da76-413b-1999-08d75e983ed1 NoDisclaimer: True X-Forefront-PRVS: 020877E0CB X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G8VCM04Tr/+BOopv+J8OkDSi/RN5veqTanVIqYNSnlkbMEXyg38Exk4Pw2pqnHwgbhwGqIFTa0pNW0sViX0aoqbPebb3D4TbubTzVVGKNXsZSdh0gLXZbQeiEnf0MRsyxE+xWXGVSKfYkm5YjjD+HEXIndrINoN6N1tGEgnGWUT/oatbKO/8wFQmas/vb6w0+Vxe3bJ0Mi9cQYczVxEnLX07BdCT5OdJevY3qafuxpkl7RZqxD03LFj/m/B01PQvLLPO+55a4/RZFwz6cgfeOtQ8NJunDFd0d426RyEAvEPoBFwKsAwkZn4ioWHoRzXdQSQIYs1m4nxy7P7g+EF/MO8ze68GYlIlVtRxwm5liP3GgjJkhwPiXGb1MisSzuQkpDdd2k5lS7mENTTocKbrWIWU5rjJtYyEjuayDk0wIWrRcertHAmo03ngLeD0T/ny X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2019 06:53:58.9181 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a03592b8-8bb5-4112-e68a-08d75e98457b 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: AM6PR08MB4181 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=pKQW6Eb95un6S0A37aPXjNKy9DHe+ZMM0AYifmcrwpU=; b=hFAoCQzckQZhnxmJJfzJPLVJ7MUtUORTu+BbaZg65fa7SeD4X4TcJyKeOEe/6bgtkBNlEcEzwQLJEkZr3LpOz86dIwai7sdXY/EdWtr2R2+i97zSofLfP/WBS8V9PeLHFSvcf11MgaBOHn+be9DdO2s6+ZN5oolx8EyVezcQHkk= 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=pKQW6Eb95un6S0A37aPXjNKy9DHe+ZMM0AYifmcrwpU=; b=hFAoCQzckQZhnxmJJfzJPLVJ7MUtUORTu+BbaZg65fa7SeD4X4TcJyKeOEe/6bgtkBNlEcEzwQLJEkZr3LpOz86dIwai7sdXY/EdWtr2R2+i97zSofLfP/WBS8V9PeLHFSvcf11MgaBOHn+be9DdO2s6+ZN5oolx8EyVezcQHkk= X-Mailman-Original-Authentication-Results: spf=fail (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.freedesktop.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.freedesktop.org; dmarc=none action=none header.from=arm.com; X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nd , Ayan Halder , "Oscar Zhang \(Arm Technology China\)" , "Tiannan Zhu \(Arm Technology China\)" , Daniel Vetter , "Jonathan Chai \(Arm Technology China\)" , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "Julien Yin \(Arm Technology China\)" , "Channing Chen \(Arm Technology China\)" , "james qian wang \(Arm Technology China\)" , "Yiqi Kang \(Arm Technology China\)" , "Thomas Sun \(Arm Technology China\)" , "Lowry Li \(Arm Technology China\)" , Ben Davis Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add a new helper function drm_color_ctm_s31_32_to_qm_n() for driver to convert S31.32 sign-magnitude to Qm.n 2's complement that supported by hardware. V4: Address Mihai, Daniel and Ilia's review comments. V5: Includes the sign bit in the value of m (Qm.n). V6: Allows m = 0 according to Mihail's comments. V7: Address Mihail's comments. V8: Use type 'u32' to replace 'uint32_t' Signed-off-by: james qian wang (Arm Technology China) Reviewed-by: Mihail Atanassov Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_color_mgmt.c | 34 ++++++++++++++++++++++++++++++++ include/drm/drm_color_mgmt.h | 1 + 2 files changed, 35 insertions(+) diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c index 4ce5c6d8de99..ba71e3b827f1 100644 --- a/drivers/gpu/drm/drm_color_mgmt.c +++ b/drivers/gpu/drm/drm_color_mgmt.c @@ -132,6 +132,40 @@ uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision) } EXPORT_SYMBOL(drm_color_lut_extract); +/** + * drm_color_ctm_s31_32_to_qm_n + * + * @user_input: input value + * @m: number of integer bits, only support m <= 32, include the sign-bit + * @n: number of fractional bits, only support n <= 32 + * + * Convert and clamp S31.32 sign-magnitude to Qm.n (signed 2's complement). + * The sign-bit BIT(m+n-1) and above are 0 for positive value and 1 for negative + * the range of value is [-2^(m-1), 2^(m-1) - 2^-n] + * + * For example + * A Q3.12 format number: + * - required bit: 3 + 12 = 15bits + * - range: [-2^2, 2^2 - 2^−15] + * + * NOTE: the m can be zero if all bit_precision are used to present fractional + * bits like Q0.32 + */ +u64 drm_color_ctm_s31_32_to_qm_n(u64 user_input, u32 m, u32 n) +{ + u64 mag = (user_input & ~BIT_ULL(63)) >> (32 - n); + bool negative = !!(user_input & BIT_ULL(63)); + s64 val; + + WARN_ON(m > 32 || n > 32); + + val = clamp_val(mag, 0, negative ? + BIT_ULL(n + m - 1) : BIT_ULL(n + m - 1) - 1); + + return negative ? -val : val; +} +EXPORT_SYMBOL(drm_color_ctm_s31_32_to_qm_n); + /** * drm_crtc_enable_color_mgmt - enable color management properties * @crtc: DRM CRTC diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h index d1c662d92ab7..997a42ab29f5 100644 --- a/include/drm/drm_color_mgmt.h +++ b/include/drm/drm_color_mgmt.h @@ -30,6 +30,7 @@ struct drm_crtc; struct drm_plane; uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision); +u64 drm_color_ctm_s31_32_to_qm_n(u64 user_input, u32 m, u32 n); void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc, uint degamma_lut_size, From patchwork Fri Nov 1 06:53:55 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: 11222447 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 3012013BD for ; Fri, 1 Nov 2019 06:54: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 15F85217D9 for ; Fri, 1 Nov 2019 06:54:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 15F85217D9 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 513576F70E; Fri, 1 Nov 2019 06:54:10 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50046.outbound.protection.outlook.com [40.107.5.46]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0FF7D6F70E for ; Fri, 1 Nov 2019 06:54:08 +0000 (UTC) Received: from DB6PR0802CA0041.eurprd08.prod.outlook.com (2603:10a6:4:a3::27) by DB6PR0801MB1863.eurprd08.prod.outlook.com (2603:10a6:4:76::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.24; Fri, 1 Nov 2019 06:54:05 +0000 Received: from DB5EUR03FT014.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::208) by DB6PR0802CA0041.outlook.office365.com (2603:10a6:4:a3::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2408.17 via Frontend Transport; Fri, 1 Nov 2019 06:54:05 +0000 Received-SPF: Fail (protection.outlook.com: domain of arm.com does not designate 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT014.mail.protection.outlook.com (10.152.20.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2387.20 via Frontend Transport; Fri, 1 Nov 2019 06:54:04 +0000 Received: ("Tessian outbound 927f2cdd66cc:v33"); Fri, 01 Nov 2019 06:54:03 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 929eb414ead90db0 X-CR-MTA-TID: 64aa7808 Received: from a5a1095d5c28.2 (cr-mta-lb-1.cr-mta-net [104.47.12.50]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 0B309B24-EFC7-451E-BBDB-CD2C8B6C9A38.1; Fri, 01 Nov 2019 06:53:58 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04lp2050.outbound.protection.outlook.com [104.47.12.50]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id a5a1095d5c28.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 01 Nov 2019 06:53:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b4K73owtHgtucvqFEUkoGVkrG0Z9vrQpINDNhylo5DUsXMeuH65pqzYxeTJsnA/P2HnzpMPR0O2qBiHLss4P2vIjB7jnFI7Oz2Vw/WHAYtXo9BYi0I18kwRJ1d8MmzbDBlEgOss9LXy9y/ItNWQQgfVjAYPhzltBkWtvc0DG5/tTI7N0LzhtGvgaR8Iws78XFwAYL4y3bMM+588PhtFXBqyzBeBcon1uyFdzSHf4HEf2k3KpfD9mO1MY3UbNCSOs2UN/eO/0gi0etocLc5xxArxLt/r5+xuPrG9vHjkryTMOXmFQpOvxzI20IUS1iH8knmugpJTuH93CKqyraWAJwA== 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=WQzAB7dSJx1S3J9sLVMloLHtn2+Cyg+gKsGHlSNBnambCNbJ7HfTxVsUiJFLwiFp0iHKWwG/FfL/m87dP27Z+94XGDWB/U2cfwG7FqYbyp7AnF6XK2SHvG/vBjO2u4Mi9xWc14ia/j3y1unnmHY8wFEjpsKqukW8JTAVl4LibvCgnpHxDxJ9lbnrClShLUb852vvWSj8KZSmh1dsZ9mKHWdtd/2h/6p5ppW7KbkIc3UTqvfFUYez5equbfvpUT/WvClfBhDn8xHSTRXtpyCGoLDz7q66m+QpM/l73w/+QrXYdG8eJHXyVAva9SskrJUrtyvqYKyPMxnEk0jtL2IvFw== 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 VE1SPR01MB0002.eurprd08.prod.outlook.com (20.179.193.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2408.17; Fri, 1 Nov 2019 06:53:55 +0000 Received: from VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::a809:417a:faf3:61a7]) by VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::a809:417a:faf3:61a7%6]) with mapi id 15.20.2387.030; Fri, 1 Nov 2019 06:53:55 +0000 From: "james qian wang (Arm Technology China)" To: Liviu Dudau , "airlied@linux.ie" , Brian Starkey , "maarten.lankhorst@linux.intel.com" , "sean@poorly.run" , Mihail Atanassov , "imirkin@alum.mit.edu" Subject: [PATCH v8 2/4] drm/komeda: Add drm_lut_to_fgamma_coeffs() Thread-Topic: [PATCH v8 2/4] drm/komeda: Add drm_lut_to_fgamma_coeffs() Thread-Index: AQHVkIEgVFu/k1utEUml4A+vyEm+iQ== Date: Fri, 1 Nov 2019 06:53:55 +0000 Message-ID: <20191101065319.29251-3-james.qian.wang@arm.com> References: <20191101065319.29251-1-james.qian.wang@arm.com> In-Reply-To: <20191101065319.29251-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: HK2PR0302CA0022.apcprd03.prod.outlook.com (2603:1096:202::32) 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-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 9797aadd-1af3-4e5a-629e-08d75e984911 X-MS-TrafficTypeDiagnostic: VE1SPR01MB0002:|VE1SPR01MB0002:|DB6PR0801MB1863: 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: 020877E0CB X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(396003)(376002)(136003)(39860400002)(346002)(366004)(199004)(189003)(66066001)(446003)(11346002)(2616005)(486006)(36756003)(8676002)(14454004)(5660300002)(476003)(103116003)(2501003)(2171002)(86362001)(3846002)(6116002)(305945005)(2201001)(25786009)(1076003)(6512007)(66476007)(52116002)(71200400001)(71190400001)(386003)(55236004)(6506007)(6436002)(102836004)(6486002)(7736002)(14444005)(186003)(99286004)(8936002)(110136005)(4326008)(54906003)(50226002)(478600001)(64756008)(2906002)(66446008)(81156014)(66556008)(316002)(66946007)(81166006)(76176011)(256004)(26005); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1SPR01MB0002; 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: qZDG91QD8O+FoDU/18w1oR5vlENb4mdrhD6VlYHDQ+PoUMSGhGWABd5h8e9Dd6kpesqmxrji4Slb9dJzDcOZ5xsPvtAB6HLtwX0lc5jNPnKAcCo0Z2MwzQHe+WM2jb9ghP9BihkGhgb2n1czjlSIYGdueyPT75bqycGgYOjm/smWIQCsJ3h8iD7e7kye8KD9QBdO2DT1gjaVvdaX9Hk0X7+88fC2KnAMTC1kX7yLxzP6BBrZQj96LKk0Ml4J+I/La4uqUbBpVw4EBflGPYSpQuliReg49pFue14FQrrscrYjVKc9pNEgmidPQvEn4NonPx3uOfdgrOvQo8WXUlG/wHwKMdOxhnJlZ3ynQw2Fg1w17EUB+vp34uqok/RwE4lKEViCUJHX/8Z87PEEAH25B8YLrOvPWb6hHJLfT5uOutTSqzOgwauCAqoD3KoXFb6u MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1SPR01MB0002 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT014.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)(396003)(136003)(376002)(346002)(1110001)(339900001)(199004)(189003)(76130400001)(336012)(2171002)(446003)(11346002)(386003)(6506007)(36756003)(356004)(186003)(76176011)(86362001)(2616005)(102836004)(26005)(2201001)(22756006)(70206006)(23756003)(70586007)(6486002)(2501003)(6512007)(5660300002)(6116002)(3846002)(1076003)(486006)(126002)(476003)(2906002)(305945005)(50226002)(26826003)(478600001)(47776003)(7736002)(316002)(25786009)(50466002)(105606002)(81166006)(8746002)(81156014)(99286004)(4326008)(8676002)(8936002)(14444005)(66066001)(14454004)(54906003)(110136005)(103116003); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0801MB1863; H:64aa7808-outbound-1.mta.getcheckrecipient.com; FPR:; SPF:Fail; LANG:en; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; A:1; MX:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: 6063315d-7c59-40e9-bf82-08d75e984354 NoDisclaimer: True X-Forefront-PRVS: 020877E0CB X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6EDxq3cnIWdCSF/4ULmI/WNSthfaeJCX305Vir5TUoKj+MERp1TNPcANDeCJjxuxRFGEPGTEG4p9KyTAYzfU2DuVnwhwCHU2yrHfQrPfgrpVHRIN1x/NMCf5VSup16bKa7VCMtmZy5WiFPSKU0FBrku+s7KYTVDRjdoZMs0+wB5W+7TLSDmPY70dtPsDp7MpNNaNGD5PDo4TWM5yhG1F46TFJvKTtFDupchoadTCRzBeehzHNmXZm4Ys9A9OdfZGXrnawZNHI4GB1O82/aiVDBey82I/yaZH39wfrmflNjsgIRkefUx6L2wWapitbsoQdeSYKUg+Fn/TSIPp4FdR1hoPlJ8P8MwUe8xGt7KvNt3JfpsSXYuUa9OIgUcZpknQcHXxobeXsylI1RAkg8Jb4PP52TjlkjwX8ldqdru60CudeQNhUOeM/5RaR4s/miwS X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2019 06:54:04.9610 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9797aadd-1af3-4e5a-629e-08d75e984911 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: DB6PR0801MB1863 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=2KivfaICzHYyUYef9HaUhEchtFV+Fvz/v3Dy7uOo9M37KlIU5zIWTmRioirZC5aRRqTwSmVVMNH3QniYAhm1qxo6EUEc/rjyGqWwCSjY0tYTKbsMGCZFcyO2znhNVSMvjcOn81E1Bp9VlttaxPlmJEEvW59tPPcw70owbKMFct4= 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=2KivfaICzHYyUYef9HaUhEchtFV+Fvz/v3Dy7uOo9M37KlIU5zIWTmRioirZC5aRRqTwSmVVMNH3QniYAhm1qxo6EUEc/rjyGqWwCSjY0tYTKbsMGCZFcyO2znhNVSMvjcOn81E1Bp9VlttaxPlmJEEvW59tPPcw70owbKMFct4= X-Mailman-Original-Authentication-Results: spf=fail (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.freedesktop.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.freedesktop.org; dmarc=none action=none header.from=arm.com; X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nd , Ayan Halder , "Oscar Zhang \(Arm Technology China\)" , "Tiannan Zhu \(Arm Technology China\)" , "Jonathan Chai \(Arm Technology China\)" , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "Julien Yin \(Arm Technology China\)" , "Channing Chen \(Arm Technology China\)" , "james qian wang \(Arm Technology China\)" , "Yiqi Kang \(Arm Technology China\)" , "Thomas Sun \(Arm Technology China\)" , "Lowry Li \(Arm Technology China\)" , Ben Davis Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This function is used to convert drm color lut to komeda HW required curve coeffs values. Signed-off-by: james qian wang (Arm Technology China) Reviewed-by: Mihail Atanassov --- .../arm/display/komeda/komeda_color_mgmt.c | 52 +++++++++++++++++++ .../arm/display/komeda/komeda_color_mgmt.h | 9 +++- 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c index 9d14a92dbb17..c180ce70c26c 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c @@ -65,3 +65,55 @@ const s32 *komeda_select_yuv2rgb_coeffs(u32 color_encoding, u32 color_range) return coeffs; } + +struct gamma_curve_sector { + u32 boundary_start; + u32 num_of_segments; + u32 segment_width; +}; + +struct gamma_curve_segment { + u32 start; + u32 end; +}; + +static struct gamma_curve_sector sector_tbl[] = { + { 0, 4, 4 }, + { 16, 4, 4 }, + { 32, 4, 8 }, + { 64, 4, 16 }, + { 128, 4, 32 }, + { 256, 4, 64 }, + { 512, 16, 32 }, + { 1024, 24, 128 }, +}; + +static void +drm_lut_to_coeffs(struct drm_property_blob *lut_blob, u32 *coeffs, + struct gamma_curve_sector *sector_tbl, u32 num_sectors) +{ + struct drm_color_lut *lut; + u32 i, j, in, num = 0; + + if (!lut_blob) + return; + + lut = lut_blob->data; + + for (i = 0; i < num_sectors; i++) { + for (j = 0; j < sector_tbl[i].num_of_segments; j++) { + in = sector_tbl[i].boundary_start + + j * sector_tbl[i].segment_width; + + coeffs[num++] = drm_color_lut_extract(lut[in].red, + KOMEDA_COLOR_PRECISION); + } + } + + coeffs[num] = BIT(KOMEDA_COLOR_PRECISION); +} + +void drm_lut_to_fgamma_coeffs(struct drm_property_blob *lut_blob, u32 *coeffs) +{ + drm_lut_to_coeffs(lut_blob, coeffs, sector_tbl, ARRAY_SIZE(sector_tbl)); +} diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h index a2df218f58e7..08ab69281648 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h +++ b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h @@ -11,7 +11,14 @@ #include #define KOMEDA_N_YUV2RGB_COEFFS 12 +#define KOMEDA_N_RGB2YUV_COEFFS 12 +#define KOMEDA_COLOR_PRECISION 12 +#define KOMEDA_N_GAMMA_COEFFS 65 +#define KOMEDA_COLOR_LUT_SIZE BIT(KOMEDA_COLOR_PRECISION) +#define KOMEDA_N_CTM_COEFFS 9 + +void drm_lut_to_fgamma_coeffs(struct drm_property_blob *lut_blob, u32 *coeffs); const s32 *komeda_select_yuv2rgb_coeffs(u32 color_encoding, u32 color_range); -#endif +#endif /*_KOMEDA_COLOR_MGMT_H_*/ From patchwork Fri Nov 1 06:54:02 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: 11222449 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 0B72913BD for ; Fri, 1 Nov 2019 06:54:18 +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 E653F217D9 for ; Fri, 1 Nov 2019 06:54:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E653F217D9 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 539196F70F; Fri, 1 Nov 2019 06:54:17 +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-db3eur04on060f.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0c::60f]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1F5D36F70F for ; Fri, 1 Nov 2019 06:54:16 +0000 (UTC) Received: from VE1PR08CA0001.eurprd08.prod.outlook.com (2603:10a6:803:104::14) by AM0PR08MB3617.eurprd08.prod.outlook.com (2603:10a6:208:db::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.24; Fri, 1 Nov 2019 06:54:12 +0000 Received: from AM5EUR03FT023.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::200) by VE1PR08CA0001.outlook.office365.com (2603:10a6:803:104::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2408.17 via Frontend Transport; Fri, 1 Nov 2019 06:54:12 +0000 Received-SPF: Fail (protection.outlook.com: domain of arm.com does not designate 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT023.mail.protection.outlook.com (10.152.16.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.20 via Frontend Transport; Fri, 1 Nov 2019 06:54:12 +0000 Received: ("Tessian outbound 0cf06bf5c60e:v33"); Fri, 01 Nov 2019 06:54:10 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 9575279cae463513 X-CR-MTA-TID: 64aa7808 Received: from 40ac0f1fb4d8.2 (cr-mta-lb-1.cr-mta-net [104.47.12.57]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id EA74F343-7B77-451B-B85A-4424F2A7F47D.1; Fri, 01 Nov 2019 06:54:05 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04lp2057.outbound.protection.outlook.com [104.47.12.57]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 40ac0f1fb4d8.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 01 Nov 2019 06:54:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eyGB2eVdXlY4UuVraWM1CN+NQdtnxWFYHRYEeVAn3BJihf+r5tMc5zmrS05qr8ca3h2CaqGeVG53vXhSbhswikKozpnrfd4ajEwr9KVTEOVZ4NNWS8DZnGoVpNWX6TmG6uizFbFe2awTgzGQCNzVVZk6zSHT7uZ9GJOtzt8DuyVR+0JHVkZe1AdjRHT2A/Er4B2CyNumciOVoBBacT+vGVBzzEMEIIvgdKjKpFEU8oGt8G6Ws4glAVNfJf2OvbKnyJzrFio354pjolpedGreOZdECv35rfcA8D3r1mJqOfoK7nKDcioi11y5l5uP/ihIsg4Casg52stLouooKyzlqA== 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=GGITmp9cJeb81yTOjIlHONILrd/vJ9OHWYUP6b0IZN2j3bBwv/sga5l6r+13JrHFu9Xb2FYVXmc4EPxUuSOefp3Udcbtj5gyY3MBRaVLmfT6diAs1o0RHag4I/w50DxjzexIF+2K/oOerZCaaH9/qxp+vg1OyoujuP6TbjWfLrto0qzVROcVuk3FhY2X08PHe7UV4N++2jDWUs+NtHD8lZbUSkHXt4P+U0XmLVSKemCWeZHM0xMa0SJs/tjZbkrceqlRmYMpdUZcw1cOvxFeLjaAoumosDLbjYEbYZPrnyA9qBB+gHjOjfDUGMcmW7NO1twQkZOmreoA7hgz2/vcJw== 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 VE1SPR01MB0002.eurprd08.prod.outlook.com (20.179.193.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2408.17; Fri, 1 Nov 2019 06:54:03 +0000 Received: from VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::a809:417a:faf3:61a7]) by VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::a809:417a:faf3:61a7%6]) with mapi id 15.20.2387.030; Fri, 1 Nov 2019 06:54:03 +0000 From: "james qian wang (Arm Technology China)" To: Liviu Dudau , "airlied@linux.ie" , Brian Starkey , "maarten.lankhorst@linux.intel.com" , "sean@poorly.run" , Mihail Atanassov , "imirkin@alum.mit.edu" Subject: [PATCH v8 3/4] drm/komeda: Add drm_ctm_to_coeffs() Thread-Topic: [PATCH v8 3/4] drm/komeda: Add drm_ctm_to_coeffs() Thread-Index: AQHVkIElzPvTOe8zQ0iuLclqIJbjiw== Date: Fri, 1 Nov 2019 06:54:02 +0000 Message-ID: <20191101065319.29251-4-james.qian.wang@arm.com> References: <20191101065319.29251-1-james.qian.wang@arm.com> In-Reply-To: <20191101065319.29251-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: HK2PR0302CA0022.apcprd03.prod.outlook.com (2603:1096:202::32) 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-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: ef0d9892-55d3-48cc-5fe3-08d75e984da8 X-MS-TrafficTypeDiagnostic: VE1SPR01MB0002:|VE1SPR01MB0002:|AM0PR08MB3617: 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: 020877E0CB X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(396003)(376002)(136003)(39860400002)(346002)(366004)(199004)(189003)(66066001)(446003)(11346002)(2616005)(486006)(36756003)(8676002)(14454004)(5660300002)(476003)(103116003)(2501003)(2171002)(86362001)(3846002)(6116002)(305945005)(2201001)(25786009)(1076003)(6512007)(66476007)(52116002)(71200400001)(71190400001)(386003)(55236004)(6506007)(6436002)(102836004)(6486002)(7736002)(186003)(99286004)(8936002)(110136005)(4326008)(54906003)(50226002)(478600001)(64756008)(2906002)(66446008)(81156014)(66556008)(316002)(66946007)(81166006)(76176011)(256004)(26005); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1SPR01MB0002; 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: J01wp0jxbXeg+FwkNh9o91Hf2h3uOb6SHct8UlpCw82gmhM3xYBfhYaxYFW8L2cXgCSXZTe4nsDGXYLZ4nyWg1z1y69xdLoLz1E2Ac04RvEg5v1l52R+uY+tf6jVKUlDUuNuVLjDAqlciU9up0y02xrPWTtSHLDy6vRowhsVu00A/9q6Xdoi6Sb6E7YYmjzpFjN/ODlOuj5Tj1uGErcupTX9JND4Wm/WGIhiEGXFZO6yKeeBJSbpe6z6aH6QP3FRgQCsCfygkCzlYsf/C3F/OY15FDbKK3C09qqMmGkVr1r5b2iY3YbKfKtp5d0Z/NVPf8pU/XBSgVobidlrnCiXpZDAttWk2ASIihXfB5y8arWoA2PYQkqJWss2UOSBQfWk4Imz1Id1jS3y6mTI492vqfQGq85QlTc1q+d5cNmsTgUKqMZpnN8VSbdukUB7bq1p MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1SPR01MB0002 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT023.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)(346002)(136003)(376002)(396003)(1110001)(339900001)(199004)(189003)(186003)(76130400001)(26826003)(50226002)(2171002)(2906002)(11346002)(26005)(110136005)(50466002)(103116003)(356004)(54906003)(478600001)(99286004)(386003)(5660300002)(316002)(70206006)(70586007)(6506007)(25786009)(1076003)(86362001)(22756006)(2616005)(446003)(14454004)(76176011)(105606002)(6512007)(476003)(126002)(47776003)(102836004)(6486002)(8746002)(36756003)(3846002)(336012)(305945005)(2501003)(8936002)(486006)(66066001)(23756003)(7736002)(81156014)(81166006)(8676002)(6116002)(4326008)(36906005)(2201001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR08MB3617; H:64aa7808-outbound-1.mta.getcheckrecipient.com; FPR:; SPF:Fail; LANG:en; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; A:1; MX:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: 2e337612-2fcd-44f2-1e59-08d75e9847b2 NoDisclaimer: True X-Forefront-PRVS: 020877E0CB X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E3oxgC//1qA2kT7uty/RwYlpA+qcCGZGXUVrFLrHzUde0G3UCFh1bO85bMXGJRaxe/n3ATH838OYIGetOYqnL4NHHlwZfw73crPBxWyOOfPpCHH6x+d21X7Y2bkoVcpQicT78kcSjX2w6XQNIbVMEUT26DLo8do3nX6wImkob5zks5xZ9hGqZCOVyvOOl0d+a8xfKowhkmT1qhPMX5fgVlk2MqrzrrziyubF1FjOWJZeNeClI/gJiGKWUHPNAhYqF0YxoUDOTAJ+QwN/3xY2wtXb5XNsj0rDSJiEPALoa9AbckoneuIiXuuMKFxgAPyk4V4UyhukrgJftl/2Y3jdzVlSdeMVC+OPZQE+xLHaGsonOFnkIhXdWg8ojUwoAQ/BB0qk9XyY9zsqye++0HpGJSAAHXZ/sT3Hp+F9tLiwAX08wjgTOmk8QtQimltyr9lo X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2019 06:54:12.6514 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ef0d9892-55d3-48cc-5fe3-08d75e984da8 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: AM0PR08MB3617 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=+DProxGofEk4F1uuIcstwG/ztC2ADlxa0y28Ga2+l+2yDYcBDil/+YVDsAg0tbNtXTm/rfvst9Dw7uthLCLlMQY3CXAjTrB4vst2KjYRzgV5UUcQLWqm7EHsGZWZihcuuzlcpeiwE3OP5iKHPt1Bv8aVDuiVhF9ZL5cReDS7OBY= 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=+DProxGofEk4F1uuIcstwG/ztC2ADlxa0y28Ga2+l+2yDYcBDil/+YVDsAg0tbNtXTm/rfvst9Dw7uthLCLlMQY3CXAjTrB4vst2KjYRzgV5UUcQLWqm7EHsGZWZihcuuzlcpeiwE3OP5iKHPt1Bv8aVDuiVhF9ZL5cReDS7OBY= X-Mailman-Original-Authentication-Results: spf=fail (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.freedesktop.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.freedesktop.org; dmarc=none action=none header.from=arm.com; X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nd , Ayan Halder , "Oscar Zhang \(Arm Technology China\)" , "Tiannan Zhu \(Arm Technology China\)" , "Jonathan Chai \(Arm Technology China\)" , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "Julien Yin \(Arm Technology China\)" , "Channing Chen \(Arm Technology China\)" , "james qian wang \(Arm Technology China\)" , "Yiqi Kang \(Arm Technology China\)" , "Thomas Sun \(Arm Technology China\)" , "Lowry Li \(Arm Technology China\)" , Ben Davis Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This function is for converting drm_color_ctm matrix to komeda hardware required required Q2.12 2's complement CSC matrix. v2: Move the fixpoint conversion function s31_32_to_q2_12() to drm core as a shared helper. Signed-off-by: james qian wang (Arm Technology China) Reviewed-by: Mihail Atanassov --- .../gpu/drm/arm/display/komeda/komeda_color_mgmt.c | 14 ++++++++++++++ .../gpu/drm/arm/display/komeda/komeda_color_mgmt.h | 1 + 2 files changed, 15 insertions(+) diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c index c180ce70c26c..d8e449e6ebda 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c @@ -117,3 +117,17 @@ void drm_lut_to_fgamma_coeffs(struct drm_property_blob *lut_blob, u32 *coeffs) { drm_lut_to_coeffs(lut_blob, coeffs, sector_tbl, ARRAY_SIZE(sector_tbl)); } + +void drm_ctm_to_coeffs(struct drm_property_blob *ctm_blob, u32 *coeffs) +{ + struct drm_color_ctm *ctm; + u32 i; + + if (!ctm_blob) + return; + + ctm = ctm_blob->data; + + for (i = 0; i < KOMEDA_N_CTM_COEFFS; i++) + coeffs[i] = drm_color_ctm_s31_32_to_qm_n(ctm->matrix[i], 3, 12); +} diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h index 08ab69281648..2f4668466112 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h +++ b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h @@ -18,6 +18,7 @@ #define KOMEDA_N_CTM_COEFFS 9 void drm_lut_to_fgamma_coeffs(struct drm_property_blob *lut_blob, u32 *coeffs); +void drm_ctm_to_coeffs(struct drm_property_blob *ctm_blob, u32 *coeffs); const s32 *komeda_select_yuv2rgb_coeffs(u32 color_encoding, u32 color_range); From patchwork Fri Nov 1 06:54:10 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: 11222451 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 9B9C71515 for ; Fri, 1 Nov 2019 06:54: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 8022421835 for ; Fri, 1 Nov 2019 06:54:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8022421835 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 D76F96F717; Fri, 1 Nov 2019 06:54:27 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150074.outbound.protection.outlook.com [40.107.15.74]) by gabe.freedesktop.org (Postfix) with ESMTPS id 727136F717 for ; Fri, 1 Nov 2019 06:54:25 +0000 (UTC) Received: from VI1PR0802CA0036.eurprd08.prod.outlook.com (2603:10a6:800:a9::22) by HE1PR0801MB1788.eurprd08.prod.outlook.com (2603:10a6:3:88::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2408.24; Fri, 1 Nov 2019 06:54:21 +0000 Received: from VE1EUR03FT011.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::200) by VI1PR0802CA0036.outlook.office365.com (2603:10a6:800:a9::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2408.19 via Frontend Transport; Fri, 1 Nov 2019 06:54:20 +0000 Received-SPF: Fail (protection.outlook.com: domain of arm.com does not designate 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT011.mail.protection.outlook.com (10.152.18.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.20 via Frontend Transport; Fri, 1 Nov 2019 06:54:20 +0000 Received: ("Tessian outbound 081de437afc7:v33"); Fri, 01 Nov 2019 06:54:18 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 27ccc1771b6db4c7 X-CR-MTA-TID: 64aa7808 Received: from 342a855bf8bd.2 (cr-mta-lb-1.cr-mta-net [104.47.12.56]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 89644E4E-0FCB-43A1-92BA-E04135A9C2D9.1; Fri, 01 Nov 2019 06:54:13 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04lp2056.outbound.protection.outlook.com [104.47.12.56]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 342a855bf8bd.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 01 Nov 2019 06:54:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JSaHuYlcqiw1WhwdFABg0ouu6zfXknHmL3nCwwH8ShUgTwoKM1LBWaczD6ySZscWYrBvKtVTOUQaTkjUKnlJtjJ3IckrMbKxDMnM3w+bEwmsXnmvu+rK1QUqklGFqy5l16MVWNFJfgIGCu23MOE3Exo42wsF/xou6BFkT78UOBr9NG258JaygACueJFNwYG6Dbm0txQpNK1M8X6Trtxddic72fpMp5xEVnp/PfL2GHlxPPvuNxknSLiQHd9MN8fDozXVT1FgWDLbZM6iRdG2MkpNVB03nUVrVSSDWUUB07I8ZZJklgI1Hmso+aU8OgiASj5QBXm6D/I6Ow/PVRZuZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9TQq3bHNRrYQiNPP2nRVJpod47h6p3GxLvGsKKnTnHo=; b=cif8TLhpGae9vvoB/yRbA9Pf1Iowi4P78+/7lNc+xN5do6P8Bl2VTyHIk5ovhlXby9Fxn5r9EcfRl/y736/m7lZ9nY6yZs0NU/EoF+MtiEobS04PvQNk8t8/UGZm0GDji4qwbbmmikqD6vctb+3EOJxRxSrzfjhA7qvwVHHZrFVMo7SEEx+gsVpiqSKFFqg46qn8EsRVxOT7ZOs1FwMI2Ht/QJ05x4eIcoaiXAK274z7+3VRe2sDngD+lnrG7Bs4Seif/bWTSdS9L2StUmtWHgXgh+t30oL7X6K9BncN9qxMSBrl+BFZf9gmTZUEmJejiwhiD9cfBCKRvVhUO3tuew== 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 VE1SPR01MB0002.eurprd08.prod.outlook.com (20.179.193.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2408.17; Fri, 1 Nov 2019 06:54:11 +0000 Received: from VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::a809:417a:faf3:61a7]) by VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::a809:417a:faf3:61a7%6]) with mapi id 15.20.2387.030; Fri, 1 Nov 2019 06:54:11 +0000 From: "james qian wang (Arm Technology China)" To: Liviu Dudau , "airlied@linux.ie" , Brian Starkey , "maarten.lankhorst@linux.intel.com" , "sean@poorly.run" , Mihail Atanassov , "imirkin@alum.mit.edu" Subject: [PATCH v8 4/4] drm/komeda: Adds gamma and color-transform support for DOU-IPS Thread-Topic: [PATCH v8 4/4] drm/komeda: Adds gamma and color-transform support for DOU-IPS Thread-Index: AQHVkIEqK7frcEGc3kG9AqJwM+vaIw== Date: Fri, 1 Nov 2019 06:54:10 +0000 Message-ID: <20191101065319.29251-5-james.qian.wang@arm.com> References: <20191101065319.29251-1-james.qian.wang@arm.com> In-Reply-To: <20191101065319.29251-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: HK2PR0302CA0022.apcprd03.prod.outlook.com (2603:1096:202::32) 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-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: c3e6a63b-12a1-4d38-c37d-08d75e98528b X-MS-TrafficTypeDiagnostic: VE1SPR01MB0002:|VE1SPR01MB0002:|HE1PR0801MB1788: 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: 020877E0CB X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(396003)(376002)(136003)(39860400002)(346002)(366004)(199004)(189003)(66066001)(446003)(11346002)(2616005)(486006)(36756003)(8676002)(14454004)(5660300002)(476003)(103116003)(2501003)(2171002)(86362001)(3846002)(6116002)(305945005)(2201001)(25786009)(1076003)(6512007)(66476007)(52116002)(71200400001)(71190400001)(386003)(55236004)(6506007)(6436002)(102836004)(6486002)(7736002)(14444005)(186003)(99286004)(8936002)(110136005)(4326008)(54906003)(50226002)(478600001)(64756008)(2906002)(66446008)(81156014)(66556008)(316002)(66946007)(81166006)(76176011)(256004)(26005); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1SPR01MB0002; 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: BNzzA4Kjin9yYjpGXKXnDDkrSkKd1qyeprWHxOBFS9bmohvVVDQUwWUX7hqhN4z7HScNODUPMrXRBy+EgV4T3zQzOlcEd62SJ8koRshI0VZrsvV/aW3OC7ma/OG8rCbpGmmIxfvtmc5N6mdFMHOOXKtux/2zBwO3SER83brFu8QA4bhmX7p4ofvYjrUXVh2piZS5y2BQeRk4hhEUaCq0gcdfoTqZT3QiqVTzCpn/hCVeN1tSKWrZAlhub60zO2N9i2TU6yU5xEigNRxhEhl0tUL6MCoFHYTarHBBRhYlj4frk2iKkMVvtTZz33PkgU4S+7BtgL1rjz65yAOzWyEZWqp9HB/HtZ8Qj9LXqJFcNMoJoq8yrz1jnB2b0tSEZdPDbV3yWM+u+ruF2X/lkJ+/JAS8Okm46D2/KxrlnR0MIHW668oTjTvtz6V2Hl7CwOmS MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1SPR01MB0002 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT011.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)(376002)(136003)(346002)(396003)(1110001)(339900001)(199004)(189003)(81156014)(26826003)(8676002)(81166006)(478600001)(105606002)(14454004)(6486002)(25786009)(50226002)(36906005)(26005)(54906003)(23756003)(8936002)(8746002)(99286004)(6512007)(70206006)(4326008)(70586007)(76176011)(110136005)(2171002)(316002)(76130400001)(386003)(36756003)(6506007)(102836004)(50466002)(186003)(1076003)(22756006)(7736002)(2906002)(66066001)(47776003)(2501003)(305945005)(86362001)(14444005)(2201001)(336012)(5660300002)(486006)(476003)(103116003)(126002)(3846002)(2616005)(6116002)(11346002)(446003)(356004); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0801MB1788; H:64aa7808-outbound-1.mta.getcheckrecipient.com; FPR:; SPF:Fail; LANG:en; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; A:1; MX:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: 4c1abd58-5aa8-4e1a-e3a1-08d75e984c64 NoDisclaimer: True X-Forefront-PRVS: 020877E0CB X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LhcCqIQApXNZDLh89O3Kd6BX1alrfDsr+p22SMkFuUi6Cnb67h4hNiwa1bzQEs3w+XUgyAk202QqXA9DuEvXpxHu8pZ8w0Mky6ecOm3ZkubV5fM/b0h9WMwjzVkwZ7BfinFmbY+R1fesSmDU0nzgdJFQP/yGJlEh8VMabxXphfFBsXygnzm1V0hbVrvR9oHug4P3HzDtwxlKCPRfZjD5G2LtRGykQ+hMOwnadkzFC+moNYwBwnyL0wwyCMur8UTCEzMsT9g99nlRLc3Zdjx5r1PuhVdlXu1cg0ezTq75+aP0OpYTb6WRfLKnMCKjhGoNrJurVn5SBfg+t5mAscTRnHbDYYQDG+ACq15zESbCgpLcqGIaegRxgQB3eOYevIfW/CPfj2vDcxO1A9adDRca8Zg2S6qJVojQXMfH+sWIVShrldvoD4k0v4qqRPMjCr3E X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2019 06:54:20.8074 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c3e6a63b-12a1-4d38-c37d-08d75e98528b 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: HE1PR0801MB1788 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9TQq3bHNRrYQiNPP2nRVJpod47h6p3GxLvGsKKnTnHo=; b=4XZkux5NumDAb2H8tdwo3YGExFmR5M8cPoEUTp5y6rDG9SrQBdFP93+qytUdQrGIiMaASVsz9L4H0hRQFd84porZY2rG9Fc4tack8klNVHH/Z1J+yDIUdpiWU4M654pOJvXwA/JsQGkYJjJ+DTOYF6qK9CicLDinw/dl+ENxG08= X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9TQq3bHNRrYQiNPP2nRVJpod47h6p3GxLvGsKKnTnHo=; b=4XZkux5NumDAb2H8tdwo3YGExFmR5M8cPoEUTp5y6rDG9SrQBdFP93+qytUdQrGIiMaASVsz9L4H0hRQFd84porZY2rG9Fc4tack8klNVHH/Z1J+yDIUdpiWU4M654pOJvXwA/JsQGkYJjJ+DTOYF6qK9CicLDinw/dl+ENxG08= X-Mailman-Original-Authentication-Results: spf=fail (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.freedesktop.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.freedesktop.org; dmarc=none action=none header.from=arm.com; X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nd , Ayan Halder , "Oscar Zhang \(Arm Technology China\)" , "Tiannan Zhu \(Arm Technology China\)" , "Jonathan Chai \(Arm Technology China\)" , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "Julien Yin \(Arm Technology China\)" , "Channing Chen \(Arm Technology China\)" , "Yiqi Kang \(Arm Technology China\)" , "Thomas Sun \(Arm Technology China\)" , "Lowry Li \(Arm Technology China\)" , Ben Davis Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: "Lowry Li (Arm Technology China)" Adds gamma and color-transform support for DOU-IPS. Adds two caps members fgamma_coeffs and ctm_coeffs to komeda_improc_state. If color management changed, set gamma and color-transform accordingly. v5: Rebase with drm-misc-next Signed-off-by: Lowry Li (Arm Technology China) Reviewed-by: Mihail Atanassov --- .../arm/display/komeda/d71/d71_component.c | 20 +++++++++++++++++++ .../gpu/drm/arm/display/komeda/komeda_crtc.c | 2 ++ .../drm/arm/display/komeda/komeda_pipeline.h | 3 +++ .../display/komeda/komeda_pipeline_state.c | 6 ++++++ 4 files changed, 31 insertions(+) diff --git a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c index f0ba26e282c3..b6517c46e670 100644 --- a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c +++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c @@ -1044,7 +1044,9 @@ static int d71_merger_init(struct d71_dev *d71, static void d71_improc_update(struct komeda_component *c, struct komeda_component_state *state) { + struct drm_crtc_state *crtc_st = state->crtc->state; struct komeda_improc_state *st = to_improc_st(state); + struct d71_pipeline *pipe = to_d71_pipeline(c->pipeline); u32 __iomem *reg = c->reg; u32 index, mask = 0, ctrl = 0; @@ -1055,6 +1057,24 @@ static void d71_improc_update(struct komeda_component *c, malidp_write32(reg, BLK_SIZE, HV_SIZE(st->hsize, st->vsize)); malidp_write32(reg, IPS_DEPTH, st->color_depth); + if (crtc_st->color_mgmt_changed) { + mask |= IPS_CTRL_FT | IPS_CTRL_RGB; + + if (crtc_st->gamma_lut) { + malidp_write_group(pipe->dou_ft_coeff_addr, FT_COEFF0, + KOMEDA_N_GAMMA_COEFFS, + st->fgamma_coeffs); + ctrl |= IPS_CTRL_FT; /* enable gamma */ + } + + if (crtc_st->ctm) { + malidp_write_group(reg, IPS_RGB_RGB_COEFF0, + KOMEDA_N_CTM_COEFFS, + st->ctm_coeffs); + ctrl |= IPS_CTRL_RGB; /* enable gamut */ + } + } + mask |= IPS_CTRL_YUV | IPS_CTRL_CHD422 | IPS_CTRL_CHD420; /* config color format */ diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c index 252015210fbc..1c452ea75999 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c @@ -617,6 +617,8 @@ static int komeda_crtc_add(struct komeda_kms_dev *kms, crtc->port = kcrtc->master->of_output_port; + drm_crtc_enable_color_mgmt(crtc, 0, true, KOMEDA_COLOR_LUT_SIZE); + return err; } diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h index bd6ca7c87037..ac8725e24853 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h @@ -11,6 +11,7 @@ #include #include #include "malidp_utils.h" +#include "komeda_color_mgmt.h" #define KOMEDA_MAX_PIPELINES 2 #define KOMEDA_PIPELINE_MAX_LAYERS 4 @@ -327,6 +328,8 @@ struct komeda_improc_state { struct komeda_component_state base; u8 color_format, color_depth; u16 hsize, vsize; + u32 fgamma_coeffs[KOMEDA_N_GAMMA_COEFFS]; + u32 ctm_coeffs[KOMEDA_N_CTM_COEFFS]; }; /* display timing controller */ diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c index 42bdc63dcffa..0930234abb9d 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c @@ -802,6 +802,12 @@ komeda_improc_validate(struct komeda_improc *improc, st->color_format = BIT(__ffs(avail_formats)); } + if (kcrtc_st->base.color_mgmt_changed) { + drm_lut_to_fgamma_coeffs(kcrtc_st->base.gamma_lut, + st->fgamma_coeffs); + drm_ctm_to_coeffs(kcrtc_st->base.ctm, st->ctm_coeffs); + } + komeda_component_add_input(&st->base, &dflow->input, 0); komeda_component_set_output(&dflow->input, &improc->base, 0);