From patchwork Tue Aug 13 04:56:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Qian Wang X-Patchwork-Id: 11091109 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8D56E746 for ; Tue, 13 Aug 2019 04:56:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7CB7128334 for ; Tue, 13 Aug 2019 04:56:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F38728409; Tue, 13 Aug 2019 04:56:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CF61828334 for ; Tue, 13 Aug 2019 04:56:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 140C66E630; Tue, 13 Aug 2019 04:56:22 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30083.outbound.protection.outlook.com [40.107.3.83]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7B8456E630 for ; Tue, 13 Aug 2019 04:56:20 +0000 (UTC) Received: from VI1PR08CA0230.eurprd08.prod.outlook.com (2603:10a6:802:15::39) by VE1PR08MB4957.eurprd08.prod.outlook.com (2603:10a6:803:110::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.18; Tue, 13 Aug 2019 04:56:16 +0000 Received: from VE1EUR03FT020.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::200) by VI1PR08CA0230.outlook.office365.com (2603:10a6:802:15::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2157.16 via Frontend Transport; Tue, 13 Aug 2019 04:56:16 +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 VE1EUR03FT020.mail.protection.outlook.com (10.152.18.242) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2052.18 via Frontend Transport; Tue, 13 Aug 2019 04:56:15 +0000 Received: ("Tessian outbound 40a263b748b4:v26"); Tue, 13 Aug 2019 04:56:09 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: de0535b376d47595 X-CR-MTA-TID: 64aa7808 Received: from 5a9e516d9020.2 (cr-mta-lb-1.cr-mta-net [104.47.2.58]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 3CA80F2B-4F52-4659-A844-F0FD2A629A0F.1; Tue, 13 Aug 2019 04:56:04 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01lp2058.outbound.protection.outlook.com [104.47.2.58]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 5a9e516d9020.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Tue, 13 Aug 2019 04:56:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d2B6ebQP4uaP/RMjLLCVGEhpPODhPQZoYUPe5m5PDporzWepuOJkB1aWZtxfVIjS3aoTEPe5bxhkEhohm5zWPTeiNUfjsDnMnwgw1sHlODIeEBr0lfCgi6VCXHzk9knlSJ7QOmNSh+rmTelPV9x/mdjb3yRcl6eREkgUEDZq/VGAExGJEr1tC8C4JQW0Hy/7LBUUpg12KkzHZY+OAfgkwrkIFOHR8H85JeCb11mQuOYdEH9afEXrJdEEz5FhaRK2Z4CiDkJHDmft0TYO6UdpCjxKN4djMJg3Xetm3QGNFbRAUhO2xEwHDZcy3prPT6jUwcbkOeUKXdT1/ivn/NOUzQ== 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=nuGciigGkwP439dkP0n3XwvBbunHid96eGr9XRrL5Jw=; b=T2GsNnUxSbK7/cBCzrm65pSPL0SCEISVNYr9xNd5VxdbwakiVej9sBKc9F4lI+KEYiEVtlEE0Gfew3iuGQH8wZ2gwZ97x3O7Y0QqWno68gcD2Tvl3pohgyN6OKdT2w5FD3Vs/az7q7VN9HQDzD4Kol6EBzIP+MNPwBII3KaWTqORNWQKp3L8brJwvMmeQmBnoXcNZ3XFvrUPU4/vrNEdU+zTmCHQ7UMMsgdxgAHnR5vHwk1/m3bPrcPZ/6BYfz8okxLTVPoTNbLSnLwNkbPTXNcmeXJL7THrd3eTkhN1esCXamvk63QsJ8zhuOpOv7vUvri/UgcoeieUtYMfOCCTzA== 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 VE1PR08MB4752.eurprd08.prod.outlook.com (10.255.112.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.15; Tue, 13 Aug 2019 04:56:02 +0000 Received: from VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::2151:f0b1:3ea7:c134]) by VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::2151:f0b1:3ea7:c134%6]) with mapi id 15.20.2157.022; Tue, 13 Aug 2019 04:56:01 +0000 From: "james qian wang (Arm Technology China)" To: Liviu Dudau , "airlied@linux.ie" , Brian Starkey , "maarten.lankhorst@linux.intel.com" , "sean@poorly.run" Subject: [PATCH v2 1/4] drm/komeda: Introduce komeda_coeffs_table/manager Thread-Topic: [PATCH v2 1/4] drm/komeda: Introduce komeda_coeffs_table/manager Thread-Index: AQHVUZNn0XyAilFXnEawB/L5bqoU/A== Date: Tue, 13 Aug 2019 04:56:01 +0000 Message-ID: <20190813045536.28239-2-james.qian.wang@arm.com> References: <20190813045536.28239-1-james.qian.wang@arm.com> In-Reply-To: <20190813045536.28239-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: HK0PR01CA0070.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::34) 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: a4e163dd-5d1e-466b-5298-08d71faa923b X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam-Untrusted: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:VE1PR08MB4752; X-MS-TrafficTypeDiagnostic: VE1PR08MB4752:|VE1PR08MB4957: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:3968;OLM:3968; x-forefront-prvs: 01283822F8 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(979002)(4636009)(136003)(376002)(39860400002)(366004)(346002)(396003)(199004)(189003)(50226002)(5660300002)(2201001)(110136005)(26005)(316002)(66066001)(6116002)(3846002)(305945005)(2906002)(7736002)(103116003)(71190400001)(71200400001)(8676002)(1076003)(54906003)(446003)(55236004)(66946007)(478600001)(81156014)(14454004)(386003)(6506007)(4326008)(36756003)(52116002)(2616005)(102836004)(25786009)(256004)(11346002)(14444005)(81166006)(186003)(76176011)(6486002)(64756008)(66556008)(66476007)(99286004)(2501003)(6512007)(6436002)(86362001)(66446008)(8936002)(486006)(476003)(53936002)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB4752; 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-Message-Info-Original: LoQbVzAb6R/gLMANugwmN1ykWg7l4Yebc6tgWNiiiczZ7ygFlBsvuBy9hHOpZx0kk7Ep64h5I6ELE9WWDzkUXJWWiqLj2ovLJ35eqAWfWFP22t2DJ13IJ5R1NH2QwqMTfgjtY17460JoGmox0qjfX/kSE8e1/ptOQ5paGJmlYqwX0RI/XaWzlj4IXzj62eFEeYyMui+i3+cm5SodCtRcZWyW8hqpPNuhP7G1Sftzz2UP0ZSBJfFdQ2/f8AHIJgKQqyvnpiQdCLtKpND3uzwkgTKURZ94McHCXLrJzftB9KC1ntJ4i/TsNgtVLB7pGbqEIbqDU9vpTywXEgVXD2MiEUpVEtWkJN61e/n8y83egbMmrbBwTKZ0WBOzwonvBW2cxJQJk5NrxCQetSSjqIz4VtT0lJefVIolpTpeq4PbA1s= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4752 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT020.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; IPV:CAL; SCL:-1; CTRY:IE; EFV:NLI; SFV:NSPM; SFS:(10009020)(979002)(4636009)(376002)(346002)(136003)(396003)(39860400002)(2980300002)(199004)(189003)(47776003)(110136005)(99286004)(486006)(76130400001)(1076003)(36756003)(76176011)(2501003)(25786009)(5660300002)(63350400001)(63370400001)(336012)(2616005)(70206006)(476003)(70586007)(11346002)(54906003)(126002)(446003)(81166006)(8676002)(81156014)(103116003)(8746002)(66066001)(6512007)(6486002)(8936002)(4326008)(356004)(316002)(6116002)(305945005)(26005)(186003)(50226002)(3846002)(50466002)(14454004)(7736002)(6506007)(86362001)(26826003)(102836004)(36906005)(478600001)(23756003)(14444005)(22756006)(2201001)(386003)(2906002)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB4957; 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: 683bd389-c07b-44cf-c8dd-08d71faa89ef X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(710020)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:VE1PR08MB4957; NoDisclaimer: True X-Forefront-PRVS: 01283822F8 X-Microsoft-Antispam-Message-Info: QcOHbfAL6GLr2q/6VeBPyzSGHFxKjJpzcx2huEY/SngIoY2GNGO2nHjQLK1lTBw5XgGDS1hc65G1rFsr06iGvfslt41KcZMQTVxjvkVHs1/X/a5uWE33h5UCyVVoF/gGSPjF+xVjMWrC1CNB8C6mNyRyh4go5l2DFDYrxaiEElQl6rjuSWnlCUyEHDJsDbSIQcxHNp1pXgQkd1z69xuiK6QkpR+aiqOAzckAhyrZZ90m5XdNsWzSEpBW1bxpD2yprgElhG5GKAHzI0Xy7LP/vgAy4Udf//FKiiql8oIhhnkuyfQXZyX1NBSEmrLZTSN5z380yYYPMETAFRo6TDVQutRX4UJvs6zutWR0pJ2m8kDIPp0gecS+mdr8L5ZY61Lzj3riUNrrju+3r2Tv5cuWmI06XtpREMnh8EePDtOewLY= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2019 04:56:15.2835 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a4e163dd-5d1e-466b-5298-08d71faa923b 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: VE1PR08MB4957 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=nuGciigGkwP439dkP0n3XwvBbunHid96eGr9XRrL5Jw=; b=JtpkwfinRXAjAP6UHPNk9EaKCUbrtWWMgHZAu12NxpaeTPfYsJ+FJm/oAF9bFyBy02PzLxLKeR4c+aYCd9255wwQRvagT7M7JojyiJcqb3f11FRiCZTSdQVdYsvb5kbbO6cV5jNjjhMJvwv3NQY+q/Rn/UgglTvUFhIdc0Z7dgI= 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=nuGciigGkwP439dkP0n3XwvBbunHid96eGr9XRrL5Jw=; b=JtpkwfinRXAjAP6UHPNk9EaKCUbrtWWMgHZAu12NxpaeTPfYsJ+FJm/oAF9bFyBy02PzLxLKeR4c+aYCd9255wwQRvagT7M7JojyiJcqb3f11FRiCZTSdQVdYsvb5kbbO6cV5jNjjhMJvwv3NQY+q/Rn/UgglTvUFhIdc0Z7dgI= 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=temperror 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" X-Virus-Scanned: ClamAV using ClamSMTP komeda display HWs have kinds of coefficient tables for various purposes like gamma/degamma. ususally these tables are shared by multiple HW component and have limited number. Introduce komeda_coeffs_table/manager for describing and managing these tables, like table reuse, racing. Signed-off-by: James Qian Wang (Arm Technology China) --- drivers/gpu/drm/arm/display/komeda/Makefile | 1 + .../drm/arm/display/komeda/komeda_coeffs.c | 119 ++++++++++++++++++ .../drm/arm/display/komeda/komeda_coeffs.h | 74 +++++++++++ 3 files changed, 194 insertions(+) create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_coeffs.c create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_coeffs.h diff --git a/drivers/gpu/drm/arm/display/komeda/Makefile b/drivers/gpu/drm/arm/display/komeda/Makefile index 5c3900c2e764..38aa5843c03a 100644 --- a/drivers/gpu/drm/arm/display/komeda/Makefile +++ b/drivers/gpu/drm/arm/display/komeda/Makefile @@ -8,6 +8,7 @@ komeda-y := \ komeda_drv.o \ komeda_dev.o \ komeda_format_caps.o \ + komeda_coeffs.o \ komeda_color_mgmt.o \ komeda_pipeline.o \ komeda_pipeline_state.o \ diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_coeffs.c b/drivers/gpu/drm/arm/display/komeda/komeda_coeffs.c new file mode 100644 index 000000000000..d9d35e23003c --- /dev/null +++ b/drivers/gpu/drm/arm/display/komeda/komeda_coeffs.c @@ -0,0 +1,119 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * (C) COPYRIGHT 2019 ARM Limited. All rights reserved. + * Author: James.Qian.Wang + * + */ +#include +#include "komeda_coeffs.h" + +static inline bool is_table_in_using(struct komeda_coeffs_table *table) +{ + return refcount_read(&table->refcount) > 1; +} + +/* request a coeffs table for the coeffs data specified by argument coeffs */ +struct komeda_coeffs_table * +komeda_coeffs_request(struct komeda_coeffs_manager *mgr, void *coeffs) +{ + struct komeda_coeffs_table *table; + u32 i; + + mutex_lock(&mgr->mutex); + + /* search table list to find if there is a in-using table with the + * same coefficient content, if find, reuse this table. + */ + for (i = 0; i < mgr->n_tables; i++) { + table = mgr->tables[i]; + + /* skip the unused table */ + if (!is_table_in_using(table)) + continue; + + if (!memcmp(table->coeffs, coeffs, mgr->coeffs_sz)) + goto found; + } + + /* can not reuse the existing in-using table, loop for a new one */ + for (i = 0; i < mgr->n_tables; i++) { + table = mgr->tables[i]; + + if (!is_table_in_using(table)) { + memcpy(table->coeffs, coeffs, mgr->coeffs_sz); + table->needs_update = true; + goto found; + } + } + + /* Since previous two search loop will directly goto found if found an + * available table, so once program ran here means search failed. + * clear the table to NULL, unlock(mgr->mutex) and return NULL. + */ + table = NULL; + +found: + komeda_coeffs_get(table); + mutex_unlock(&mgr->mutex); + return table; +} + +/* Add a coeffs table to manager */ +int komeda_coeffs_add(struct komeda_coeffs_manager *mgr, + u32 hw_id, u32 __iomem *reg, + void (*update)(struct komeda_coeffs_table *table)) +{ + struct komeda_coeffs_table *table; + + if (mgr->n_tables >= ARRAY_SIZE(mgr->tables)) + return -ENOSPC; + + table = kzalloc(sizeof(*table), GFP_KERNEL); + if (!table) + return -ENOMEM; + + table->coeffs = kzalloc(mgr->coeffs_sz, GFP_KERNEL); + if (!table->coeffs) { + kfree(table); + return -ENOMEM; + } + + refcount_set(&table->refcount, 1); + table->mgr = mgr; + table->hw_id = hw_id; + table->update = update; + table->reg = reg; + + mgr->tables[mgr->n_tables++] = table; + return 0; +} + +struct komeda_coeffs_manager *komeda_coeffs_create_manager(u32 coeffs_sz) +{ + struct komeda_coeffs_manager *mgr; + + mgr = kzalloc(sizeof(*mgr), GFP_KERNEL); + if (!mgr) + return ERR_PTR(-ENOMEM); + + mutex_init(&mgr->mutex); + mgr->coeffs_sz = coeffs_sz; + + return mgr; +} + +void komeda_coeffs_destroy_manager(struct komeda_coeffs_manager *mgr) +{ + u32 i; + + if (!mgr) + return; + + for (i = 0; i < mgr->n_tables; i++) { + WARN_ON(is_table_in_using(mgr->tables[i])); + kfree(mgr->tables[i]->coeffs); + kfree(mgr->tables[i]); + } + + kfree(mgr); +} diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_coeffs.h b/drivers/gpu/drm/arm/display/komeda/komeda_coeffs.h new file mode 100644 index 000000000000..172ac2ea17ba --- /dev/null +++ b/drivers/gpu/drm/arm/display/komeda/komeda_coeffs.h @@ -0,0 +1,74 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * (C) COPYRIGHT 2019 ARM Limited. All rights reserved. + * Author: James.Qian.Wang + * + */ +#ifndef _KOMEDA_COEFFS_H_ +#define _KOMEDA_COEFFS_H_ + +#include + +/* Komeda display HWs have kinds of coefficient tables for various purposes, + * like gamma/degamma. ususally these tables are shared by multiple HW component + * and limited number. + * The komeda_coeffs_table/manager are imported for describing and managing + * these tables for table reuse and racing. + */ +struct komeda_coeffs_table { + struct komeda_coeffs_manager *mgr; + refcount_t refcount; + bool needs_update; + u32 hw_id; + void *coeffs; + u32 __iomem *reg; + void (*update)(struct komeda_coeffs_table *table); +}; + +struct komeda_coeffs_manager { + struct mutex mutex; /* for tables accessing */ + u32 n_tables; + u32 coeffs_sz; + struct komeda_coeffs_table *tables[8]; +}; + +static inline struct komeda_coeffs_table * +komeda_coeffs_get(struct komeda_coeffs_table *table) +{ + if (table) + refcount_inc(&table->refcount); + + return table; +} + +static inline void __komeda_coeffs_put(struct komeda_coeffs_table *table) +{ + if (table) + refcount_dec(&table->refcount); +} + +#define komeda_coeffs_put(table) \ +do { \ + __komeda_coeffs_put(table); \ + (table) = NULL; \ +} while (0) + +static inline void komeda_coeffs_update(struct komeda_coeffs_table *table) +{ + if (!table || !table->needs_update) + return; + + table->update(table); + table->needs_update = false; +} + +struct komeda_coeffs_manager *komeda_coeffs_create_manager(u32 coeffs_sz); +void komeda_coeffs_destroy_manager(struct komeda_coeffs_manager *mgr); + +int komeda_coeffs_add(struct komeda_coeffs_manager *mgr, + u32 hw_id, u32 __iomem *reg, + void (*update)(struct komeda_coeffs_table *table)); +struct komeda_coeffs_table * +komeda_coeffs_request(struct komeda_coeffs_manager *mgr, void *coeffs); + +#endif /*_KOMEDA_COEFFS_H_*/ From patchwork Tue Aug 13 04:56:07 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: 11091111 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED7E614DB for ; Tue, 13 Aug 2019 04:56:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE6D428334 for ; Tue, 13 Aug 2019 04:56:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1D4628409; Tue, 13 Aug 2019 04:56:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 48FCB28334 for ; Tue, 13 Aug 2019 04:56:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5A0BF6E632; Tue, 13 Aug 2019 04:56:25 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30069.outbound.protection.outlook.com [40.107.3.69]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9A2A16E632 for ; Tue, 13 Aug 2019 04:56:23 +0000 (UTC) Received: from VI1PR08CA0133.eurprd08.prod.outlook.com (10.175.229.11) by VE1PR08MB4958.eurprd08.prod.outlook.com (10.255.158.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.16; Tue, 13 Aug 2019 04:56:19 +0000 Received: from VE1EUR03FT015.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::200) by VI1PR08CA0133.outlook.office365.com (2603:10a6:800:d5::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2157.13 via Frontend Transport; Tue, 13 Aug 2019 04:56:19 +0000 Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT015.mail.protection.outlook.com (10.152.18.176) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2052.18 via Frontend Transport; Tue, 13 Aug 2019 04:56:17 +0000 Received: ("Tessian outbound 220137ab7b0b:v26"); Tue, 13 Aug 2019 04:56:15 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 5a4466e494ac27c0 X-CR-MTA-TID: 64aa7808 Received: from 48d282c98ec2.2 (cr-mta-lb-1.cr-mta-net [104.47.2.52]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 3EA0245D-8345-4038-BA22-129FD4567396.1; Tue, 13 Aug 2019 04:56:10 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01lp2052.outbound.protection.outlook.com [104.47.2.52]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 48d282c98ec2.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Tue, 13 Aug 2019 04:56:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eodcI3b4cbg8foLpxrxIw4vzu6Xnt+gtPnTetX8YBVwRgO3BWbKO9jRZnl0uNB8BuFnhmOdGfqYNga+1kb7vE0m/6oQMOh/ckTulFV330kplrEnj/+RH680e37eXNDSxs4hqfkJ3DBSS8eTuyibg5psoWcjMMJI0dfjcR1bIrIGHImiGWSctyKqXEnwiL6XU4kUvwR3Z1edjFlssdJu2jEWlqArxQLPwe8pLUyJkympqMwB/hQrT6syt/7KB8JINLNBXn/d4AF26VL9NuF6V2a1NjdyeTleBQ/RahMbjbTpQ3JoubkyQS0Cs2kGlZKyxVluaypLdhBwcG2TXgUXfAQ== 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=Lht/FXnDUDdG/2htzFfQqSr71W++svRRJXgUnujKmXo=; b=ZP0XO+xqGF7wjwIdMEgTddKNI/rFv7VTv8R362eaF4bD+9hVjQCReE5/VMXM553WB/2EUsnEjDS7XOo1GBYJNsZg+1LBaF78lswed4R4MT6Ydo533FO29EouiiRLAh4HjKhKlGWbwQjxnIcfjxZBJZ6/k3UIF0nnpQ24sn8aQuRipSd+vH0T1lLSfyx+2IKV57b4XKd38t//EzJvlOynk+v67DCb6iCYqKuZiwT+IfS4SNJP9a2ADarEceqTmo0Klt7I4cRZcsAujdMzt1xXn27x9bt7j4+1lepFM2+Imx1isZIGwMac+hE7f7fVRCBRTXGKpzLQ17ZJUCcnkV6ulQ== 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 VE1PR08MB4752.eurprd08.prod.outlook.com (10.255.112.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.15; Tue, 13 Aug 2019 04:56:07 +0000 Received: from VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::2151:f0b1:3ea7:c134]) by VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::2151:f0b1:3ea7:c134%6]) with mapi id 15.20.2157.022; Tue, 13 Aug 2019 04:56:07 +0000 From: "james qian wang (Arm Technology China)" To: Liviu Dudau , "airlied@linux.ie" , Brian Starkey , "maarten.lankhorst@linux.intel.com" , "sean@poorly.run" Subject: [PATCH v2 2/4] drm/komeda: Introduce komeda_color_manager/state Thread-Topic: [PATCH v2 2/4] drm/komeda: Introduce komeda_color_manager/state Thread-Index: AQHVUZNrgGWWre2e4Eyh5LBkmfNYaA== Date: Tue, 13 Aug 2019 04:56:07 +0000 Message-ID: <20190813045536.28239-3-james.qian.wang@arm.com> References: <20190813045536.28239-1-james.qian.wang@arm.com> In-Reply-To: <20190813045536.28239-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: HK0PR01CA0070.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::34) 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: d12a69de-2b87-42d4-a5fc-08d71faa93ad X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam-Untrusted: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:VE1PR08MB4752; X-MS-TrafficTypeDiagnostic: VE1PR08MB4752:|VE1PR08MB4958: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:3276;OLM:3276; x-forefront-prvs: 01283822F8 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(136003)(376002)(39860400002)(366004)(346002)(396003)(199004)(189003)(50226002)(5660300002)(2201001)(110136005)(26005)(316002)(66066001)(6116002)(3846002)(305945005)(2906002)(7736002)(103116003)(71190400001)(71200400001)(8676002)(1076003)(54906003)(446003)(55236004)(66946007)(478600001)(81156014)(14454004)(386003)(6506007)(4326008)(36756003)(52116002)(2616005)(102836004)(25786009)(256004)(11346002)(14444005)(81166006)(186003)(76176011)(6486002)(64756008)(66556008)(66476007)(99286004)(2501003)(6512007)(6436002)(86362001)(66446008)(8936002)(486006)(476003)(53936002); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB4752; 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-Message-Info-Original: 2gpb+2vaeXz6XazK4aNvYeXepjiL48SMVgwale7OvV6sP6itJz8pJSWjhgwA0iaqC21MnEmciDnkvU10wj4EZIJEudFNAfldzIoyww90TxW4XAdl/I3KMI4RzfBOhMk1Hx3XdVeOAEmjnmrUY5EW0D6cB5gQFi4qoL3f9Nz+ve/9b9Rc47VhrlWiW18NRHGSN9r+LEB/vdlRz3s7GtwiF/rzHVbp7JCw27H6Fi9EosieMsLytUkjNMCy+bsfEEW1AlZXTimNOkqrYtQzuFqm+qshr8IrRGvuQEo2utbSdd5LZiApG/SNWD3K9I9N/7Ag0fPKMWldih4/m5r90H41sRvPfCYZkhD4RRj4w9Scet3FvV0T4BJJWqrLVf+dW/GBPnIhv/Za+kBOU15mRZRBSItsHdR+jn6wS1EK64vCb3I= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4752 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT015.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)(376002)(136003)(39860400002)(346002)(2980300002)(189003)(199004)(50226002)(81156014)(8746002)(5660300002)(26005)(36756003)(36906005)(102836004)(6486002)(8936002)(76176011)(6506007)(316002)(14444005)(386003)(54906003)(2616005)(476003)(336012)(81166006)(110136005)(47776003)(63350400001)(63370400001)(11346002)(446003)(66066001)(486006)(103116003)(76130400001)(70586007)(126002)(50466002)(1076003)(2201001)(22756006)(70206006)(6512007)(25786009)(4326008)(86362001)(14454004)(478600001)(26826003)(23756003)(7736002)(186003)(305945005)(8676002)(99286004)(6116002)(2906002)(3846002)(356004)(2501003); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB4958; 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: 7f5b7130-b506-43d4-376a-08d71faa8d6c X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(710020)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:VE1PR08MB4958; NoDisclaimer: True X-Forefront-PRVS: 01283822F8 X-Microsoft-Antispam-Message-Info: NMhEabwKgi2YRrd4RnyDycTGE7Ml6PL9sY5K9BpbaMsRWvCBCjXnMC3+j1JP7ymgAlfQROX9rEK1QtBuxb6n3ELQGW9EUMcK4vUHz4QNv8EKU/0i8x9KIFB2L6HZPDO94oOSSpK+FDaKWWrCHRhyAkU4XYuN6WG4AUDwlQlpvdXhHV27QDqLOp4GReVAOaxRZ1gfInLDdHCIPELQwe3WDHJcVm7Nw1dB1jzssbDVPbiSLjU/HfNF6FT6bUaU/gPvY2vVTXHodyEq2GaRRWz2TxV+VC17M6RtrpEeH/DSQJN9mxzIhvtnJnA820Ovc3R+oJvfl2spN/uHicvaTNXmwd3TeR7rTG4gPzw2IC1VZzNE/aNcBfs28F0evmFbG/Vg7axl69fKpehMllj7HO0wnFMFLz3ylK1WGo0IDryUJF0= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2019 04:56:17.7425 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d12a69de-2b87-42d4-a5fc-08d71faa93ad 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: VE1PR08MB4958 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=Lht/FXnDUDdG/2htzFfQqSr71W++svRRJXgUnujKmXo=; b=68So3K9Z+gsyBSknXWc6z95iWaDo6fRYF0JVcEjN31Zu4OBo5deEHaaicxwJRavKsHc6MBIV3yRu30RrqoBypyKKIsUECaNLjNQUpxttpDpNrTCY4PNEnWBHiLptkbEp6Hm0gp2OgmDO3e/JBfAhHtcEBdrN3eTKYgvZ8cMPM7g= 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=Lht/FXnDUDdG/2htzFfQqSr71W++svRRJXgUnujKmXo=; b=68So3K9Z+gsyBSknXWc6z95iWaDo6fRYF0JVcEjN31Zu4OBo5deEHaaicxwJRavKsHc6MBIV3yRu30RrqoBypyKKIsUECaNLjNQUpxttpDpNrTCY4PNEnWBHiLptkbEp6Hm0gp2OgmDO3e/JBfAhHtcEBdrN3eTKYgvZ8cMPM7g= 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=temperror 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" X-Virus-Scanned: ClamAV using ClamSMTP Many komeda component support color management like layer and IPS, so komeda_color_manager/state are introduced to manager gamma, csc and degamma together for easily share it to multiple componpent. And for komeda_color_manager which: - convert drm 3d gamma lut to komeda specific gamma coeffs - gamma table management and hide the HW difference for komeda-CORE Signed-off-by: James Qian Wang (Arm Technology China) Reviewed-by: Mihail Atanassov --- .../arm/display/komeda/komeda_color_mgmt.c | 126 ++++++++++++++++++ .../arm/display/komeda/komeda_color_mgmt.h | 32 ++++- 2 files changed, 156 insertions(+), 2 deletions(-) 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..bf2388d641b9 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c @@ -4,7 +4,9 @@ * Author: James.Qian.Wang * */ +#include +#include "malidp_utils.h" #include "komeda_color_mgmt.h" /* 10bit precision YUV2RGB matrix */ @@ -65,3 +67,127 @@ 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 struct gamma_curve_sector igamma_sector_tbl[] = { + {0, 64, 64}, +}; + +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_igamma_coeffs(struct drm_property_blob *lut_blob, u32 *coeffs) +{ + drm_lut_to_coeffs(lut_blob, coeffs, + igamma_sector_tbl, ARRAY_SIZE(igamma_sector_tbl)); +} + +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) { + /* Convert from S31.32 to Q3.12. */ + s64 v = ctm->matrix[i]; + + coeffs[i] = clamp_val(v, 1 - (1LL << 34), (1LL << 34) - 1) >> 20; + } +} + +void komeda_color_duplicate_state(struct komeda_color_state *new, + struct komeda_color_state *old) +{ + new->igamma = komeda_coeffs_get(old->igamma); + new->fgamma = komeda_coeffs_get(old->fgamma); +} + +void komeda_color_cleanup_state(struct komeda_color_state *color_st) +{ + komeda_coeffs_put(color_st->igamma); + komeda_coeffs_put(color_st->fgamma); +} + +int komeda_color_validate(struct komeda_color_manager *mgr, + struct komeda_color_state *st, + struct drm_property_blob *igamma_blob, + struct drm_property_blob *fgamma_blob) +{ + u32 coeffs[KOMEDA_N_GAMMA_COEFFS]; + + komeda_color_cleanup_state(st); + + if (igamma_blob) { + drm_lut_to_igamma_coeffs(igamma_blob, coeffs); + st->igamma = komeda_coeffs_request(mgr->igamma_mgr, coeffs); + if (!st->igamma) { + DRM_DEBUG_ATOMIC("request igamma table failed.\n"); + return -EBUSY; + } + } + + if (fgamma_blob) { + drm_lut_to_fgamma_coeffs(fgamma_blob, coeffs); + st->fgamma = komeda_coeffs_request(mgr->fgamma_mgr, coeffs); + if (!st->fgamma) { + DRM_DEBUG_ATOMIC("request fgamma table failed.\n"); + return -EBUSY; + } + } + + return 0; +} 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..41a96b3b540f 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h +++ b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h @@ -4,14 +4,42 @@ * Author: James.Qian.Wang * */ - #ifndef _KOMEDA_COLOR_MGMT_H_ #define _KOMEDA_COLOR_MGMT_H_ #include +#include "komeda_coeffs.h" #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 + +struct komeda_color_manager { + struct komeda_coeffs_manager *igamma_mgr; + struct komeda_coeffs_manager *fgamma_mgr; + bool has_ctm; +}; + +struct komeda_color_state { + struct komeda_coeffs_table *igamma; + struct komeda_coeffs_table *fgamma; +}; + +void komeda_color_duplicate_state(struct komeda_color_state *new, + struct komeda_color_state *old); +void komeda_color_cleanup_state(struct komeda_color_state *color_st); +int komeda_color_validate(struct komeda_color_manager *mgr, + struct komeda_color_state *st, + struct drm_property_blob *igamma_blob, + struct drm_property_blob *fgamma_blob); + +void drm_lut_to_igamma_coeffs(struct drm_property_blob *lut_blob, u32 *coeffs); +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); -#endif +#endif /*_KOMEDA_COLOR_MGMT_H_*/ From patchwork Tue Aug 13 04:56:13 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: 11091113 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0BB4E746 for ; Tue, 13 Aug 2019 04:56:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F17B628334 for ; Tue, 13 Aug 2019 04:56:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E317428409; Tue, 13 Aug 2019 04:56:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 91D9228334 for ; Tue, 13 Aug 2019 04:56:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C7F3E6E634; Tue, 13 Aug 2019 04:56:31 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10070.outbound.protection.outlook.com [40.107.1.70]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7051D6E634 for ; Tue, 13 Aug 2019 04:56:30 +0000 (UTC) Received: from DB7PR08CA0065.eurprd08.prod.outlook.com (20.176.237.170) by HE1PR0802MB2604.eurprd08.prod.outlook.com (10.175.32.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.16; Tue, 13 Aug 2019 04:56:26 +0000 Received: from DB5EUR03FT012.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::208) by DB7PR08CA0065.outlook.office365.com (2603:10a6:10:26::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.18 via Frontend Transport; Tue, 13 Aug 2019 04:56:26 +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 DB5EUR03FT012.mail.protection.outlook.com (10.152.20.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2052.18 via Frontend Transport; Tue, 13 Aug 2019 04:56:24 +0000 Received: ("Tessian outbound 40a263b748b4:v26"); Tue, 13 Aug 2019 04:56:21 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: c98b36d8a0807742 X-CR-MTA-TID: 64aa7808 Received: from 72c8a93d845b.2 (cr-mta-lb-1.cr-mta-net [104.47.2.56]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 823FA6D8-80AB-4B6F-AD61-678636BDA14C.1; Tue, 13 Aug 2019 04:56:16 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01lp2056.outbound.protection.outlook.com [104.47.2.56]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 72c8a93d845b.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Tue, 13 Aug 2019 04:56:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aDs23oBNL4yiNYf6D2k6EzSKCvmPrz1ssPg1aWeYfShSyX5V1fsCrakxMaXl7zHkBKI/xvpBSNdShN7D/ipDmPJ7ZxWd5/s+HXaVjyVsG60MJw8C9daI2gWAbP4ERgF6CByJ0uTzShMDHFcEKkSRx7x3zw3+AgOh4+h7gkL/OQUNE+UfHLyxMONi3487aKb0p5Ni2vLOlOquH7l6Vg5/RfLsVErbJ2+YwQ1TnIUfNDSWw5eBCA2m/J5hGp7Nov9Nug+/5uriNlxcuSi7Hb9ZAOZ2Knxlxo7SJK7X3b+04Oa744e34dZnxjRiV+h5qQv4fWNLNq07JyYjY+AohnE4fA== 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=q+0u85TYIqzebZPwRrp3l710GQKtayDKSXGIPRoI9M0=; b=gmvtb98YUejL9TfRKWAoD0CyfQJuMXXU7T4NR0FELOkMm9v+/kJSJJnKOMeTKcRbVL/skJ5Mhv9MnYR5hOl7eTz/i8Sooi1lBLcNDY2tTYaqP/ELQR4eDJQ2HKVhOMjVtYyOTpMjtmUFJfqF3IBIu9LHWhT7dZ9kiliWPYV/CvqKd9BWZk91nchenjBE8avWMoas971aC3dnzQGvkbUUkUP7Emc1nlvNb/DA4nANt4zmVcRsha33Fbi+mSbcjk1NwTzU0xZl9zFPvls03WhEHuEIUNfM5M9i73acZi8ax3PJQvzZi2h6O7ClxAA3SaAX8uDfbiv8GDZoLkpZYl3d2w== 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 VE1PR08MB4752.eurprd08.prod.outlook.com (10.255.112.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.15; Tue, 13 Aug 2019 04:56:13 +0000 Received: from VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::2151:f0b1:3ea7:c134]) by VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::2151:f0b1:3ea7:c134%6]) with mapi id 15.20.2157.022; Tue, 13 Aug 2019 04:56:13 +0000 From: "james qian wang (Arm Technology China)" To: Liviu Dudau , "airlied@linux.ie" , Brian Starkey , "maarten.lankhorst@linux.intel.com" , "sean@poorly.run" Subject: [PATCH v2 3/4] drm: Increase DRM_OBJECT_MAX_PROPERTY to 32 Thread-Topic: [PATCH v2 3/4] drm: Increase DRM_OBJECT_MAX_PROPERTY to 32 Thread-Index: AQHVUZNuExuVOSGvIUuvlOEBz51WoQ== Date: Tue, 13 Aug 2019 04:56:13 +0000 Message-ID: <20190813045536.28239-4-james.qian.wang@arm.com> References: <20190813045536.28239-1-james.qian.wang@arm.com> In-Reply-To: <20190813045536.28239-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: HK0PR01CA0070.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::34) 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: d8a03e7d-04f1-4045-7e1b-08d71faa97d3 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam-Untrusted: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:VE1PR08MB4752; X-MS-TrafficTypeDiagnostic: VE1PR08MB4752:|HE1PR0802MB2604: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:3383;OLM:3383; x-forefront-prvs: 01283822F8 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(136003)(376002)(39860400002)(366004)(346002)(396003)(199004)(189003)(50226002)(5660300002)(2201001)(110136005)(26005)(316002)(66066001)(6116002)(3846002)(305945005)(2906002)(7736002)(103116003)(71190400001)(71200400001)(4744005)(8676002)(1076003)(54906003)(446003)(55236004)(66946007)(478600001)(81156014)(14454004)(386003)(6506007)(4326008)(36756003)(52116002)(2616005)(102836004)(25786009)(256004)(11346002)(14444005)(81166006)(186003)(76176011)(6486002)(64756008)(66556008)(66476007)(99286004)(2501003)(6512007)(6436002)(86362001)(66446008)(8936002)(486006)(476003)(53936002); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB4752; 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-Message-Info-Original: ReEIy0SpfB0bF4e+4ch+ModvRHJLMrbASfNAdfw0U/nxFdLFd/XK9d9difLEnNdTPSFC6glpj+HbA8++5XV94N3iOrUCrFrYXEk4jcqVTfB/UGi1pSxXfaFobgqNty8Ph9ueYMkGcmiViTfvbq/lVm+pYysyzuQ1Yr+syLRHcfQME3qciqOxmz/KxC6X3nIIcKAbGc30Rtq001r1Fo3OdJC0W2DC53ro4bOfKUoXi/nMs6XmpdaCB6vnEL3OzjX4FaMRU2iPsoshp4gtp0kR1MuOmwEPEMO0iIjyudosji6j38ONfKUXFZR/bNilSyLOG0nhyz884rqKbMWxVnZ+grUn3G9/stjYrT0vaYkuos2w3bVN4joL3E5/43UuYFmQODOtUDFKFCF/T5U0gxS2tjrdl6DImjZiVMeNJnWZkIc= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4752 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT012.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)(376002)(136003)(346002)(2980300002)(189003)(199004)(5660300002)(14454004)(50466002)(26826003)(23756003)(70586007)(356004)(4744005)(70206006)(103116003)(1076003)(478600001)(76130400001)(22756006)(6116002)(3846002)(316002)(8676002)(54906003)(110136005)(186003)(336012)(7736002)(81166006)(8746002)(81156014)(6486002)(386003)(6506007)(8936002)(102836004)(50226002)(305945005)(446003)(486006)(76176011)(47776003)(26005)(66066001)(99286004)(14444005)(2616005)(2501003)(4326008)(25786009)(86362001)(2906002)(36756003)(63370400001)(2201001)(11346002)(63350400001)(476003)(6512007)(126002); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0802MB2604; 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: 4c508d22-354b-495e-4a79-08d71faa90ee X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(710020)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:HE1PR0802MB2604; NoDisclaimer: True X-Forefront-PRVS: 01283822F8 X-Microsoft-Antispam-Message-Info: G/kH8JtBOp+wdE8EDYsLqPbkO9atkkVh9uGyGYaLRk/V4tnJVEr+ca71mfqH2ZBykhvYXxCiDr/Yxq3o/+Bo5tzUyD0I2XlQPIWN36Bl1vJ3/t3G/f/lEFTMn3s1xkRCDXFOVwrGw8+QClLnYxKl4y4stZ12niqWpRdyd92uk8d2HblZ/0f8xKi6U+Ewlkaa9hg4PyLnzIrWxrCfKh3DzGv4lLCSFKmgmBHN67MNJBOjCMYjLPxaCx5oxgQXUxDKMoeW69GywvMOUy1dBO2nnzrIMdVWnA4OuWwrT+RKBt5gloAamYYFuQy3xmGCPfXIa6Bo+BMiI0kxCayPuuTWG/TSFgKvNyKJujxIrgplqpwERLIIRN8nfZqqmQsoh1X76sDBG+s2WcfZs4/EOk43//PQhbNJ11tJTqs2iXct3BA= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2019 04:56:24.7795 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d8a03e7d-04f1-4045-7e1b-08d71faa97d3 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: HE1PR0802MB2604 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=q+0u85TYIqzebZPwRrp3l710GQKtayDKSXGIPRoI9M0=; b=KQ8nSjUMsPy0YMldoGAAxWKGCgZe+Ri+ckkDtD5KPAn50uBDPJlRtwSNBDBMUdCwk3V+GcOmbRsEJ54yYkIx6v9amadXBp9zI2K6/+Vc0mqgkWtUGmJWoTw3NriSvh7+MYVXxy6nrnE15M8he/FJCHpnqvq/PXuW1o7rA0YEo04= 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=q+0u85TYIqzebZPwRrp3l710GQKtayDKSXGIPRoI9M0=; b=KQ8nSjUMsPy0YMldoGAAxWKGCgZe+Ri+ckkDtD5KPAn50uBDPJlRtwSNBDBMUdCwk3V+GcOmbRsEJ54yYkIx6v9amadXBp9zI2K6/+Vc0mqgkWtUGmJWoTw3NriSvh7+MYVXxy6nrnE15M8he/FJCHpnqvq/PXuW1o7rA0YEo04= 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=temperror 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" X-Virus-Scanned: ClamAV using ClamSMTP DRM_OBJECT_MAX_PROPERTY number 24 is not enough for komeda usage, increase it to 32 to fit komeda's requirement. Signed-off-by: James Qian Wang (Arm Technology China) --- include/drm/drm_mode_object.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/drm/drm_mode_object.h b/include/drm/drm_mode_object.h index c34a3e8030e1..fd7666048197 100644 --- a/include/drm/drm_mode_object.h +++ b/include/drm/drm_mode_object.h @@ -60,7 +60,7 @@ struct drm_mode_object { void (*free_cb)(struct kref *kref); }; -#define DRM_OBJECT_MAX_PROPERTY 24 +#define DRM_OBJECT_MAX_PROPERTY 32 /** * struct drm_object_properties - property tracking for &drm_mode_object */ From patchwork Tue Aug 13 04:56:19 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: 11091115 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B26ED746 for ; Tue, 13 Aug 2019 04:56:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9EBC0283BF for ; Tue, 13 Aug 2019 04:56:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8EBA728334; Tue, 13 Aug 2019 04:56:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A600428334 for ; Tue, 13 Aug 2019 04:56:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B9B306E639; Tue, 13 Aug 2019 04:56:40 +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-eopbgr130058.outbound.protection.outlook.com [40.107.13.58]) by gabe.freedesktop.org (Postfix) with ESMTPS id D49B56E635 for ; Tue, 13 Aug 2019 04:56:38 +0000 (UTC) Received: from VI1PR0802CA0031.eurprd08.prod.outlook.com (2603:10a6:800:a9::17) by DB6PR0801MB1848.eurprd08.prod.outlook.com (2603:10a6:4:38::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.21; Tue, 13 Aug 2019 04:56:35 +0000 Received: from AM5EUR03FT029.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::208) by VI1PR0802CA0031.outlook.office365.com (2603:10a6:800:a9::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.16 via Frontend Transport; Tue, 13 Aug 2019 04:56:34 +0000 Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT029.mail.protection.outlook.com (10.152.16.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2052.18 via Frontend Transport; Tue, 13 Aug 2019 04:56:32 +0000 Received: ("Tessian outbound cc8a947d4660:v26"); Tue, 13 Aug 2019 04:56:27 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: f56bfa327bedf641 X-CR-MTA-TID: 64aa7808 Received: from 2d74ace07b8c.2 (cr-mta-lb-1.cr-mta-net [104.47.2.52]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 600BA60B-36EF-41A6-AFDD-39ACEF0B48F9.1; Tue, 13 Aug 2019 04:56:22 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01lp2052.outbound.protection.outlook.com [104.47.2.52]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 2d74ace07b8c.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Tue, 13 Aug 2019 04:56:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a42k6Ui/tmClTldgVCo07zzS5YDRsChG9pE0DIPR6ZtFeC37kr/mpdc9R0pcAuq2WIYshUYWaJRHB5NCxBBYebjH7vmyFUo9zd2yI8vu6e3qGcAt4EjiWanVUhuWpO0jccjxYV5PXc5jTgg58Fa4uflfiEXiKOMED/zsnJbyCpgt0hfpem095AUWmrafMZKqTOeuD4k78NbdMM+sgXqYn+U8ow4rrzg1+aQopGmZx1U6+CjhUUDgd+UjA2rl2WDrcW3RYEzpwdm1aYKvTCxsnJ3WB4cdkHNvW4YbS5QJVdralp/qrvmxkdxuh9EdsVSo1V4yQrWJrTZPf/KFbpQ+rg== 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=ELGSwsk+zynTLRxU+VJpxB9bM0b/m1S4eaWpwfH4Ip4=; b=NOJzEFFyKEIGQiG1M6u+yVDGi+2nL4RqExU4V21dwPiyUo/cwG8c+KCrBK8MMRxAUkF0puvlIO5X0LBAGcWTQYvTvBSdTiA1KtGLptcJ6IzVnAhmdoI3jxJue/M6tJ0gIvC5gzd83dUSpbMirmfWITwmu8guBfyvuLLEaALRekpx9UtB+0ozklvR1TN0e7W3owQwCFj+KheLW2JB5OYR01OYwrM1v5qGE0gF7NJ6fZwTrmUkT0Cv99rsdvc51IQfjOIXqSY6dD31AHbKwyvGTjzH/m1OMLcZS40eNaCF3U4kGuZkbyWqiFYcMr/KjK7VR9aSTnKMEIt3gZCpovWTRA== 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 VE1PR08MB4752.eurprd08.prod.outlook.com (10.255.112.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.15; Tue, 13 Aug 2019 04:56:20 +0000 Received: from VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::2151:f0b1:3ea7:c134]) by VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::2151:f0b1:3ea7:c134%6]) with mapi id 15.20.2157.022; Tue, 13 Aug 2019 04:56:20 +0000 From: "james qian wang (Arm Technology China)" To: Liviu Dudau , "airlied@linux.ie" , Brian Starkey , "maarten.lankhorst@linux.intel.com" , "sean@poorly.run" Subject: [PATCH v2 4/4] drm/komeda: Enable Layer color management for komeda Thread-Topic: [PATCH v2 4/4] drm/komeda: Enable Layer color management for komeda Thread-Index: AQHVUZNyccESoC2zR0ORWyBtwFKZLA== Date: Tue, 13 Aug 2019 04:56:19 +0000 Message-ID: <20190813045536.28239-5-james.qian.wang@arm.com> References: <20190813045536.28239-1-james.qian.wang@arm.com> In-Reply-To: <20190813045536.28239-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: HK0PR01CA0070.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::34) 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: aa6c5e2d-4924-42b3-908d-08d71faa9cb8 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam-Untrusted: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:VE1PR08MB4752; X-MS-TrafficTypeDiagnostic: VE1PR08MB4752:|DB6PR0801MB1848: X-MS-Exchange-PUrlCount: 1 x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:7691;OLM:7691; x-forefront-prvs: 01283822F8 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(136003)(376002)(39860400002)(366004)(346002)(396003)(199004)(189003)(50226002)(5660300002)(2201001)(110136005)(26005)(316002)(66066001)(6116002)(3846002)(305945005)(2906002)(7736002)(103116003)(71190400001)(71200400001)(30864003)(8676002)(1076003)(54906003)(446003)(55236004)(66946007)(966005)(478600001)(81156014)(14454004)(386003)(6506007)(4326008)(36756003)(52116002)(2616005)(102836004)(25786009)(256004)(11346002)(14444005)(81166006)(186003)(76176011)(6486002)(64756008)(66556008)(66476007)(99286004)(2501003)(6306002)(6512007)(6436002)(86362001)(66446008)(8936002)(486006)(476003)(53936002); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB4752; 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-Message-Info-Original: yj+BSqhadMT5kN6q5kM8Pt+I8QngsTmcNLEror4wOZcIzwA+9StMwSVuPH5u378I45rwzYMdb0/qQXI0lfeDMrhPo0MObvtQGVyBA7RSh7ED9aOolNB7w7cEeXu78iEyB9M3nsUnJUEJ8YuSMWY1YUXavkBDLpf9lXJ0GlgmdmZIcmxNRJrlIU+8Njy7haLQBmGzTpyK4IJZRTTz0sorUDi1uL5VCwVPjfqfh/u4qtwWbIQ5hKOAfjdjR4xm6lTQ3o8N6SQT284cbGlpsigYcG8JZvxFqLA2NA66iUXJZmfXx0B1Dxautx5VripaBBBuX5et/rWD/RH5UY3GCBpwNWL7KM3WFF1CVdG/qc8Hk6hmXg9iF2JjGBIMXYrmoxUMYYPT8ht3O7N3pjqbOi8TJRklDt7ztIazJQ3FtM/YeME= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4752 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT029.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; IPV:CAL; SCL:-1; CTRY:IE; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(136003)(39860400002)(376002)(396003)(346002)(2980300002)(189003)(199004)(3846002)(6116002)(8936002)(81156014)(81166006)(356004)(8746002)(2906002)(6512007)(50226002)(6306002)(23756003)(8676002)(22756006)(86362001)(76130400001)(50466002)(966005)(1076003)(2616005)(386003)(6506007)(63370400001)(63350400001)(36906005)(478600001)(54906003)(36756003)(476003)(186003)(316002)(70586007)(5660300002)(14444005)(14454004)(110136005)(486006)(6486002)(70206006)(126002)(30864003)(336012)(47776003)(66066001)(4326008)(99286004)(305945005)(7736002)(2201001)(26826003)(446003)(26005)(102836004)(2501003)(76176011)(103116003)(25786009)(11346002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0801MB1848; 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: ec62dfa1-281b-48f6-ec4b-08d71faa94b3 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(710020)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:DB6PR0801MB1848; NoDisclaimer: True X-Forefront-PRVS: 01283822F8 X-Microsoft-Antispam-Message-Info: xtkiAFjvfMD40ML5DD1aj2W85dcFcZcBBCVUiNVyJn/lC1gDulL9BufPjfhL6ovfnaPJlpipyWYb7Cmud6m4I69Q+IY8rrZQdlYCNXgZW24jTtayzxocYyHX7H5LCZec8Qz6sKC4Relbohq97T86iy8jmL8DVdfzSCq+Osp2UD93FJ9MbY8LpI98bd8+Jea/DDk+hj+Rv0ZmYxYuCoblulpiY5i8HMFwVPkBNZSwCYxXaGLQD2yyrybGyPngE1geRdauwm/Ex5OZdMD1Wukm+YZz4Uf1CfILvxrdQAv1xf3GqG5nqn6IcgAADccLHbAlGGEB8npxV4gXtf3N1oc6QK+204OEdwsg4SOdpLf+nI3kSbZEERKi1+ymHcd0r7HTg45ljpvT1JRKsrS8r89aQoY9n9co3AQWiTPU24moCR8= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2019 04:56:32.9476 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aa6c5e2d-4924-42b3-908d-08d71faa9cb8 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: DB6PR0801MB1848 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=ELGSwsk+zynTLRxU+VJpxB9bM0b/m1S4eaWpwfH4Ip4=; b=WBGtg6tVVuqBOBF/YmFxwvY9jftvMPsiqsGlevXouqaaKl3AvhsZaZJ3RcvaISzyJtGMPK2inhebUQWRqIgQHlkIdjBrXmVK5VYwWxvzrc5sDoU+DbFCkmD6IJCIkcTvHU3DN9qYM4bgB2OfcWvxHPgW6CnOVCQ8Y2AFkXh6PJ4= 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=ELGSwsk+zynTLRxU+VJpxB9bM0b/m1S4eaWpwfH4Ip4=; b=WBGtg6tVVuqBOBF/YmFxwvY9jftvMPsiqsGlevXouqaaKl3AvhsZaZJ3RcvaISzyJtGMPK2inhebUQWRqIgQHlkIdjBrXmVK5VYwWxvzrc5sDoU+DbFCkmD6IJCIkcTvHU3DN9qYM4bgB2OfcWvxHPgW6CnOVCQ8Y2AFkXh6PJ4= 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=temperror 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" X-Virus-Scanned: ClamAV using ClamSMTP - D71 has 3 global layer gamma table which can be used for all layers as gamma lookup table, no matter inverse or forward. - Add komeda_color_manager/state to layer/layer_state for describe the color caps for the specific layer which will be initialized in d71_layer_init, and for D71 only layer with L_INFO_CM (color mgmt) bit can support forward gamma, and CSC. - Update komeda-CORE code to validate and convert the plane color state to komeda_color_state. - Enable plane color mgmt according to layer komeda_color_manager This patch depends on: - https://patchwork.freedesktop.org/series/30876/ Signed-off-by: James Qian Wang (Arm Technology China) --- .../arm/display/komeda/d71/d71_component.c | 64 +++++++++++++++++++ .../gpu/drm/arm/display/komeda/d71/d71_dev.c | 5 +- .../gpu/drm/arm/display/komeda/d71/d71_dev.h | 2 + .../drm/arm/display/komeda/komeda_pipeline.h | 4 +- .../display/komeda/komeda_pipeline_state.c | 53 ++++++++++++++- .../gpu/drm/arm/display/komeda/komeda_plane.c | 12 ++++ .../arm/display/komeda/komeda_private_obj.c | 4 ++ 7 files changed, 139 insertions(+), 5 deletions(-) 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 55a8cc94808a..c9c40a36e4d2 100644 --- a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c +++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c @@ -189,6 +189,46 @@ static void d71_layer_update_fb(struct komeda_component *c, malidp_write32(reg, LAYER_FMT, kfb->format_caps->hw_id); } +static u32 d71_layer_update_color(struct drm_plane_state *st, + u32 __iomem *reg, + struct komeda_color_state *color_st, + u32 *mask) +{ + struct komeda_coeffs_table *igamma = color_st->igamma; + struct komeda_coeffs_table *fgamma = color_st->fgamma; + u32 ctrl = 0, v = 0; + + if (!st->color_mgmt_changed) + return 0; + + *mask |= L_IT | L_R2R | L_FT; + + if (igamma) { + komeda_coeffs_update(igamma); + ctrl |= L_IT; + v = L_ITSEL(igamma->hw_id); + } + + if (st->ctm) { + u32 ctm_coeffs[KOMEDA_N_CTM_COEFFS]; + + drm_ctm_to_coeffs(st->ctm, ctm_coeffs); + malidp_write_group(reg, LAYER_RGB_RGB_COEFF0, + ARRAY_SIZE(ctm_coeffs), + ctm_coeffs); + ctrl |= L_R2R; /* enable RGB2RGB conversion */ + } + + if (fgamma) { + komeda_coeffs_update(fgamma); + ctrl |= L_FT; + v |= L_FTSEL(fgamma->hw_id); + } + + malidp_write32(reg, LAYER_LT_COEFFTAB, v); + return ctrl; +} + static void d71_layer_disable(struct komeda_component *c) { malidp_write32_mask(c->reg, BLK_CONTROL, L_EN, 0); @@ -261,6 +301,8 @@ static void d71_layer_update(struct komeda_component *c, malidp_write32(reg, BLK_IN_SIZE, HV_SIZE(st->hsize, st->vsize)); + ctrl |= d71_layer_update_color(plane_st, reg, &st->color_st, &ctrl_mask); + if (kfb->is_va) ctrl |= L_TBU_EN; malidp_write32_mask(reg, BLK_CONTROL, ctrl_mask, ctrl); @@ -365,6 +407,12 @@ static int d71_layer_init(struct d71_dev *d71, else layer->layer_type = KOMEDA_FMT_SIMPLE_LAYER; + layer->color_mgr.igamma_mgr = d71->glb_lt_mgr; + if (layer_info & L_INFO_CM) { + layer->color_mgr.has_ctm = true; + layer->color_mgr.fgamma_mgr = d71->glb_lt_mgr; + } + set_range(&layer->hsize_in, 4, d71->max_line_size); set_range(&layer->vsize_in, 4, d71->max_vsize); @@ -1140,6 +1188,21 @@ static int d71_timing_ctrlr_init(struct d71_dev *d71, return 0; } +static void d71_gamma_update(struct komeda_coeffs_table *table) +{ + malidp_write_group(table->reg, GLB_LT_COEFF_DATA, + GLB_LT_COEFF_NUM, table->coeffs); +} + +static int d71_lt_coeff_init(struct d71_dev *d71, + struct block_header *blk, u32 __iomem *reg) +{ + struct komeda_coeffs_manager *mgr = d71->glb_lt_mgr; + int hw_id = BLOCK_INFO_TYPE_ID(blk->block_info); + + return komeda_coeffs_add(mgr, hw_id, reg, d71_gamma_update); +} + int d71_probe_block(struct d71_dev *d71, struct block_header *blk, u32 __iomem *reg) { @@ -1202,6 +1265,7 @@ int d71_probe_block(struct d71_dev *d71, break; case D71_BLK_TYPE_GLB_LT_COEFF: + err = d71_lt_coeff_init(d71, blk, reg); break; case D71_BLK_TYPE_GLB_SCL_COEFF: diff --git a/drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c b/drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c index d567ab7ed314..edd5d7c7f2a2 100644 --- a/drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c +++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c @@ -341,7 +341,7 @@ static int d71_enum_resources(struct komeda_dev *mdev) struct komeda_pipeline *pipe; struct block_header blk; u32 __iomem *blk_base; - u32 i, value, offset; + u32 i, value, offset, coeffs_size; int err; d71 = devm_kzalloc(mdev->dev, sizeof(*d71), GFP_KERNEL); @@ -398,6 +398,9 @@ static int d71_enum_resources(struct komeda_dev *mdev) d71->pipes[i] = to_d71_pipeline(pipe); } + coeffs_size = GLB_LT_COEFF_NUM * sizeof(u32); + d71->glb_lt_mgr = komeda_coeffs_create_manager(coeffs_size); + /* loop the register blks and probe */ i = 2; /* exclude GCU and PERIPH */ offset = D71_BLOCK_SIZE; /* skip GCU */ diff --git a/drivers/gpu/drm/arm/display/komeda/d71/d71_dev.h b/drivers/gpu/drm/arm/display/komeda/d71/d71_dev.h index 84f1878b647d..009c164a1584 100644 --- a/drivers/gpu/drm/arm/display/komeda/d71/d71_dev.h +++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_dev.h @@ -39,6 +39,8 @@ struct d71_dev { u32 __iomem *periph_addr; struct d71_pipeline *pipes[D71_MAX_PIPELINE]; + /* global layer transform coefficient table manager */ + struct komeda_coeffs_manager *glb_lt_mgr; }; #define to_d71_pipeline(x) container_of(x, struct d71_pipeline, base) diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h index a7a84e66549d..4104c81e5032 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h @@ -10,6 +10,7 @@ #include #include #include +#include "komeda_color_mgmt.h" #include "malidp_utils.h" #define KOMEDA_MAX_PIPELINES 2 @@ -226,6 +227,7 @@ struct komeda_layer { struct komeda_component base; /* accepted h/v input range before rotation */ struct malidp_range hsize_in, vsize_in; + struct komeda_color_manager color_mgr; u32 layer_type; /* RICH, SIMPLE or WB */ u32 supported_rots; /* komeda supports layer split which splits a whole image to two parts @@ -238,7 +240,7 @@ struct komeda_layer { struct komeda_layer_state { struct komeda_component_state base; - /* layer specific configuration state */ + struct komeda_color_state color_st; u16 hsize, vsize; u32 rot; u16 afbc_crop_l; 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 ea26bc9c2d00..803715c1128e 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c @@ -95,6 +95,21 @@ komeda_pipeline_get_state_and_set_crtc(struct komeda_pipeline *pipe, return st; } +static bool komeda_component_is_new_active(struct komeda_component *c, + struct drm_atomic_state *state) +{ + struct komeda_pipeline_state *ppl_old_st; + + ppl_old_st = komeda_pipeline_get_old_state(c->pipeline, state); + if (IS_ERR(ppl_old_st)) + return true; + + if (has_bit(c->id, ppl_old_st->active_comps)) + return false; + + return true; +} + static struct komeda_component_state * komeda_component_get_state(struct komeda_component *c, struct drm_atomic_state *state) @@ -279,6 +294,29 @@ komeda_rotate_data_flow(struct komeda_data_flow_cfg *dflow, u32 rot) } } +static int +komeda_validate_plane_color(struct komeda_component *c, + struct komeda_color_manager *color_mgr, + struct komeda_color_state *color_st, + struct drm_plane_state *plane_st) +{ + int err; + + if (komeda_component_is_new_active(c, plane_st->state)) + plane_st->color_mgmt_changed = true; + + if (!plane_st->color_mgmt_changed) + return 0; + + err = komeda_color_validate(color_mgr, color_st, + plane_st->degamma_lut, + plane_st->gamma_lut); + if (err) + DRM_DEBUG_ATOMIC("%s validate color failed.\n", c->name); + + return err; +} + static int komeda_layer_check_cfg(struct komeda_layer *layer, struct komeda_fb *kfb, @@ -362,6 +400,11 @@ komeda_layer_validate(struct komeda_layer *layer, st->addr[i] = komeda_fb_get_pixel_addr(kfb, dflow->in_x, dflow->in_y, i); + err = komeda_validate_plane_color(&layer->base, &layer->color_mgr, + &st->color_st, plane_st); + if (err) + return err; + err = komeda_component_validate_private(&layer->base, c_st); if (err) return err; @@ -1177,7 +1220,7 @@ komeda_pipeline_unbound_components(struct komeda_pipeline *pipe, { struct drm_atomic_state *drm_st = new->obj.state; struct komeda_pipeline_state *old = priv_to_pipe_st(pipe->obj.state); - struct komeda_component_state *c_st; + struct komeda_component_state *st; struct komeda_component *c; u32 disabling_comps, id; @@ -1188,9 +1231,13 @@ komeda_pipeline_unbound_components(struct komeda_pipeline *pipe, /* unbound all disabling component */ dp_for_each_set_bit(id, disabling_comps) { c = komeda_pipeline_get_component(pipe, id); - c_st = komeda_component_get_state_and_set_user(c, + st = komeda_component_get_state_and_set_user(c, drm_st, NULL, new->crtc); - WARN_ON(IS_ERR(c_st)); + + WARN_ON(IS_ERR(st)); + + if (has_bit(id, KOMEDA_PIPELINE_LAYERS)) + komeda_color_cleanup_state(&to_layer_st(st)->color_st); } } diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c b/drivers/gpu/drm/arm/display/komeda/komeda_plane.c index 98e915e325dd..69fa1dea41c9 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_plane.c @@ -11,6 +11,7 @@ #include "komeda_dev.h" #include "komeda_kms.h" #include "komeda_framebuffer.h" +#include "komeda_color_mgmt.h" static int komeda_plane_init_data_flow(struct drm_plane_state *st, @@ -250,6 +251,7 @@ static int komeda_plane_add(struct komeda_kms_dev *kms, { struct komeda_dev *mdev = kms->base.dev_private; struct komeda_component *c = &layer->base; + struct komeda_color_manager *color_mgr; struct komeda_plane *kplane; struct drm_plane *plane; u32 *formats, n_formats = 0; @@ -306,6 +308,16 @@ static int komeda_plane_add(struct komeda_kms_dev *kms, if (err) goto cleanup; + err = drm_plane_color_create_prop(plane->dev, plane); + if (err) + goto cleanup; + + color_mgr = &layer->color_mgr; + drm_plane_enable_color_mgmt(plane, + color_mgr->igamma_mgr ? KOMEDA_COLOR_LUT_SIZE : 0, + color_mgr->has_ctm, + color_mgr->fgamma_mgr ? KOMEDA_COLOR_LUT_SIZE : 0); + err = drm_plane_create_zpos_property(plane, layer->base.id, 0, 8); if (err) goto cleanup; diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_private_obj.c b/drivers/gpu/drm/arm/display/komeda/komeda_private_obj.c index 914400c4af73..4c474663f554 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_private_obj.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_private_obj.c @@ -19,12 +19,15 @@ komeda_component_state_reset(struct komeda_component_state *st) static struct drm_private_state * komeda_layer_atomic_duplicate_state(struct drm_private_obj *obj) { + struct komeda_layer_state *old = to_layer_st(priv_to_comp_st(obj->state)); struct komeda_layer_state *st; st = kmemdup(obj->state, sizeof(*st), GFP_KERNEL); if (!st) return NULL; + komeda_color_duplicate_state(&st->color_st, &old->color_st); + komeda_component_state_reset(&st->base); __drm_atomic_helper_private_obj_duplicate_state(obj, &st->base.obj); @@ -37,6 +40,7 @@ komeda_layer_atomic_destroy_state(struct drm_private_obj *obj, { struct komeda_layer_state *st = to_layer_st(priv_to_comp_st(state)); + komeda_color_cleanup_state(&st->color_st); kfree(st); }