From patchwork Mon Oct 21 07:23:12 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: 11201461 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 E49131515 for ; Mon, 21 Oct 2019 07:23:35 +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 C5C392089C for ; Mon, 21 Oct 2019 07:23:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C5C392089C 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 10A9C899E9; Mon, 21 Oct 2019 07:23:35 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80074.outbound.protection.outlook.com [40.107.8.74]) by gabe.freedesktop.org (Postfix) with ESMTPS id ED4CD899E9 for ; Mon, 21 Oct 2019 07:23:33 +0000 (UTC) Received: from VI1PR08CA0232.eurprd08.prod.outlook.com (2603:10a6:802:15::41) by DB8PR08MB5084.eurprd08.prod.outlook.com (2603:10a6:10:38::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.18; Mon, 21 Oct 2019 07:23:29 +0000 Received: from AM5EUR03FT034.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::203) by VI1PR08CA0232.outlook.office365.com (2603:10a6:802:15::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2367.22 via Frontend Transport; Mon, 21 Oct 2019 07:23:29 +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 AM5EUR03FT034.mail.protection.outlook.com (10.152.16.81) 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, 21 Oct 2019 07:23:27 +0000 Received: ("Tessian outbound 0cf06bf5c60e:v33"); Mon, 21 Oct 2019 07:23:21 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 7eafda87506444b9 X-CR-MTA-TID: 64aa7808 Received: from 73989a51e813.2 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.13.50]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id EC0A171C-D314-4E7B-89FE-5D5D8F8BAB27.1; Mon, 21 Oct 2019 07:23:16 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04lp2050.outbound.protection.outlook.com [104.47.13.50]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 73989a51e813.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 21 Oct 2019 07:23:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HyxXP9X7LBRNJmytOUaju3IBymj10TS9WC5AGf8duQRwsguJ7f22730RsykTBsPzgM3X5Rp9It3b3dvJJomksjcRbyiuGYDGD96jIGcEzA5HjgWPz2LuHsTvkxzLdkRQpKVo520xELxQmeRyj0xf907ekKFbvAfnpysM0XMUMfMHcvt24tcFj13fKsHOQhbcxMVazA9Szt6p9yQhCGPQcgc9c2lD0AOp8+KfCx2eY0d55WEbln1UYNEcvX2Vqae/RrFg2fl/248mk7hfeib7Oz9qh0ab+T+UMgyie+xYNlqv/OHvme8Aj3ulrTQMWNr1gRXM8VyA+c1Ly7py7vM1kA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Dwl4JXh3gudDNqqnWSO4qmhHyZFD7hivyUxQxR0plGY=; b=bbcrNtHVcGVsvNKohsG+dSik7Nfojqr06gbZpzk5DxLEwqhGK4vOH5zkh+hB73kHUdwJTBSkMoOB9noIozFaugmn9tc7MtVk5IPV8ONINfr7Ip9FpvAMoHKuZdbibWZNa5plhj+9dLHJUdtm5En+7rCAKGq5Tw2oUy/+JttHqiiP8n5fEm+N2ofEibVEw3RYDVJIbtosYtu0nGxCqzMAlRKKwIK07cq0iLRn8/0f1WRdDSrsaWIlEl5tBI02Qs2mf27RG8I1TcUkPW2qDt6BLjIErowGHqva2ZPvRW9dk2EAF55uZ34zh8d3DFFJQvvhpBpPHzY4iI3SbNMUjezIXA== 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 VE1PR08MB4831.eurprd08.prod.outlook.com (10.255.115.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.21; Mon, 21 Oct 2019 07:23:12 +0000 Received: from VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::40ed:7ed3:90cf:ece5]) by VE1PR08MB5006.eurprd08.prod.outlook.com ([fe80::40ed:7ed3:90cf:ece5%3]) with mapi id 15.20.2347.028; Mon, 21 Oct 2019 07:23:12 +0000 From: "james qian wang (Arm Technology China)" To: Liviu Dudau , "airlied@linux.ie" , Brian Starkey , "maarten.lankhorst@linux.intel.com" , "sean@poorly.run" , "imirkin@alum.mit.edu" Subject: [PATCH v6 2/4] drm/komeda: Add drm_lut_to_fgamma_coeffs() Thread-Topic: [PATCH v6 2/4] drm/komeda: Add drm_lut_to_fgamma_coeffs() Thread-Index: AQHVh+BlOncB8sw6wk+4WVNM6w1Zjg== Date: Mon, 21 Oct 2019 07:23:12 +0000 Message-ID: <20191021072215.3993-3-james.qian.wang@arm.com> References: <20191021072215.3993-1-james.qian.wang@arm.com> In-Reply-To: <20191021072215.3993-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: HK2PR0401CA0019.apcprd04.prod.outlook.com (2603:1096:202:2::29) 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: 2572eb8f-7889-47a1-6354-08d755f7915d X-MS-Office365-Filtering-HT: Tenant X-MS-TrafficTypeDiagnostic: VE1PR08MB4831:|VE1PR08MB4831:|DB8PR08MB5084: 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: 0197AFBD92 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(346002)(366004)(39850400004)(396003)(136003)(376002)(199004)(189003)(110136005)(6506007)(6486002)(386003)(66066001)(4326008)(8676002)(66946007)(54906003)(99286004)(103116003)(36756003)(6512007)(6436002)(66446008)(64756008)(66556008)(66476007)(55236004)(2171002)(102836004)(2501003)(26005)(14454004)(186003)(81156014)(81166006)(2201001)(478600001)(11346002)(446003)(316002)(2906002)(7736002)(86362001)(71190400001)(71200400001)(256004)(6116002)(25786009)(305945005)(14444005)(486006)(3846002)(76176011)(52116002)(5660300002)(8936002)(2616005)(476003)(1076003)(50226002); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB4831; 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: ALri2EBbuhxCABmXnTVF9PhiSWmGD8ZwycnPKPfflyrPpuxaAalzosPy1riG5duGdRQprhIJ+vDhKgO2WxNa/A6nOAZIxjvvq2b1mmu9Fmia/pCGm20mioBLWHnhOz8M9fzzLpiO5j1Si6aPqMfldZqNqvltC+JwW5soYSy8i+48ocLdC9cKr2Ocdu91FBjCQzwwnKu3bv/O2/ejyuyIBhVqBweJIT13qLbr+I4Wz8HLfBI6dQBxUEEc382lnFlE9P5pChPtofwyfGprnJRWO7rE5dGq4jWhEpu8ZEcR2O9y+TMlbcWXK2E0rU3eIzB51hhm7mLdfWAoRhVImaSj9LBnyFXzc7GQTJkPYzr7+xJZE7VqQR+hX3Tcb9OqnOTL+4RXq+8T7kI4s9lO1IrHECV86sKMWIPNc6IVonKXKb0= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4831 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=james.qian.wang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT034.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; IPV:CAL; SCL:-1; CTRY:IE; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(376002)(396003)(346002)(39860400002)(136003)(199004)(189003)(36756003)(6486002)(86362001)(5660300002)(2906002)(70206006)(4326008)(2171002)(50466002)(6512007)(3846002)(6116002)(66066001)(2501003)(2201001)(76130400001)(1076003)(316002)(70586007)(36906005)(47776003)(14444005)(2616005)(476003)(23756003)(356004)(50226002)(22756006)(26005)(110136005)(11346002)(126002)(478600001)(446003)(8746002)(7736002)(54906003)(305945005)(25786009)(386003)(103116003)(6506007)(486006)(99286004)(102836004)(186003)(26826003)(81166006)(8936002)(8676002)(14454004)(336012)(81156014)(63350400001)(76176011); DIR:OUT; SFP:1101; SCL:1; SRVR:DB8PR08MB5084; 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: 645e2568-bbdd-49cf-32cf-08d755f787ed NoDisclaimer: True X-Forefront-PRVS: 0197AFBD92 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3gTffOL44Luu5nCIkEnuERgghE5qW9oAv7KVWIEaHYegsOYclSr3t0XPsRXeUXSellvb9RUgPM51UezKLQKce12hjY6wFBT6zpIEi0WFPwOhDkbbRvVwSCalWqhfpxxOadtYnz/6tCE5gz9brW91TahW/HAJcb605sNTkmo1BzWWeXMhj+BMCGx/YZYrpkjOJUp2H6htW2kfVI9wZY31yyuK4ThPRw+cGqLc5BoJekuoBJRHCJ8EDcGyZezJH5yMW6IZkjaaCY6W7KRqmKdM+naAcz7L/zeJ5EZDMrE+5fWrMRPStWvHvoOyZzypvheuQ1y8lkvv+BZbgevfm3Cq+c9u+fzyWAzctVHpcZpyTZebhc/N+vM223RwpDgkXemItcXKq/EbpQIXswxRlbqTiX+OQwGz+U5ThLIBDqi6V/EsTYbcxRU4cKkBBa79EJGY X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2019 07:23:27.9773 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2572eb8f-7889-47a1-6354-08d755f7915d 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: DB8PR08MB5084 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Dwl4JXh3gudDNqqnWSO4qmhHyZFD7hivyUxQxR0plGY=; b=k1Gi4kU6Af9s09nSoybt04gZWl4g5NNZDHuFxLt0/evWrL+fxBYjm7lWLHG31DxljzVFe/ozdfYqQY2eX5E44iLIp2rDeK4OKtmuJIphqqVtivk0XOWzCVrKtcF3JiyCISraStgaQ7Nn5OV1YOJ3jjQt5sknhDz2zynzeTO+YNk= X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Dwl4JXh3gudDNqqnWSO4qmhHyZFD7hivyUxQxR0plGY=; b=k1Gi4kU6Af9s09nSoybt04gZWl4g5NNZDHuFxLt0/evWrL+fxBYjm7lWLHG31DxljzVFe/ozdfYqQY2eX5E44iLIp2rDeK4OKtmuJIphqqVtivk0XOWzCVrKtcF3JiyCISraStgaQ7Nn5OV1YOJ3jjQt5sknhDz2zynzeTO+YNk= 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 lut to komeda HW required curve coeffs values. Signed-off-by: james qian wang (Arm Technology China) Reviewed-by: Mihail Atanassov --- .../arm/display/komeda/komeda_color_mgmt.c | 52 +++++++++++++++++++ .../arm/display/komeda/komeda_color_mgmt.h | 9 +++- 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c index 9d14a92dbb17..c180ce70c26c 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c @@ -65,3 +65,55 @@ const s32 *komeda_select_yuv2rgb_coeffs(u32 color_encoding, u32 color_range) return coeffs; } + +struct gamma_curve_sector { + u32 boundary_start; + u32 num_of_segments; + u32 segment_width; +}; + +struct gamma_curve_segment { + u32 start; + u32 end; +}; + +static struct gamma_curve_sector sector_tbl[] = { + { 0, 4, 4 }, + { 16, 4, 4 }, + { 32, 4, 8 }, + { 64, 4, 16 }, + { 128, 4, 32 }, + { 256, 4, 64 }, + { 512, 16, 32 }, + { 1024, 24, 128 }, +}; + +static void +drm_lut_to_coeffs(struct drm_property_blob *lut_blob, u32 *coeffs, + struct gamma_curve_sector *sector_tbl, u32 num_sectors) +{ + struct drm_color_lut *lut; + u32 i, j, in, num = 0; + + if (!lut_blob) + return; + + lut = lut_blob->data; + + for (i = 0; i < num_sectors; i++) { + for (j = 0; j < sector_tbl[i].num_of_segments; j++) { + in = sector_tbl[i].boundary_start + + j * sector_tbl[i].segment_width; + + coeffs[num++] = drm_color_lut_extract(lut[in].red, + KOMEDA_COLOR_PRECISION); + } + } + + coeffs[num] = BIT(KOMEDA_COLOR_PRECISION); +} + +void drm_lut_to_fgamma_coeffs(struct drm_property_blob *lut_blob, u32 *coeffs) +{ + drm_lut_to_coeffs(lut_blob, coeffs, sector_tbl, ARRAY_SIZE(sector_tbl)); +} diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h index a2df218f58e7..08ab69281648 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h +++ b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h @@ -11,7 +11,14 @@ #include #define KOMEDA_N_YUV2RGB_COEFFS 12 +#define KOMEDA_N_RGB2YUV_COEFFS 12 +#define KOMEDA_COLOR_PRECISION 12 +#define KOMEDA_N_GAMMA_COEFFS 65 +#define KOMEDA_COLOR_LUT_SIZE BIT(KOMEDA_COLOR_PRECISION) +#define KOMEDA_N_CTM_COEFFS 9 + +void drm_lut_to_fgamma_coeffs(struct drm_property_blob *lut_blob, u32 *coeffs); const s32 *komeda_select_yuv2rgb_coeffs(u32 color_encoding, u32 color_range); -#endif +#endif /*_KOMEDA_COLOR_MGMT_H_*/