From patchwork Mon Sep 30 04:54: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: 11165991 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 24325112B for ; Mon, 30 Sep 2019 04:55:00 +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 0729821855 for ; Mon, 30 Sep 2019 04:54:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0729821855 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 0843B6E32F; Mon, 30 Sep 2019 04:54:59 +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-eopbgr130088.outbound.protection.outlook.com [40.107.13.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id DD15D6E32F for ; Mon, 30 Sep 2019 04:54:55 +0000 (UTC) Received: from VI1PR0802CA0020.eurprd08.prod.outlook.com (2603:10a6:800:aa::30) by DBBPR08MB4680.eurprd08.prod.outlook.com (2603:10a6:10:f2::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.20; Mon, 30 Sep 2019 04:54:49 +0000 Received: from AM5EUR03FT051.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::206) by VI1PR0802CA0020.outlook.office365.com (2603:10a6:800:aa::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.20 via Frontend Transport; Mon, 30 Sep 2019 04:54:48 +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 AM5EUR03FT051.mail.protection.outlook.com (10.152.16.246) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.15 via Frontend Transport; Mon, 30 Sep 2019 04:54:47 +0000 Received: ("Tessian outbound 927f2cdd66cc:v33"); Mon, 30 Sep 2019 04:54:43 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 449fa4edf9518bb1 X-CR-MTA-TID: 64aa7808 Received: from cda93119b744.2 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.13.53]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 01DA1FD6-318D-466A-A93B-1013410DD6CA.1; Mon, 30 Sep 2019 04:54:38 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04lp2053.outbound.protection.outlook.com [104.47.13.53]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id cda93119b744.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Mon, 30 Sep 2019 04:54:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OAmxKax6gf7ZEaaWofuM3U3D8NH0E7Rj6+nJ9XcS4pYsYEF8QFF6H7tQwU/+HUMbRLtX0vN5qZxsTAuv2Uc9DduS8w7rMDbd9COLFhHgjDRT2yL1f2vYIxKyxzkCZUn5nJ766x3lS5CSZWPMhMuXPtcRScxEjb+PXPs1qU5JEli2UGPjFjWr/TAzOtNfNTyC1j2/9g1yCk8Z+ECUFHX7eiJgv/+0q4rJ/sFP5lVIVBSLAIElDTBqmk4TUbZoCrRCNXeMK0X5v6GhKzKaT7Xu9VINxhwdLqW/KE63RJtgTS3TahIxZf1q2wbeBf7tUKXtYdCYF6X1ycs/mJYO/dFmlQ== 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=G8p14T5zzsEVDuvuNqAfIV2/Lu1wkm1STaTxKDjP/Q7UIbpqmZa6jyScr/VLgZ4LBMqeOeLayGp4agORNLJ+M1Sj40D7mCykPoZRm2Hwabph/o1qDXgG0tH2ctmR1k6M1DYHK0cYsA6z47wnFS+gxEGzHLYgb3+WGX8jBqGJVbjEMInGRNY9cELNo6c5a0CeIR5YlFFXPSeb76dKUA5OW0hWQDPfoQt+kcFov97Ubgbay+MfQh1hOH0O6B2ed2eEnHnTOBVc2cw0fPTbthpbiRMI4u7Uq7smBYkFpC6lvzdMwlS2RQusFk/Wb71cRyqLM94wKsPpWcX1gWmQAK+fqg== 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 VE1PR08MB4703.eurprd08.prod.outlook.com (10.255.27.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.17; Mon, 30 Sep 2019 04:54: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.2305.017; Mon, 30 Sep 2019 04:54: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" Subject: [PATCH 1/3] drm/komeda: Add drm_lut_to_fgamma_coeffs() Thread-Topic: [PATCH 1/3] drm/komeda: Add drm_lut_to_fgamma_coeffs() Thread-Index: AQHVd0snT33H/BtpsUmrR4CGKgAzPQ== Date: Mon, 30 Sep 2019 04:54:35 +0000 Message-ID: <20190930045408.8053-2-james.qian.wang@arm.com> References: <20190930045408.8053-1-james.qian.wang@arm.com> In-Reply-To: <20190930045408.8053-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: HK2PR03CA0066.apcprd03.prod.outlook.com (2603:1096:202:17::36) 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: a9021a26-0439-448f-cf8b-08d745625188 X-MS-Office365-Filtering-HT: Tenant X-MS-TrafficTypeDiagnostic: VE1PR08MB4703:|VE1PR08MB4703:|DBBPR08MB4680: 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: 01762B0D64 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(136003)(376002)(396003)(366004)(346002)(39850400004)(199004)(189003)(6116002)(3846002)(103116003)(26005)(36756003)(2201001)(256004)(305945005)(71200400001)(7736002)(6486002)(55236004)(102836004)(8676002)(81156014)(2501003)(52116002)(71190400001)(66946007)(6436002)(81166006)(14454004)(64756008)(446003)(76176011)(11346002)(2616005)(66476007)(66556008)(86362001)(66446008)(478600001)(99286004)(6506007)(386003)(6512007)(14444005)(66066001)(8936002)(1076003)(476003)(2906002)(316002)(486006)(4326008)(50226002)(54906003)(5660300002)(186003)(110136005)(25786009); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB4703; 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: lZ7mBFKlE3zMXXk+ZEbCOVOUPdhbtGHn3mzRXNDpumBXjQtJsOspw+lLufuqAlNhw3nV/vg5lIHQ7uyp2sOzcO1ElowG5bFlVrjiMnh9ST+4xDr44FnQbAq1saj9FB7SJvmwcs0sBaauKMD8pCwcMOONS6G1Dn/y4bzWO9gWrAK4e+TPWfyIkF4KC01IPeA1ywrrx4AY8DBvaSMr2RowYqfluSvXqfZBQyp4rHhrRoqR1SzVZL8j+odUJ1L3jHuAzuYhT9w9enadgRlQ+DiV3q38UoJvb+d8FAuj/WMR/kIhQNrHvr9sG7qqTBzbfpldJZ/ramabn+uDOjzTU6Nj1BUJPTKuYHrAVNdEPeHi3EWP1C5Mg2mMSLZBm0mtwCsLZ00uWYHaZ7uz+7187fCzcy93WMqACsOeeMdntQ1A6rw= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4703 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT051.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)(39850400004)(396003)(346002)(136003)(376002)(189003)(199004)(2501003)(22756006)(8676002)(6116002)(81156014)(8746002)(81166006)(4326008)(14444005)(8936002)(336012)(110136005)(86362001)(23756003)(6512007)(54906003)(50226002)(316002)(3846002)(14454004)(36906005)(2906002)(6486002)(2201001)(186003)(63350400001)(50466002)(446003)(6506007)(99286004)(11346002)(305945005)(356004)(386003)(126002)(5660300002)(26005)(486006)(70206006)(103116003)(476003)(7736002)(1076003)(2616005)(478600001)(36756003)(102836004)(47776003)(70586007)(66066001)(76130400001)(26826003)(76176011)(25786009); DIR:OUT; SFP:1101; SCL:1; SRVR:DBBPR08MB4680; 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: d4a3009c-24e0-48a2-de47-08d745624a1c NoDisclaimer: True X-Forefront-PRVS: 01762B0D64 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: spfYgjy7ZxraOQblLj8c1g4u8Y1rrIb+oxN24/6zspTuz7HPaNuYKOF69tXr/8g7SUUH5VRZ7hhw1prGPLOVWYZX9PloVn9mrUNrrbuw2TLz3ujcdpQNvyCDMWA+J4mdtuFA7Xk1tw8Xv4SSj8yyCGKd4pZmO4a6Uz7F4BJYbeYEUBonwvYYzRKAEtAfSsp995by6Tg1CG4RwTv5ak+ZTmwpWfhwSGebh7lRRcmPZZTEiQ66l0WMqGKfTuJX+X0VwRPFI//jEYq7VBzfqaHA0hWzCWlQI352GQ2w7qhvwUBsjW4MCeqtTt+BtSME2lSgp0zH88FosKhhVj/kqZwd4+Lx1zum1JUbTaNDsPzUyIur/23+NmtjxMeMYO/f+NILBMsOfa7cZJFqqjrM0FuuzSDNCGXauwZPIptU8QPcUDw= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2019 04:54:47.2686 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a9021a26-0439-448f-cf8b-08d745625188 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: DBBPR08MB4680 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=6LFj2bBDUDf6PPzsngLgAge8gnWBtUiqapCSf6+PCwANsj/U48Pk1CcAfBJ1lNP4PNlmT5rEJ6fF/b5/BnPcvgfDOdgqaxZwCq1mWQx/dkefihxfYk/3DjQbiJn4pu4AlpjnE3Ni6bCXpOHd1KJuat2yl4r93uSvWjx/f0f+LRo= 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=6LFj2bBDUDf6PPzsngLgAge8gnWBtUiqapCSf6+PCwANsj/U48Pk1CcAfBJ1lNP4PNlmT5rEJ6fF/b5/BnPcvgfDOdgqaxZwCq1mWQx/dkefihxfYk/3DjQbiJn4pu4AlpjnE3Ni6bCXpOHd1KJuat2yl4r93uSvWjx/f0f+LRo= 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) --- .../arm/display/komeda/komeda_color_mgmt.c | 52 +++++++++++++++++++ .../arm/display/komeda/komeda_color_mgmt.h | 9 +++- 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c index 9d14a92dbb17..c180ce70c26c 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c @@ -65,3 +65,55 @@ const s32 *komeda_select_yuv2rgb_coeffs(u32 color_encoding, u32 color_range) return coeffs; } + +struct gamma_curve_sector { + u32 boundary_start; + u32 num_of_segments; + u32 segment_width; +}; + +struct gamma_curve_segment { + u32 start; + u32 end; +}; + +static struct gamma_curve_sector sector_tbl[] = { + { 0, 4, 4 }, + { 16, 4, 4 }, + { 32, 4, 8 }, + { 64, 4, 16 }, + { 128, 4, 32 }, + { 256, 4, 64 }, + { 512, 16, 32 }, + { 1024, 24, 128 }, +}; + +static void +drm_lut_to_coeffs(struct drm_property_blob *lut_blob, u32 *coeffs, + struct gamma_curve_sector *sector_tbl, u32 num_sectors) +{ + struct drm_color_lut *lut; + u32 i, j, in, num = 0; + + if (!lut_blob) + return; + + lut = lut_blob->data; + + for (i = 0; i < num_sectors; i++) { + for (j = 0; j < sector_tbl[i].num_of_segments; j++) { + in = sector_tbl[i].boundary_start + + j * sector_tbl[i].segment_width; + + coeffs[num++] = drm_color_lut_extract(lut[in].red, + KOMEDA_COLOR_PRECISION); + } + } + + coeffs[num] = BIT(KOMEDA_COLOR_PRECISION); +} + +void drm_lut_to_fgamma_coeffs(struct drm_property_blob *lut_blob, u32 *coeffs) +{ + drm_lut_to_coeffs(lut_blob, coeffs, sector_tbl, ARRAY_SIZE(sector_tbl)); +} diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h index a2df218f58e7..08ab69281648 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h +++ b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h @@ -11,7 +11,14 @@ #include #define KOMEDA_N_YUV2RGB_COEFFS 12 +#define KOMEDA_N_RGB2YUV_COEFFS 12 +#define KOMEDA_COLOR_PRECISION 12 +#define KOMEDA_N_GAMMA_COEFFS 65 +#define KOMEDA_COLOR_LUT_SIZE BIT(KOMEDA_COLOR_PRECISION) +#define KOMEDA_N_CTM_COEFFS 9 + +void drm_lut_to_fgamma_coeffs(struct drm_property_blob *lut_blob, u32 *coeffs); const s32 *komeda_select_yuv2rgb_coeffs(u32 color_encoding, u32 color_range); -#endif +#endif /*_KOMEDA_COLOR_MGMT_H_*/ From patchwork Mon Sep 30 04:54:41 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: 11165993 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 066FC112B for ; Mon, 30 Sep 2019 04:55: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 E19D421855 for ; Mon, 30 Sep 2019 04:55:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E19D421855 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 E19786E334; Mon, 30 Sep 2019 04:55:03 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-db5eur03on0617.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0a::617]) by gabe.freedesktop.org (Postfix) with ESMTPS id C02B86E334 for ; Mon, 30 Sep 2019 04:55:00 +0000 (UTC) Received: from VI1PR0802CA0019.eurprd08.prod.outlook.com (2603:10a6:800:aa::29) by VI1PR08MB3583.eurprd08.prod.outlook.com (2603:10a6:803:84::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.20; Mon, 30 Sep 2019 04:54:56 +0000 Received: from VE1EUR03FT041.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::209) by VI1PR0802CA0019.outlook.office365.com (2603:10a6:800:aa::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.17 via Frontend Transport; Mon, 30 Sep 2019 04:54:56 +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 VE1EUR03FT041.mail.protection.outlook.com (10.152.19.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.15 via Frontend Transport; Mon, 30 Sep 2019 04:54:53 +0000 Received: ("Tessian outbound 851a1162fca7:v33"); Mon, 30 Sep 2019 04:54:49 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 824b97fff89316d1 X-CR-MTA-TID: 64aa7808 Received: from d5dd76d7e6d0.2 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.12.58]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 6FE777CD-0CB5-4C4C-BDA6-25D9613B6C2E.1; Mon, 30 Sep 2019 04:54:43 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04lp2058.outbound.protection.outlook.com [104.47.12.58]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d5dd76d7e6d0.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Mon, 30 Sep 2019 04:54:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i8nuF3kg6g72EXC91iWZ7gG6ziPxNQdLCV9RWqoch+rSfoYp2v+EnHSJt+4JxkjDZ3ouE+LFtO3fiXCNOSsIMDQ9XO8IUfmblIGFJGNshZANzvCDd6Y4gMlGSLCxxalkATHuA4JAld7rjxCFpCDypslDLw6/uwHMvQ23RbmA9aik/shSl06dUjHclDPbydTLSqAYaFVH16PvQc9pQPhZy5E8sNrr7ZU1DUyrPIqUnP45GwYyzQuigvZm9iw5iaqzE+D3E0G+WSnl+6jkKGDgp1++BJf6t4wKEl6VU7HbJx8Uc0vVKNjRd+5aTSs7fA1pJ9PNfXyds4f+FrV/xHDM0Q== 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=ZvbEac7OETtKJD9fllmHTJ/Fl/DPCKR8vUreA20Jicw=; b=Ka7ivca9vb+82L612XlrH8c+B26at/6HKFb+1omtxZYykFlZZISKQm6pFV0CC8/Dv5MO5730u+rtIjgRqqqLY0i8LAfDW4XSLdUXGhsrPmSKkB99XqdfD2kPznlFPyh1dsoew9/0PsHb8TejzLHry1ZjY26zirNSi04A/qFEEWRZpBaq1e7Vhu9idBWFT6kVURUdM8VxwFKUsVTe+ZzfOdxSQdU+H/fB4Xs4Umzdq9RaS7NdwmL+3qA3aaO8QYMIP4/+NAJrp8wKuefxVJ7BJnP5YYqY37HH8xpCyNd339fFXEE8KjorjanK7XZQeStXHSGp1l3hmvWblL/rRbl18Q== 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 VE1PR08MB4671.eurprd08.prod.outlook.com (10.255.115.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.20; Mon, 30 Sep 2019 04:54:41 +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.2305.017; Mon, 30 Sep 2019 04:54:41 +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 2/3] drm/komeda: Add drm_ctm_to_coeffs() Thread-Topic: [PATCH 2/3] drm/komeda: Add drm_ctm_to_coeffs() Thread-Index: AQHVd0sr2eIkvH1CKkK4ZygjJg2yVg== Date: Mon, 30 Sep 2019 04:54:41 +0000 Message-ID: <20190930045408.8053-3-james.qian.wang@arm.com> References: <20190930045408.8053-1-james.qian.wang@arm.com> In-Reply-To: <20190930045408.8053-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: HK2PR03CA0066.apcprd03.prod.outlook.com (2603:1096:202:17::36) 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: bb4daf03-89ea-4e4b-68db-08d745625667 X-MS-Office365-Filtering-HT: Tenant X-MS-TrafficTypeDiagnostic: VE1PR08MB4671:|VE1PR08MB4671:|VI1PR08MB3583: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:3826;OLM:3826; x-forefront-prvs: 01762B0D64 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(39850400004)(396003)(366004)(376002)(346002)(136003)(189003)(199004)(25786009)(52116002)(55236004)(11346002)(50226002)(486006)(6506007)(8676002)(8936002)(6512007)(99286004)(102836004)(6116002)(6486002)(3846002)(1076003)(2906002)(81166006)(5660300002)(86362001)(2616005)(476003)(446003)(386003)(6436002)(76176011)(81156014)(186003)(54906003)(110136005)(26005)(316002)(14454004)(2201001)(478600001)(66066001)(66446008)(64756008)(66556008)(103116003)(66476007)(66946007)(2501003)(4326008)(36756003)(71200400001)(7736002)(71190400001)(305945005)(256004); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB4671; H:VE1PR08MB5006.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 6dBgWVlXMfRMwCCEFy6F9eSikyP7EJwgv5VvV/2Cbcod7A9KzusJ1nRYQLXZ8ZnU0cuJaBhbOUg51Lomb2jGGvoWDiHf1jKso8jFFchoOWRB87NLxNHObfRP1SrvCRSW4SgwNCipYQZCHl11J03gz/mVdGGHbQPT1sahUKv6jGhAt1iQuiwhF4Zxc+5ibYYQWiY4PLdGcW2V37n9Qe3f1GrGm0+/QskSCTv8xptzIdksqhjxuW657D15Q//zyG6e/nXAFAWS+gCxzKh/+G/fNjUkpZPMwenj+HILFDzLB11mxFOPksROyCXHG81pZ+yNz+71qwvyV8Of+PTHleuIlESCuodrVb9xytPYKN7gxslgXsm+Eg3Uc8t7uD1BRtYOmrYyYC51LMiRt2RkwFSp6o+zk/ORMqOYl46FHtwNpvY= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4671 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT041.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)(39850400004)(376002)(396003)(136003)(199004)(189003)(70586007)(476003)(63350400001)(14454004)(50466002)(11346002)(25786009)(446003)(2616005)(47776003)(336012)(356004)(26826003)(126002)(103116003)(66066001)(2501003)(478600001)(486006)(1076003)(23756003)(5660300002)(76130400001)(305945005)(7736002)(70206006)(81166006)(81156014)(6116002)(36756003)(316002)(8676002)(3846002)(36906005)(50226002)(8746002)(8936002)(26005)(76176011)(110136005)(54906003)(6486002)(99286004)(102836004)(22756006)(2906002)(386003)(6506007)(4326008)(2201001)(86362001)(6512007)(186003); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR08MB3583; 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: f0cd0d40-c547-484a-7e98-08d745624df2 NoDisclaimer: True X-Forefront-PRVS: 01762B0D64 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GGT9ug1C3fAf8BFRviQOKbWetgwe+lVY4cjYZ2nakfg7m6mtSSywGcFRmqth5wre8OY+ALF8w1Pu+dqB3cfOD/uboHwdiucqQrEcY7n6Evg9Ii1yg3F/KkPoUDv+8oJ7VtrZW9al1lagjIRdbw7tST5AXOP9BS7zC7UYB5YtyI2JI7UCr9bnNZPT1EXWAgfqcvU+CBZ4rMts7MC4CIdFpgcMb0gKQ9nBMpHH88qPoom0RtFe9dFwFFI1apoaTOFxInhkmp0FKPdhGpnBNgu4wZon3kQT9f6AdnmS5aSN83FT0FBLxUgdXLE+9SqQhiSXYr8+vzzKFBxtwgU9O/yt+sz90qmlNooUP9P5lPMfpSZ1dEeL4S55BqcfTXZ02gxF0altW4Z3mpLIzDDBXoVQtFZu+Wm/g5aKTTrF0oUImkM= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2019 04:54:53.9891 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bb4daf03-89ea-4e4b-68db-08d745625667 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: VI1PR08MB3583 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=ZvbEac7OETtKJD9fllmHTJ/Fl/DPCKR8vUreA20Jicw=; b=fKZfMyduqFWv/HNLuIlfp7fyuTxrhglD+scnYh0Pfvcj2RQBioz39GMqoZUoo2FmuayGrR4aTNz1A+VUDHB7F2UQQEj60NdVOmNSPDZfP1gRIJRagC3phMEgjzHKYLtVUbUw0d3ukQc0mBnrw4JqMWXTGD2sbLgWJZVp99ZWOyI= 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=ZvbEac7OETtKJD9fllmHTJ/Fl/DPCKR8vUreA20Jicw=; b=fKZfMyduqFWv/HNLuIlfp7fyuTxrhglD+scnYh0Pfvcj2RQBioz39GMqoZUoo2FmuayGrR4aTNz1A+VUDHB7F2UQQEj60NdVOmNSPDZfP1gRIJRagC3phMEgjzHKYLtVUbUw0d3ukQc0mBnrw4JqMWXTGD2sbLgWJZVp99ZWOyI= X-Mailman-Original-Authentication-Results: spf=temperror (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.freedesktop.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.freedesktop.org; dmarc=none action=none header.from=arm.com; X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nd , Ayan Halder , "Oscar Zhang \(Arm Technology China\)" , "Tiannan Zhu \(Arm Technology China\)" , Mihail Atanassov , "Jonathan Chai \(Arm Technology China\)" , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "Julien Yin \(Arm Technology China\)" , "Channing Chen \(Arm Technology China\)" , "james qian wang \(Arm Technology China\)" , "Yiqi Kang \(Arm Technology China\)" , "Thomas Sun \(Arm Technology China\)" , "Lowry Li \(Arm Technology China\)" , Ben Davis Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This function is used to convert drm_color_ctm S31.32 sign-magnitude value to komeda required Q2.12 2's complement Signed-off-by: james qian wang (Arm Technology China) --- .../arm/display/komeda/komeda_color_mgmt.c | 27 +++++++++++++++++++ .../arm/display/komeda/komeda_color_mgmt.h | 1 + 2 files changed, 28 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..c92c82eebddb 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,30 @@ 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)); } + +/* Convert from S31.32 sign-magnitude to HW Q2.12 2's complement */ +static s32 drm_ctm_s31_32_to_q2_12(u64 input) +{ + u64 mag = (input & ~BIT_ULL(63)) >> 20; + bool negative = !!(input & BIT_ULL(63)); + u32 val; + + /* the range of signed 2s complement is [-2^n, 2^n - 1] */ + val = clamp_val(mag, 0, negative ? BIT(14) : BIT(14) - 1); + + return negative ? 0 - val : val; +} + +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_ctm_s31_32_to_q2_12(ctm->matrix[i]); +} diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h index 08ab69281648..2f4668466112 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h +++ b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h @@ -18,6 +18,7 @@ #define KOMEDA_N_CTM_COEFFS 9 void drm_lut_to_fgamma_coeffs(struct drm_property_blob *lut_blob, u32 *coeffs); +void drm_ctm_to_coeffs(struct drm_property_blob *ctm_blob, u32 *coeffs); const s32 *komeda_select_yuv2rgb_coeffs(u32 color_encoding, u32 color_range); From patchwork Mon Sep 30 04:54:47 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: 11165995 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 F311B13BD for ; Mon, 30 Sep 2019 04:55:11 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DA201218AC for ; Mon, 30 Sep 2019 04:55:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DA201218AC 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 0D2896E338; Mon, 30 Sep 2019 04:55:11 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-ve1eur02on062b.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe06::62b]) by gabe.freedesktop.org (Postfix) with ESMTPS id E6A706E338 for ; Mon, 30 Sep 2019 04:55:08 +0000 (UTC) Received: from VI1PR08CA0258.eurprd08.prod.outlook.com (2603:10a6:803:dc::31) by AM0PR08MB4354.eurprd08.prod.outlook.com (2603:10a6:208:13e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.20; Mon, 30 Sep 2019 04:55:04 +0000 Received: from DB5EUR03FT061.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::205) by VI1PR08CA0258.outlook.office365.com (2603:10a6:803:dc::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.17 via Frontend Transport; Mon, 30 Sep 2019 04:55:04 +0000 Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT061.mail.protection.outlook.com (10.152.21.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.15 via Frontend Transport; Mon, 30 Sep 2019 04:55:02 +0000 Received: ("Tessian outbound 081de437afc7:v33"); Mon, 30 Sep 2019 04:54:55 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 49372420f580918c X-CR-MTA-TID: 64aa7808 Received: from 1a833b181f9a.2 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.12.58]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 3E05B2CF-92EB-4741-9304-3812FB11AC36.1; Mon, 30 Sep 2019 04:54:50 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04lp2058.outbound.protection.outlook.com [104.47.12.58]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 1a833b181f9a.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Mon, 30 Sep 2019 04:54:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PXXg5Aj4ydTNg8KZOMRJpf9t3WHJIaLbF1ObLa5fDP7ju6V+vMH/woTnbDyZiC8qDY7GvJ06aUEp5A1o+Oc2TMmnfGD1BRula2uf7zr9gJWw6zuUO5JTGZPRBEa73NN73SZ3bFUoJIJf99RAt7iTPKFuR9Yp9rdSut2jYDgaqaYKonyP/zNr7QyE57mRHjmuEK4DPtrRDM+SzaIh5cxPZexHhBv5sB9QM3uFgAz40H8K4f6oad771IRkCmGhp0Nvnu9FqPdDuE9gVDnmorta0zMX76O53C6f7xhiaUo6/+FfZbscpOlckWXEc5XB6fp9MSJaZZsHqKWXU7Kyjbh1pg== 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=IpK8QoVPwkG2dNMzEgnGMuEmaJOfHjkcn0pIVo7kdrg=; b=CQEJ9/b7oyiZJ5hpfFRsQi4ViT4bmcAGCgtk/iWa8Tk/k3RjFNY5NaEkt6PUhFA7WoJJvnSHPCQySyvIofPXxOhdamaSvbvoTWARVhv7yQ8PQvLK21bPfMT5yL8+ey5IcJRtThzgnMvxcnaL9tsKnvz6DqrK/BHNjDBPkHx7JW6/Grtupz9tsj7RRlxVd6kKnXEjTOYM4aQCvMQNlEG9gB6n5tuChJcrQCAZOIEvmCmNzIg9LSYUawmqP5tZU9fSvVtwfH1T4/fxw9duFhEZ6n0JTK9KEQJaeU4tJkIVVq65Qec+kd5c7nFylYqAXpqdtRP2TZ6ygferaA+1DKo7LA== 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 VE1PR08MB4671.eurprd08.prod.outlook.com (10.255.115.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.20; Mon, 30 Sep 2019 04:54:48 +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.2305.017; Mon, 30 Sep 2019 04:54:48 +0000 From: "james qian wang (Arm Technology China)" To: Liviu Dudau , "airlied@linux.ie" , Brian Starkey , "maarten.lankhorst@linux.intel.com" , "sean@poorly.run" Subject: [PATCH 3/3] drm/komeda: Adds gamma and color-transform support for DOU-IPS Thread-Topic: [PATCH 3/3] drm/komeda: Adds gamma and color-transform support for DOU-IPS Thread-Index: AQHVd0svDPRxDROFCUC/H9BR83IxGw== Date: Mon, 30 Sep 2019 04:54:47 +0000 Message-ID: <20190930045408.8053-4-james.qian.wang@arm.com> References: <20190930045408.8053-1-james.qian.wang@arm.com> In-Reply-To: <20190930045408.8053-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: HK2PR03CA0066.apcprd03.prod.outlook.com (2603:1096:202:17::36) 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: 3e4d56d4-7621-4712-4d07-08d745625a8a X-MS-Office365-Filtering-HT: Tenant X-MS-TrafficTypeDiagnostic: VE1PR08MB4671:|VE1PR08MB4671:|AM0PR08MB4354: 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: 01762B0D64 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(39850400004)(396003)(366004)(376002)(346002)(136003)(189003)(199004)(25786009)(52116002)(55236004)(11346002)(50226002)(486006)(6506007)(8676002)(8936002)(6512007)(99286004)(102836004)(6116002)(6486002)(3846002)(1076003)(2906002)(81166006)(5660300002)(86362001)(2616005)(476003)(446003)(386003)(6436002)(76176011)(81156014)(186003)(54906003)(110136005)(26005)(316002)(14454004)(2201001)(478600001)(66066001)(66446008)(64756008)(66556008)(103116003)(66476007)(66946007)(2501003)(4326008)(36756003)(71200400001)(14444005)(7736002)(71190400001)(305945005)(256004); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB4671; H:VE1PR08MB5006.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: oqyqqcr56s1qtHTfzZE8GuHOFdkB5o9iP9mUEhbm1ywYUX4XtznzDABwHvy1uDH8KKSJ+oSQKdrAJXnXcVUh1Fma/UxJGLB8XJyFdm7ngtudt2zw2wf84Dw+IywhCsyOC2a2UFOGI9hflpptIiF/pekY4XcEHb7FBJvAb7J3juGPadcjcGXG9rOts8QRTOU9LyeKIDd2U9m3MFNotk6jlU5eyPxc2s0+GtdgqJpiuYUJfIMBxD73vzGcImvywpGMHIkel3VG10VeM4pxYZCCC7zfD5fOnULfdyRoD3nXTSzp+/nqS8GHAdAAU7AnKfRS0u+ksmASecy1jgKmIbqs3QKL3vjc3y3VWo0CQwEcFmunGXT9Yk0eNtXQk5tYdaDtq6jRUNxsiMiN+ZY6QLnFQx/sYqt//jh5u7m6QxJCpTU= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4671 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT061.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)(39850400004)(346002)(396003)(136003)(189003)(199004)(76176011)(2906002)(26005)(70586007)(54906003)(6116002)(386003)(6506007)(70206006)(6512007)(102836004)(66066001)(3846002)(47776003)(76130400001)(99286004)(478600001)(26826003)(6486002)(25786009)(14454004)(316002)(110136005)(186003)(103116003)(50466002)(81156014)(81166006)(4326008)(14444005)(2201001)(8936002)(486006)(126002)(86362001)(63350400001)(50226002)(22756006)(1076003)(305945005)(8746002)(2501003)(5660300002)(7736002)(8676002)(446003)(11346002)(2616005)(356004)(36756003)(336012)(23756003)(476003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR08MB4354; 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: cf3335d8-2038-4123-9958-08d7456251bd NoDisclaimer: True X-Forefront-PRVS: 01762B0D64 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1CMWBRLDwfXBWqZ7gtud56gE/mSJHYZELkc+cn/jzV/qhlaHb6uiSm3DpK/K4nOOEMF5/AI8iXX25dUfg/pfDTMQ78hc4TZ6EYZbfI4l+mdRd7wTmLo4vbaNYxmbY/O3mpFKPX7Ynfk41RF/fhHiGUDjjNqpMcmGjBnfAkwclfVBVjGd5/mjMZIjteFhyNmq0DhY3aWe70wIfI3hpWRcBf0sTWyFODbpXOYbJESPPqdlQhf2DbjvRN3NmwBc0/9DxF6x0JuJsW0aW5lKYwNO7jCGjCQuYZ8AcZfWSqxkz5w6845+Pf40M2bHbAE1tXwLM7Ele3vjKucozQOHOTPtYUGUT0OrUDGy0Jmo/GiOlWdGWb2NIK/4tO0lXxfI0iyyfiONI+8Fzjia3cENWcCj4MukxH8jUEiFr3ORipfaUxw= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2019 04:55:02.3848 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3e4d56d4-7621-4712-4d07-08d745625a8a 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: AM0PR08MB4354 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=IpK8QoVPwkG2dNMzEgnGMuEmaJOfHjkcn0pIVo7kdrg=; b=IyLXX6vFn7bz19n3soGni8pfNpBphGEszKMwbKTkhxq3zEPmXnraaED74gGn00yklRUksq0CC6Z1JRvAcBKQ8ZWTDWp3cPAXSEoizoa3GjlfiufKxoSDZvI+2CgGN/B8JB5JwY4boWg3rb81m3jXrKgqVg4DXdyuTUMhVcP2xhk= 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=IpK8QoVPwkG2dNMzEgnGMuEmaJOfHjkcn0pIVo7kdrg=; b=IyLXX6vFn7bz19n3soGni8pfNpBphGEszKMwbKTkhxq3zEPmXnraaED74gGn00yklRUksq0CC6Z1JRvAcBKQ8ZWTDWp3cPAXSEoizoa3GjlfiufKxoSDZvI+2CgGN/B8JB5JwY4boWg3rb81m3jXrKgqVg4DXdyuTUMhVcP2xhk= 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 9ca5dbfd0723..33f7362dcc6e 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c @@ -588,6 +588,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 8401cc0cdfe7..21a50e8ce0b7 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);