From patchwork Fri Oct 11 05:45:27 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: 11184843 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 9772714ED for ; Fri, 11 Oct 2019 05:45:59 +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 7E99F214E0 for ; Fri, 11 Oct 2019 05:45:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7E99F214E0 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 9B0F56EB97; Fri, 11 Oct 2019 05:45:58 +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-vi1eur04on0619.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0e::619]) by gabe.freedesktop.org (Postfix) with ESMTPS id BE0EF6EB97 for ; Fri, 11 Oct 2019 05:45:53 +0000 (UTC) Received: from AM4PR08CA0045.eurprd08.prod.outlook.com (2603:10a6:205:2::16) by HE1PR0802MB2137.eurprd08.prod.outlook.com (2603:10a6:3:c8::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.20; Fri, 11 Oct 2019 05:45:49 +0000 Received: from VE1EUR03FT003.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::209) by AM4PR08CA0045.outlook.office365.com (2603:10a6:205:2::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2347.16 via Frontend Transport; Fri, 11 Oct 2019 05:45:49 +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 VE1EUR03FT003.mail.protection.outlook.com (10.152.18.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.15 via Frontend Transport; Fri, 11 Oct 2019 05:45:47 +0000 Received: ("Tessian outbound 3fba803f6da3:v33"); Fri, 11 Oct 2019 05:45:34 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: e3db94b223a7aa1e X-CR-MTA-TID: 64aa7808 Received: from 0016c1b5f25c.2 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.9.52]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id BB36F53E-3171-470C-9BAA-14A3D2F9E699.1; Fri, 11 Oct 2019 05:45:29 +0000 Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-ve1eur03lp2052.outbound.protection.outlook.com [104.47.9.52]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 0016c1b5f25c.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Fri, 11 Oct 2019 05:45:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JEQxeexqiS4RYFzgegTIxOc421T3TU5DQOUmE2ECfPUQUdpniyCjS/cm25WulLRTqt6kSqPLUXk6nV0jvSLLiWJYNVHQeaPoNoA8ycb/BZCarDGRrYOg0T4Hq5js8mqNM0VOYvNC/L423fePniNNJFDwwLAxOyzGSgL+9kVIOMPM7m8hh2oTY1iN5p/AaVFKGaOPZhw1OcudVtIKQeraEUkArhq52dQuXOm+RqczPrjgzoFeRGG+exjbTOLZ9ID0L9qS9+ihlhp5gqy6mBOAAbkFBom8kUIGo7hQn7Plix2kIahhG34gkMdMz0I5siUDmk/K8fDD+gWQ1meiszo70A== 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=Tg5FqZcXN1Q8PYyDwUWcRuC6JhC60pEQl00Wv88LR5o=; b=iPRwWhNKYhy/kSGjEcYev+lmosEMXnrRsYb4qTRjDKLz6v66Yq3lNdH5Xrckmb4GX2k/G02K9XyP08suCdVroZY3fdbPo2fmi4akRW0zMvY+X6FMNS90BP96VGpogBExfX6F61a1VZoPF3PewL0Gz8qBVnd7ZZL2tLaXj5sJml0b4DS0iGfWvZR2rdFqlDcN61Rq1BIc4RJIXT6673St0wwZKsLNXsGa57xQ2Md36zt+yuk4PAgj1DIUbrdbcFjMBdseJLlzsgwri9G5o7iEkpN9fO+Fp0R9nO4YIPjxLWDqmfSiqcOquZ5ye4enicfDBgfjYtr+MSoET93fYnmOeA== 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 VE1PR08MB4816.eurprd08.prod.outlook.com (10.255.112.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.16; Fri, 11 Oct 2019 05:45:27 +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.021; Fri, 11 Oct 2019 05:45:27 +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 v2 1/4] drm: Add a new helper drm_color_ctm_s31_32_to_qm_n() Thread-Topic: [PATCH v2 1/4] drm: Add a new helper drm_color_ctm_s31_32_to_qm_n() Thread-Index: AQHVf/cV8wl8pZbk8kmsplok4zd2Gw== Date: Fri, 11 Oct 2019 05:45:27 +0000 Message-ID: <20191011054459.17984-2-james.qian.wang@arm.com> References: <20191011054459.17984-1-james.qian.wang@arm.com> In-Reply-To: <20191011054459.17984-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: HK0PR03CA0011.apcprd03.prod.outlook.com (2603:1096:203:2e::23) 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: 2bf9f7b4-2580-45e2-ee62-08d74e0e43ed X-MS-Office365-Filtering-HT: Tenant X-MS-TrafficTypeDiagnostic: VE1PR08MB4816:|VE1PR08MB4816:|HE1PR0802MB2137: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:4125;OLM:4125; x-forefront-prvs: 0187F3EA14 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(366004)(136003)(39860400002)(396003)(376002)(346002)(199004)(189003)(4326008)(2201001)(2171002)(86362001)(2906002)(103116003)(36756003)(6512007)(1076003)(316002)(110136005)(81156014)(81166006)(8936002)(6436002)(54906003)(99286004)(50226002)(305945005)(7736002)(8676002)(3846002)(76176011)(6116002)(5660300002)(52116002)(6486002)(66476007)(6506007)(386003)(66556008)(66446008)(64756008)(14454004)(446003)(186003)(11346002)(256004)(26005)(102836004)(71200400001)(2616005)(476003)(486006)(66946007)(55236004)(25786009)(71190400001)(2501003)(66066001)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB4816; 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: kZseXxyq3+7BV1f66OK9E+I9JtdhGNwjl4tARhiY6Zg8TKORfT27y4FP8rMVTdnbYeXdhUhU5LPp9ETFajKpKkOaQS2wt50eLV9Hu+djsYHdZeXN8b+d3wNAh9xZ2p6BTZB+bnGSckiMAeIX7n78dLtlauSMtvbXlBreliv/oVH4Q2ibvdBDp+BPZty1i6b+wW//urY4kzUP+YRWMLiouLVeDcJjxn4OJq68zyCLwKOCvvDd+PUSGJyB7dvCRI/O3Vvqtb2nxyIxkW8P1i+5o7kGOtbIqMJ4TkSEQo3QwLbpD5CqW0Tu8QbBi3xTNHGSSLOvUIIDlo7kXk6NSZjMPYklfPstp1Flc+6zzixZwBK9etbiBIjMgNa7CW4kYFnfRrrYmPgAFWg6M8x3m0K5FAcT2y3U0wiEPvqKMQjdomM= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4816 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT003.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; IPV:CAL; SCL:-1; CTRY:IE; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(376002)(39860400002)(136003)(396003)(346002)(199004)(189003)(86362001)(3846002)(316002)(26005)(102836004)(23756003)(76176011)(47776003)(36756003)(1076003)(6116002)(54906003)(22756006)(6512007)(6506007)(110136005)(2201001)(36906005)(4326008)(7736002)(2501003)(2171002)(305945005)(66066001)(63350400001)(478600001)(50466002)(386003)(186003)(336012)(6486002)(486006)(11346002)(126002)(476003)(14454004)(5660300002)(8936002)(8676002)(76130400001)(50226002)(356004)(70586007)(81166006)(99286004)(81156014)(25786009)(2616005)(26826003)(2906002)(446003)(70206006)(103116003)(8746002); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0802MB2137; 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: 569d4c24-4bc1-4db0-0474-08d74e0e3817 NoDisclaimer: True X-Forefront-PRVS: 0187F3EA14 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xzewXLLaAQEZoHTLZ+3Ixbe8Wzeh0vDOPhQgtOwbjfaFfGJTTo3G4p719ApSrvOzx5aNHVj26Pls4tILU897v2eACZYGi58COO07+Ea+Wtn/8QHjRtW2Rqm9vqVQHVnHeNGiqqRRwaaugdd55Va7QHcVWVRoBQTz39KxNmQ25uj9N6E34hdVmfHyzYsYi2T+z5pFSOurreoHcV/yC/x98xRSN9V20RLNhWe8eLUQqVEOOnD+7hsKHJMRwa5x8IHhPIKrcC8BNFoZc42jsljfLcROPELgwi1B6cULYkT/mQ7ufnhcJLWGgoCQoEh8THf4WJpHEPPOIXv4ZLxiE/rTtmvzzKD6/pBybs866ZqSyJVJM7at2eFbtStC/T0BS3isT/rRf5tVj1wZr0DBzT+ZEA4qitTcBuJ3vb7WE3SQrbc= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Oct 2019 05:45:47.1348 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2bf9f7b4-2580-45e2-ee62-08d74e0e43ed 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: HE1PR0802MB2137 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=Tg5FqZcXN1Q8PYyDwUWcRuC6JhC60pEQl00Wv88LR5o=; b=EeI9cSGdeSucDS2FIuk33MCGsS7//zHVxiRlKdOtPXkCczahabF1ngjLiiW20AmxAn02r7pH7//omcR4Ijpi8C+U/S3kgVLhhKlmaDRXXtpSb7YdyPKx4qKc0w92IEPaXXEu44emGwaw/6MgUCFGJ0cKzzfn0bolVW1CRmg25es= 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=Tg5FqZcXN1Q8PYyDwUWcRuC6JhC60pEQl00Wv88LR5o=; b=EeI9cSGdeSucDS2FIuk33MCGsS7//zHVxiRlKdOtPXkCczahabF1ngjLiiW20AmxAn02r7pH7//omcR4Ijpi8C+U/S3kgVLhhKlmaDRXXtpSb7YdyPKx4qKc0w92IEPaXXEu44emGwaw/6MgUCFGJ0cKzzfn0bolVW1CRmg25es= 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" 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. Signed-off-by: james qian wang (Arm Technology China) Reviewed-by: Mihail Atanassov --- drivers/gpu/drm/drm_color_mgmt.c | 23 +++++++++++++++++++++++ include/drm/drm_color_mgmt.h | 2 ++ 2 files changed, 25 insertions(+) -- 2.20.1 diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c index 4ce5c6d8de99..3d533d0b45af 100644 --- a/drivers/gpu/drm/drm_color_mgmt.c +++ b/drivers/gpu/drm/drm_color_mgmt.c @@ -132,6 +132,29 @@ 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 + * @n: number of fractinal bits + * + * Convert and clamp S31.32 sign-magnitude to Qm.n 2's complement. + */ +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; + + /* the range of signed 2s complement is [-2^n+m, 2^n+m - 1] */ + val = clamp_val(mag, 0, negative ? BIT(n + m) : BIT(n + m) - 1); + + return negative ? 0ll - 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 Fri Oct 11 05:45:35 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: 11184841 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 E281914ED for ; Fri, 11 Oct 2019 05:45:56 +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 C13A2206A1 for ; Fri, 11 Oct 2019 05:45:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C13A2206A1 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 F0C146E554; Fri, 11 Oct 2019 05:45:55 +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-eopbgr50087.outbound.protection.outlook.com [40.107.5.87]) by gabe.freedesktop.org (Postfix) with ESMTPS id 32B956E554 for ; Fri, 11 Oct 2019 05:45:53 +0000 (UTC) Received: from VI1PR08CA0152.eurprd08.prod.outlook.com (2603:10a6:800:d5::30) by VI1PR08MB3664.eurprd08.prod.outlook.com (2603:10a6:803:85::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.16; Fri, 11 Oct 2019 05:45:49 +0000 Received: from VE1EUR03FT024.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::206) by VI1PR08CA0152.outlook.office365.com (2603:10a6:800:d5::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2347.17 via Frontend Transport; Fri, 11 Oct 2019 05:45:49 +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 VE1EUR03FT024.mail.protection.outlook.com (10.152.18.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.15 via Frontend Transport; Fri, 11 Oct 2019 05:45:47 +0000 Received: ("Tessian outbound 0939a6bab6b1:v33"); Fri, 11 Oct 2019 05:45:42 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: ee33e86667b35187 X-CR-MTA-TID: 64aa7808 Received: from e02de6d1ad5a.2 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.10.50]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 53D50113-D5A6-4B8F-94F2-90B2EFAC6E97.1; Fri, 11 Oct 2019 05:45:37 +0000 Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-db5eur03lp2050.outbound.protection.outlook.com [104.47.10.50]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e02de6d1ad5a.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Fri, 11 Oct 2019 05:45:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lnW9vM/69pyvXM5QdOx/44ArSrxixR9Kvwcoo46GZbdf6Ug/XZzrdSaYWWdDRWZ6gaNiyBVA9fKDspbzsAvgvICChfSJGeHbzl9DLmneYlY4ITVBLJk0LF4HrRSWkVIbAyLPaxr+eSq69iZQGX94H8GTsQpL1CSUIbL/kSQG31aI6s+9QFVS5VTtkvIEGpOSTbApm+foM7shJrMQJEwUAGjPFp6QctYMreI7fuQMlNtslLY317iNQleeE1LSX4hyrEumWtLZhBpjeSjYbhAka0Mzu6JCzG+avym4B3pNbUp6iQ4NgfLVus25YlyXGN2uzBeLKgqr4mUqR6D1kkuEBg== 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=fUBbQ6jci7ZZBrBwHMNuLpOgBHySGEUsJ89UPIG5ETg=; b=c1KAGTB0qU1jk8NveHdZBAxbwGIFz3GB8rfN7X+oz0Lb7aM1uXUaXW7S/rIp0A4Y6wWw4tXgckGKqTmQD2GRLctpbMR9NfcvcrKEvZWwZ2DqQrqUkBmM3smxSZDx0AipwFGq7PY/84xyhMDrFXTf0dVCMtPqZGAvvq97mD8qY2vX44pXmg3xF/vy6UGPXZh23/xq040eI41Pqm/Q+oTYkdHWpn6nFPmkAptSyx4TLTk3V6VCvQvCvufGTnUvZdaxcb+hxlKdpkiZt5a4SWg0eMOdfc9sIIeQ4VGzfwvDWDKTeLNozyvNndf90b5wfUeolNkAazwxEJ2lh1EXHNN4Rw== 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 VE1PR08MB4816.eurprd08.prod.outlook.com (10.255.112.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.16; Fri, 11 Oct 2019 05:45:35 +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.021; Fri, 11 Oct 2019 05:45:35 +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 v2 2/4] drm/komeda: Add drm_lut_to_fgamma_coeffs() Thread-Topic: [PATCH v2 2/4] drm/komeda: Add drm_lut_to_fgamma_coeffs() Thread-Index: AQHVf/cahg9HTk7nnke/u6sXaUorqg== Date: Fri, 11 Oct 2019 05:45:35 +0000 Message-ID: <20191011054459.17984-3-james.qian.wang@arm.com> References: <20191011054459.17984-1-james.qian.wang@arm.com> In-Reply-To: <20191011054459.17984-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: HK0PR03CA0011.apcprd03.prod.outlook.com (2603:1096:203:2e::23) 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: 06545c5e-4a04-4235-600f-08d74e0e4456 X-MS-Office365-Filtering-HT: Tenant X-MS-TrafficTypeDiagnostic: VE1PR08MB4816:|VE1PR08MB4816:|VI1PR08MB3664: 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: 0187F3EA14 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(366004)(136003)(39860400002)(396003)(376002)(346002)(199004)(189003)(4326008)(2201001)(2171002)(86362001)(2906002)(103116003)(36756003)(6512007)(1076003)(316002)(110136005)(81156014)(81166006)(8936002)(6436002)(54906003)(99286004)(50226002)(305945005)(7736002)(8676002)(3846002)(76176011)(6116002)(5660300002)(52116002)(6486002)(66476007)(6506007)(386003)(66556008)(66446008)(64756008)(14454004)(446003)(186003)(11346002)(14444005)(256004)(26005)(102836004)(71200400001)(2616005)(476003)(486006)(66946007)(55236004)(25786009)(71190400001)(2501003)(66066001)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB4816; 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: dn4tcfyUpPpF4U/YXbMcs75xZEIW+aIPB1vmXTROjeqHPNdrzsvKZ+oQPdMpOAvxZCsFmniQWinA6c5V/sTOAm/Sk76MAK1hQLaWiuo3kPkLZnOgKB6q6ts51HQGqD0hQ//VfVJkP4NHPjizqm/QTNPgKT1fm4C+TuVgM02RbLn+rH4O5ZoN5sruP15J+A4YC9qrfU3iufGxIUG9+ZoVDix8KGcfnKnJ01921vs4HhMfkOVg1CU/oPzyA5GEyywoSx5RNtaDSADhY4rSD8Al9VMlKEwCuIdBjQFd0GlmKSZPKOvFqiMJHxWrMTLT0nwdpwdZzwqS6zj3gdUkBNknnwYXSLgNadGDTHzLb/2N+KB6DW9ZXTsEwqhUKPQyXWrFgOOcJcPTn0WNu0WRZhfSImGpOfPQFWn8AMhk/jcryS4= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4816 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT024.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)(136003)(39860400002)(376002)(346002)(199004)(189003)(76130400001)(6116002)(3846002)(54906003)(6486002)(23756003)(50226002)(103116003)(110136005)(4326008)(99286004)(6512007)(36906005)(70586007)(70206006)(22756006)(316002)(86362001)(25786009)(2171002)(7736002)(305945005)(50466002)(1076003)(14454004)(47776003)(5660300002)(66066001)(81166006)(81156014)(8676002)(8746002)(8936002)(2201001)(356004)(14444005)(2501003)(36756003)(186003)(6506007)(2616005)(126002)(478600001)(76176011)(386003)(336012)(102836004)(486006)(446003)(2906002)(11346002)(26005)(63350400001)(26826003)(476003); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR08MB3664; 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: 2430ebd0-358a-4d8d-7b92-08d74e0e3cc0 NoDisclaimer: True X-Forefront-PRVS: 0187F3EA14 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4aImk91QjUYkiC5v7g/ErnLnt5sg4Sug0mHsFmO37RWDfmBas0knUsDGXmMdwyKEOUIkjRnOgNxIT/2B+ZsThzge5SjWggmaLbVfTRU8wpAjxSHoXG3Mmxs1otpvMZb0qYrDzr5N1WzhHgk9Ed459PYVZDzkIZF5MWVz9S4zrzeVT2qH1Dj3arETfNDCFn6jycuYFPHZaQqgYJ3BzsxQFKWmR5BsNvJniu8U/jZ9IsNKURUJDQD0lCQe3QfuUQjkgb5MQMu3RxoJx+KmHdZsaEL4mONxo5JO8QMrU29BCFBH1YhEdYjU6Vo1iQjKwFgQvqHOymHkkbImE3y+5FmcyUcoMy/g37KlKu+PHbWjrNugG2Oj70d0isaUXt4ytdQZjcIrFYLL2ndc3+9lm6pOmJuYaqv9EGDafETGkF92lCU= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Oct 2019 05:45:47.8193 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 06545c5e-4a04-4235-600f-08d74e0e4456 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: VI1PR08MB3664 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=fUBbQ6jci7ZZBrBwHMNuLpOgBHySGEUsJ89UPIG5ETg=; b=zuW0j5Hx8HGQv59K8T1irjc9S+l+UndyNXCVECA3YSE7+eviUs6qXfYlSlTTfsKbZJ/C9PU1q9LLviHeGjoyhbVGHb2ip0O3EzPf4ckHwkg40uKCCmv+Nmh9gg/iqtU+iwMvG8YzBpwLZvn2oMPrhSK6PIA13lcyDThAyctXF2s= 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=fUBbQ6jci7ZZBrBwHMNuLpOgBHySGEUsJ89UPIG5ETg=; b=zuW0j5Hx8HGQv59K8T1irjc9S+l+UndyNXCVECA3YSE7+eviUs6qXfYlSlTTfsKbZJ/C9PU1q9LLviHeGjoyhbVGHb2ip0O3EzPf4ckHwkg40uKCCmv+Nmh9gg/iqtU+iwMvG8YzBpwLZvn2oMPrhSK6PIA13lcyDThAyctXF2s= 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 Fri Oct 11 05:45:42 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: 11184845 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 F2A8A14ED for ; Fri, 11 Oct 2019 05:46:05 +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 D86D721D71 for ; Fri, 11 Oct 2019 05:46:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D86D721D71 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 37D986EB9B; Fri, 11 Oct 2019 05:46:05 +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-eopbgr10088.outbound.protection.outlook.com [40.107.1.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9C0A96EB9B for ; Fri, 11 Oct 2019 05:46:03 +0000 (UTC) Received: from VI1PR08CA0235.eurprd08.prod.outlook.com (2603:10a6:802:15::44) by AM0PR08MB3698.eurprd08.prod.outlook.com (2603:10a6:208:fe::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.16; Fri, 11 Oct 2019 05:45:59 +0000 Received: from VE1EUR03FT048.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::204) by VI1PR08CA0235.outlook.office365.com (2603:10a6:802:15::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2347.21 via Frontend Transport; Fri, 11 Oct 2019 05:45:59 +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 VE1EUR03FT048.mail.protection.outlook.com (10.152.19.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.15 via Frontend Transport; Fri, 11 Oct 2019 05:45:57 +0000 Received: ("Tessian outbound e4042aced47b:v33"); Fri, 11 Oct 2019 05:45:50 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 506eef3dc52c589c X-CR-MTA-TID: 64aa7808 Received: from f097dae2e33d.2 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.9.57]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 43688E5C-310B-4CF0-A787-3102134EC532.1; Fri, 11 Oct 2019 05:45:45 +0000 Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-ve1eur03lp2057.outbound.protection.outlook.com [104.47.9.57]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f097dae2e33d.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Fri, 11 Oct 2019 05:45:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bIXEn5tMOxD7xWHszFE8c1AWxEP139BVXS7WGlmCSnnS16zvKcn85Cka0roqjRVMyI2vc4lYDTOec9teVCZ+vkAelFRJ+Gh1v49meMLuv/BBlDwFqrviBD0X+IzxQ4wzY8s4ClMyKXruYbcuhfGOz8JJfgbQJ2Noo6mwMcKQ98+9LtJ4rzIx13i2o5gLiJp9FysJkYqKtwcuD8wDs1udaedbSLH8RqvOqa4A0aGjz7vlN2574BgbkCch5yeXEyTmONoIE8oCrbAnfs0m0uB+vIQDG9vrKF0osMInp/rIfQkL/fTSftCZcmE4uVdw7IsqW7HL9ZKd5/IFijVEhp/Epw== 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=GwjboglvKAq6uiIJDn2YUD84pCdj+UuHqWJb/1SqjLc=; b=ZH77U9OW4tFH291JAwI0nBehspeLZ+B+BDwuITpDgfa2O7E97rg7KrpQa6z4PKK5RuLT5Cg2V2oqrC2DdA9r18+sLoPXgxqCKMmQdABZaq42h07or45xuvVOVjX+oTw/8Pl2VuLHyR+tSfnajvzEXpZMNb9/MNauUrywTzEMSQWXPJfMdvM3qgMh8gxWoowPb6dbQOGHuA/pUpM3xhwSmvDiKp3o9+EjThowdhznemGr4xvv2XAarUOkPBZPkwX7B8rYGIz1nbsM3Xp2csXl+HTPnP42BFyF9/5Hz02xY/lVnJTEHkcGIznbQCAQwgZ21JEtsW9HChvCqeSCxmf2Lg== 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 VE1PR08MB4816.eurprd08.prod.outlook.com (10.255.112.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.16; Fri, 11 Oct 2019 05:45:43 +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.021; Fri, 11 Oct 2019 05:45:43 +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 v2 3/4] drm/komeda: Add drm_ctm_to_coeffs() Thread-Topic: [PATCH v2 3/4] drm/komeda: Add drm_ctm_to_coeffs() Thread-Index: AQHVf/ce0iEWJoV9sUaEYo7sUivKyA== Date: Fri, 11 Oct 2019 05:45:42 +0000 Message-ID: <20191011054459.17984-4-james.qian.wang@arm.com> References: <20191011054459.17984-1-james.qian.wang@arm.com> In-Reply-To: <20191011054459.17984-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: HK0PR03CA0011.apcprd03.prod.outlook.com (2603:1096:203:2e::23) 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: 5d097231-747d-4d5e-3cfb-08d74e0e4a50 X-MS-Office365-Filtering-HT: Tenant X-MS-TrafficTypeDiagnostic: VE1PR08MB4816:|VE1PR08MB4816:|AM0PR08MB3698: 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: 0187F3EA14 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(366004)(136003)(39860400002)(396003)(376002)(346002)(199004)(189003)(4326008)(2201001)(2171002)(86362001)(2906002)(103116003)(36756003)(6512007)(1076003)(316002)(110136005)(81156014)(81166006)(8936002)(6436002)(54906003)(99286004)(50226002)(305945005)(7736002)(8676002)(3846002)(76176011)(6116002)(5660300002)(52116002)(6486002)(66476007)(6506007)(386003)(66556008)(66446008)(64756008)(14454004)(446003)(186003)(11346002)(256004)(26005)(102836004)(71200400001)(2616005)(476003)(486006)(66946007)(55236004)(25786009)(71190400001)(2501003)(66066001)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB4816; 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: JR0DUEcS0sIXhKrvgHNsP58qGnxRONqWsfugxS73WR/RVCbu/C4GjTXUEScmSGi4wUYGfyoRxSvT9jTKIhOstSsYLilsM7f2PdggkB9o1yWwWFcD1MxJCyOpHHGQl4XehADC2SPpwQqVIa5E7M2cs8fFr1+oGOd931Tqq6ob0puKiUJTjb9AIZ1zK1i5pOGIH8kUajD48i4PpIypS8/ExdV4rpiaSXk5ptqPsq5ZbWs35pWH2+s5SRe4EBgCMWMjyeNhVqMGU9Z6ggqGMNQklbNGyWUgsaNsfNdT7B7R0Gr4xr/7me5lNcGb9MKwAnL+dkJkbwdzjodyFsVKhQLvmTSYys6mDpStnqsQU1CvyifjaRt8ayM2oXAf6ZZ4FgtChCS4okHEFKCAWkZ/Utc+o7nfv+IwnjoDMExj1lELG9g= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4816 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT048.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; IPV:CAL; SCL:-1; CTRY:IE; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(346002)(376002)(39860400002)(396003)(136003)(189003)(199004)(8746002)(8936002)(25786009)(76176011)(50226002)(99286004)(22756006)(63350400001)(23756003)(26005)(305945005)(70586007)(3846002)(36906005)(316002)(2906002)(47776003)(6116002)(6506007)(386003)(70206006)(81156014)(26826003)(478600001)(81166006)(8676002)(6512007)(102836004)(356004)(76130400001)(186003)(110136005)(50466002)(2171002)(4326008)(103116003)(6486002)(2501003)(36756003)(86362001)(126002)(476003)(2616005)(2201001)(5660300002)(336012)(1076003)(14454004)(54906003)(11346002)(486006)(446003)(7736002)(66066001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR08MB3698; H:64aa7808-outbound-1.mta.getcheckrecipient.com; FPR:; SPF:TempError; LANG:en; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; MX:1; A:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: a58bbe66-d148-4d33-87dc-08d74e0e4116 NoDisclaimer: True X-Forefront-PRVS: 0187F3EA14 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RXf7YnX17wfAJEVGHq50nZoy6QYK9LTP4NKMwv3zvo6Z7rWzo+k+sJyZX+TgUNozVQ7UX5F7GclvugajknEPplr6tn0+UjQQZhK/ITnd6Yrd/qi3ZXGmqzKTr9kZsEjq2wqwoUZP8l/+G58Ub0E8eHNawfGpPXEPhCzuK4fZ/csqq1kWtFwL42U5M029gEHWBayLc7tF0yGXEbYol8rw0L+l/qxUYZ2Gyczk9ZLShhYahh6d+yi4kuKQxmuUL5rLBVqwTuB7RO5fSb9UYN+v0FWO3h0o01Ic9y2Cdf0gHbBalGavzRcKQodG0EzLUu+PGfVt6Qey9Tftxle+bjLO883JSnYf48md1DLJOdppW2XWBY1agVRjMaIdqrmwOPqqs5iR9tvKAVndrKfUCDthMNFjhQXgV+5HCDC0trwILxw= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Oct 2019 05:45:57.8464 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5d097231-747d-4d5e-3cfb-08d74e0e4a50 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: AM0PR08MB3698 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=GwjboglvKAq6uiIJDn2YUD84pCdj+UuHqWJb/1SqjLc=; b=cjD9HM5xZ1L1JIRCvc+Kafj2je7ePdNBHkH3tj70E5euwE+oBAp+5H/f7fXu2dLA+aoYKdpizmSMyV6hX7tL1OC8ulgGqEydoFHGeNCFiklrtd+gH0EsQU2qB6JQQ749NGesJJ8v7bgHEnh97cnx2hakqnvyfRAYyz99vul5M10= 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=GwjboglvKAq6uiIJDn2YUD84pCdj+UuHqWJb/1SqjLc=; b=cjD9HM5xZ1L1JIRCvc+Kafj2je7ePdNBHkH3tj70E5euwE+oBAp+5H/f7fXu2dLA+aoYKdpizmSMyV6hX7tL1OC8ulgGqEydoFHGeNCFiklrtd+gH0EsQU2qB6JQQ749NGesJJ8v7bgHEnh97cnx2hakqnvyfRAYyz99vul5M10= 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 Fri Oct 11 05:45:50 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: 11184847 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 251DB14ED for ; Fri, 11 Oct 2019 05:46: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 08CC921D71 for ; Fri, 11 Oct 2019 05:46:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 08CC921D71 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 4D9156EB9C; Fri, 11 Oct 2019 05:46:13 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0600.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe1e::600]) by gabe.freedesktop.org (Postfix) with ESMTPS id 308B86EB9C for ; Fri, 11 Oct 2019 05:46:11 +0000 (UTC) Received: from VI1PR0802CA0024.eurprd08.prod.outlook.com (2603:10a6:800:aa::34) by DB6SPR00MB245.eurprd08.prod.outlook.com (2603:10a6:4:8e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.16; Fri, 11 Oct 2019 05:46:07 +0000 Received: from VE1EUR03FT062.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::209) by VI1PR0802CA0024.outlook.office365.com (2603:10a6:800:aa::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2347.18 via Frontend Transport; Fri, 11 Oct 2019 05:46:07 +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 VE1EUR03FT062.mail.protection.outlook.com (10.152.18.252) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.15 via Frontend Transport; Fri, 11 Oct 2019 05:46:05 +0000 Received: ("Tessian outbound 0cf06bf5c60e:v33"); Fri, 11 Oct 2019 05:45:57 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: c3e3ec89d654538e X-CR-MTA-TID: 64aa7808 Received: from c5a225462778.2 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.6.56]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id DAF63611-CBC2-4757-98F0-1FDD967470A0.1; Fri, 11 Oct 2019 05:45:52 +0000 Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-ve1eur02lp2056.outbound.protection.outlook.com [104.47.6.56]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id c5a225462778.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 11 Oct 2019 05:45:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CLLoUWN/Dg0zazjSXSt+Y8Zb9dmHpnsIZaM5GOT2cO64KTkAxJMAagXweyQZFzYObWhTDwcmI2/vnecvpR6UnlMCMwAiWzHb1SzvVKKC1tPSut83VkGfXWQSDblAfBU9V+9MXX1dZlqA8AiNUtzvxj3BGBtnIyojNexVGRQDwcogWEaVptRTsVtVx6zX9GdUIx7pgPvfOx6PRopBhaGAGofo+/y9sQ9J5zzbzZgxITVCj23oURtRxTGV2oF7YNpT3AuefPyXPUTDYAbSyG27sa4+KPwYQ3wgQGTIzfFQA00kgOYdOFK8iiDmKW5X0UmPmpyovhSQ+919swy/aLGpCg== 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=FuJdvaLExOfd2N4CZZ8qRY+/1qcem1D6j/mi5OWfSkQ+CD1pYEhggUD42Qt3AC4yqtCACgJAfWS2BhETucpkm9OTVlqa982fMTmZ8xfaDR652tcfNVMdKK7XpeNz/Ip6Him24RgYi4zoX3EzfnLhiIlH2GIWWwRahxN44hSIijChLWvM4Y/emp/uA021JPurdZWSqWXPmOivEFhf3Dd5VnfVZcug0bPZnPOlZrbB7hV3ATBhzg26O5os1z4Ua6mGUcdM1Ve4n6rIrbi8jvphfE/C6hdHg4d+d1Zwa1CaN9bKqR5WTlCSStLsKfVG8de1h53m6jEmDCf/AbFzRHRqJg== 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 VE1PR08MB5262.eurprd08.prod.outlook.com (20.179.31.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.16; Fri, 11 Oct 2019 05:45:50 +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.021; Fri, 11 Oct 2019 05:45:50 +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 v2 4/4] drm/komeda: Adds gamma and color-transform support for DOU-IPS Thread-Topic: [PATCH v2 4/4] drm/komeda: Adds gamma and color-transform support for DOU-IPS Thread-Index: AQHVf/cjoruYXL2LUkqKp6fLHl28hQ== Date: Fri, 11 Oct 2019 05:45:50 +0000 Message-ID: <20191011054459.17984-5-james.qian.wang@arm.com> References: <20191011054459.17984-1-james.qian.wang@arm.com> In-Reply-To: <20191011054459.17984-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: HK0PR03CA0011.apcprd03.prod.outlook.com (2603:1096:203:2e::23) 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: 3c6efd1e-374d-42fa-994c-08d74e0e4ef3 X-MS-Office365-Filtering-HT: Tenant X-MS-TrafficTypeDiagnostic: VE1PR08MB5262:|VE1PR08MB5262:|DB6SPR00MB245: 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: 0187F3EA14 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(136003)(39860400002)(366004)(396003)(346002)(376002)(199004)(189003)(14454004)(3846002)(81156014)(110136005)(54906003)(76176011)(52116002)(36756003)(2616005)(6116002)(11346002)(476003)(446003)(2201001)(25786009)(50226002)(99286004)(1076003)(8936002)(66066001)(81166006)(386003)(26005)(6506007)(102836004)(8676002)(316002)(4326008)(186003)(55236004)(5660300002)(305945005)(66476007)(66556008)(2501003)(2171002)(64756008)(66446008)(86362001)(6486002)(14444005)(7736002)(2906002)(103116003)(71200400001)(71190400001)(6436002)(66946007)(486006)(6512007)(478600001)(256004); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB5262; 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: JFAYJfltCER9MYs+nOxvEz2zdcKGLouxXg6W74MpKFgsIgM5jxRmb9ZnQerHYjCJsLUuZf6tc4yxeNcaaLEwkZxxGkRutOGlg/jwZgLVnyJ5suH73M1+qWs58a6QOS6zC0dLTexUZwEs5KxQIMtnO8n5cj5VE+my/ghTiGvvaLTcztlQkjiLaTaBvKISbqxFPUW2IUEj7IWjLFQ1iVxABj9MdcwcbIWfw0FdZwFIVH0oXRpwVEgx/zD8wd4sWJz0n3/c6j4EGlMttbLyy29DitXyKQdu5hQlQbC14vRsZwOqNSG30bMxkAbPqAmheYazIp9pjtGRkwAn7lDrJOUhbD8HTBc8UU348Nv3FWKBHrf+rUaSEnZX3Y1HN1l9GGNQGHsNHgam7P/iBwZuZM7kWTXAWjITU5NmVM00UP6nz1w= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5262 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT062.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)(189003)(199004)(2201001)(23756003)(26826003)(478600001)(2501003)(66066001)(5660300002)(22756006)(486006)(36756003)(1076003)(2906002)(7736002)(305945005)(3846002)(6116002)(356004)(36906005)(8676002)(110136005)(316002)(14444005)(4326008)(81166006)(54906003)(81156014)(2616005)(26005)(386003)(99286004)(6506007)(63350400001)(476003)(103116003)(102836004)(2171002)(126002)(76176011)(25786009)(8936002)(6486002)(8746002)(11346002)(14454004)(336012)(446003)(70586007)(70206006)(6512007)(76130400001)(47776003)(50226002)(86362001)(186003)(50466002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6SPR00MB245; H:64aa7808-outbound-1.mta.getcheckrecipient.com; FPR:; SPF:TempError; LANG:en; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; MX:1; A:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: e65bf5b8-88f2-4062-fbd9-08d74e0e4572 NoDisclaimer: True X-Forefront-PRVS: 0187F3EA14 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TZX5fBqo70TecSwfzzl+is55jGTfeciC0HFREtbHsskR4BXn+UeaX7vEnnq9cfN/FvCLL/lC0K3nq+qJJvAh83uBLXIhi1BE2U5OpYYrXvxMkxSIQMfcBX4SFjMgJ+zjzy8KeNslN4300H8hy8CFYOgHEWhRM2mp9N8LpEo2GpHl2htVcbYoiKhWLp12sc+RH3QzeFQziWDknAaIz/UFBEB+a60aA3rhQZnrJYPR6Lhy1Bxal0hXkUIAzUxH5a+AfOqEiNEjX6UPdMLqlbwWVm5knO0dMGuRr24pkFY+selHJB+WtRqJacYK91rXhRdOJ80g2Dg4fvlDEYFM2o1WTggVwddX0UCjbeDpQ4ecTTntIhKrzzhINdYOc0Bbsy/rooW57ij1u40dyKd+MAf0xbstF7/5TUy6BxR3Swrt24w= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Oct 2019 05:46:05.6259 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3c6efd1e-374d-42fa-994c-08d74e0e4ef3 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: DB6SPR00MB245 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=ZWvf4MmuGN72hP4mmwV/VrCiLkamrDatG4jOGGCYg3+1DWSa55DHdkXjWXBO5Lf1U6WEEk/OBQvD+HzI7M3i+uZM0F52gq406RfecpLZtVejF4jPPEv/Af4vDh7TezCEzCT9v/U5pogJm+b/GUMPCFPrGGvPVFk/6hkp5iQAGJw= 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=ZWvf4MmuGN72hP4mmwV/VrCiLkamrDatG4jOGGCYg3+1DWSa55DHdkXjWXBO5Lf1U6WEEk/OBQvD+HzI7M3i+uZM0F52gq406RfecpLZtVejF4jPPEv/Af4vDh7TezCEzCT9v/U5pogJm+b/GUMPCFPrGGvPVFk/6hkp5iQAGJw= 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);