From patchwork Mon Feb 26 21:10:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13572882 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 09F3DC5478C for ; Mon, 26 Feb 2024 21:13:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 182D510F26B; Mon, 26 Feb 2024 21:11:46 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="DBdQAyiI"; dkim-atps=neutral Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by gabe.freedesktop.org (Postfix) with ESMTPS id EFEE210F24A; Mon, 26 Feb 2024 21:11:34 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oDjQaUdBHdcrD/a3h7zTcUyMbJPtI8kg6i74OGz6mr27PTvQrrojuan8MQ60ihtdWFYJJK5eAqfBwF09+DVpCIlEtAEpNNxU0WumhqBKVBZBpTphqlIQnsANQbgcDQnXZy4KP//q3c/+YwPYNRPEtFsZEQZO5W8gYkwE52l9CLnB0iVTyZiSvXfiV3SKCR35XaYjqLDtPCdW4/Kzqwo9p59LGZGet/+pyadt5+o5Su1dOhW83ZqDdbwUMocqBuFJL4WZq7foBaDQDRSxvzbTQCTHeu1wpjyuuPIdWVy1s4XcK5o8KWHYkyCOKvoqbfgjGIANH0b+O9ISwRy6LJplQg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yN21Hub7LJTInNzdyUM1Tj23zhaFQ4q5seCNm12XiYE=; b=EGJKEAI1IEnHG5ZDbtGeM6G8ic442S2LZD3d5lDlwwp6oHOrEaaI0tEJ5Fp5jd5DMzdNbaBSV1ZLt/IsTVN6F4crocVbO3Kf4M9aY83bQN0HgezRtdPjl7ALKcmJZCwDWRd8pNCHFXcfqXnxQ1VRgsFLM9S1jgPB1Akz0AGfKitLFa3yxL6MWY5v25eF2K+oECsY86Aan0f9UN77oiXy8mluLHj9T+aH6IJoUxHGxibeKDUSr1uVNEIwr2joJGDax4HmWjf9/dDIJI/gdZNVrtbcUcCTF89y2ZW0ukp6z7y8B9x7lUL5aDxwAaxUmufzsXKShLFORkXNTsLYckqCKw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yN21Hub7LJTInNzdyUM1Tj23zhaFQ4q5seCNm12XiYE=; b=DBdQAyiIO4MGnrHP+E/T2JQkvF8Qtms/1ctXC981Nv33Tm1h8txNLpEr5MIJrnooKyq2jdv2MrlKUZ7eNOIYry8AFoz9uMwy0ZmayNKfgx+w73TX7Acc3sR5l+EP15f+MVOvVayyNE1pM1nhMVG+B8M+cygv8npFxMHTgj+XCMo= Received: from CH0PR04CA0088.namprd04.prod.outlook.com (2603:10b6:610:74::33) by DS0PR12MB7728.namprd12.prod.outlook.com (2603:10b6:8:13a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.34; Mon, 26 Feb 2024 21:11:32 +0000 Received: from DS2PEPF0000343D.namprd02.prod.outlook.com (2603:10b6:610:74:cafe::9) by CH0PR04CA0088.outlook.office365.com (2603:10b6:610:74::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.49 via Frontend Transport; Mon, 26 Feb 2024 21:11:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by DS2PEPF0000343D.mail.protection.outlook.com (10.167.18.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7292.25 via Frontend Transport; Mon, 26 Feb 2024 21:11:28 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 26 Feb 2024 15:11:27 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 26 Feb 2024 13:11:26 -0800 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Mon, 26 Feb 2024 15:11:26 -0600 From: Harry Wentland To: , CC: , Alex Hung , Harry Wentland Subject: [RFC PATCH v4 33/42] drm/amd/display: Add support for sRGB EOTF in BLND block Date: Mon, 26 Feb 2024 16:10:47 -0500 Message-ID: <20240226211100.100108-34-harry.wentland@amd.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240226211100.100108-1-harry.wentland@amd.com> References: <20240226211100.100108-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343D:EE_|DS0PR12MB7728:EE_ X-MS-Office365-Filtering-Correlation-Id: f7fa581b-a04b-4194-5443-08dc370f7f89 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R5P8S8EPEFsnje2J7AVNRotjTBGsHBbb6oun/LIGAI4ImRZGLh5e3Xld2HKkVce4k0cZ3eYGxeC4Put0j3owv9L8FOIrD1yh30XA4dsq9Cu5vIsVHoWhSv+1+d9uMPNwq00zmqsaL5ao+WRpCxaImFshcAjXS4u6Q4vhbnkcBcMj3zyoF2AS5U+dRqGXhthrEUSywM3IIXJkSSx2yj//uKnx+rUe/ZBufiGLjufhqg65XDyN815Fp5I4vL/Rjfp1g7Nut4PtwFLKeuQ8o8dDqYTTGXlL61c/OcH9ihvvNT8c227jrDZS/z5pp+L/T174RZkHCcuI421+JUh6QsC6OPzF5/367rsZcTg+UXoqu5C4XuM/YiGnTtJP6bMckBkWwqnQrYFQa4IFFIKryPYXLcI7hPbciIgWbKAh1kyjN2GUFAAXvwkMwHjgW3rfdTkmpTd3CcixUvEO1U8y5QIRwTAs5m6y4pLcyeSGnNyyajmUQJUQSKyRu15okopXz7xkK+vyyvrDtNrXrwhloIo9b45b3Fj4RSPgHsCBkUyQVIqOPfs93o6CcvQXkdf/vlFzJ0pl2S1rkmW2f6ar1PzKXaThc0ln0vrh8O/4mQeBbDil9RvJQXHKIKhz9GzpcxKWviOtjFcLaYg2svrEGguDaSs7VuO7znnQ3Lxr7XIIRVIlOsvtva0FN+vfuGbiYsFC7xQ1kffibr1n/Cv8EoH5MNSH3sipTbvL4C2/W+ilZNFqlExrxhUE6eClpSPo3eVd X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(36860700004); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Feb 2024 21:11:28.2573 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f7fa581b-a04b-4194-5443-08dc370f7f89 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF0000343D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7728 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Alex Hung Expose a 3rd 1D curve colorop, with support for DRM_COLOROP_1D_CURVE_SRGB_EOTF and program the BLND block to perform the sRGB transform when the colorop is not in bypass With this change the following IGT test passes: kms_colorop --run plane-XR30-XR30-srgb_eotf-srgb_inv_eotf-srgb_eotf The color pipeline now consists of the following colorops: 1. 1D curve colorop w/ sRGB EOTF support 2. 1D curve colorop w/ sRGB Inverse EOTF support 3. 1D curve colorop w/ sRGB EOTF support Signed-off-by: Alex Hung Signed-off-by: Harry Wentland Co-developed-by: Harry Wentland --- .../amd/display/amdgpu_dm/amdgpu_dm_color.c | 77 +++++++++++++++++++ .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 18 +++++ .../amd/display/amdgpu_dm/amdgpu_dm_colorop.h | 1 + 3 files changed, 96 insertions(+) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c index 8788cfd26abd..3e3ae2b58b06 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c @@ -1267,6 +1267,72 @@ __set_dm_plane_colorop_shaper(struct drm_plane_state *plane_state, return __set_colorop_in_shaper_1d_curve(dc_plane_state, colorop_state); } + +static int +__set_colorop_1d_curve_blend_tf_lut(struct dc_plane_state *dc_plane_state, + struct drm_colorop_state *colorop_state) +{ + + struct dc_transfer_func *tf = dc_plane_state->blend_tf; + struct drm_colorop *colorop = colorop_state->colorop; + struct drm_device *drm = colorop->dev; + const struct drm_color_lut *blend_lut; + uint32_t blend_size; + + if (colorop->type != DRM_COLOROP_1D_CURVE && + colorop_state->curve_1d_type != DRM_COLOROP_1D_CURVE_SRGB_EOTF) + return -EINVAL; + + if (colorop_state->bypass) { + tf->type = TF_TYPE_BYPASS; + tf->tf = TRANSFER_FUNCTION_LINEAR; + return 0; + } + + drm_dbg(drm, "Blend colorop with ID: %d\n", colorop->base.id); + + if (colorop->type == DRM_COLOROP_1D_CURVE) { + tf->type = TF_TYPE_DISTRIBUTED_POINTS; + tf->tf = amdgpu_colorop_tf_to_dc_tf(colorop_state->curve_1d_type); + tf->sdr_ref_white_level = SDR_WHITE_LEVEL_INIT_VALUE; + return __set_input_tf(NULL, tf, blend_lut, blend_size); + } + + return -EINVAL; +} + +static int +__set_dm_plane_colorop_blend(struct drm_plane_state *plane_state, + struct dc_plane_state *dc_plane_state, + struct drm_colorop *colorop) +{ + struct drm_colorop *old_colorop; + struct drm_colorop_state *colorop_state = NULL, *new_colorop_state; + struct drm_atomic_state *state = plane_state->state; + int i = 0; + + old_colorop = colorop; + + /* 3nd op: 1d curve - blend */ + for_each_new_colorop_in_state(state, colorop, new_colorop_state, i) { + if (new_colorop_state->colorop == old_colorop && + new_colorop_state->curve_1d_type == DRM_COLOROP_1D_CURVE_SRGB_EOTF) { + colorop_state = new_colorop_state; + break; + } + + if (new_colorop_state->colorop == old_colorop) { + colorop_state = new_colorop_state; + break; + } + } + + if (!colorop_state) + return -EINVAL; + + return __set_colorop_1d_curve_blend_tf_lut(dc_plane_state, colorop_state); +} + static int amdgpu_dm_plane_set_color_properties(struct drm_plane_state *plane_state, struct dc_plane_state *dc_plane_state) @@ -1345,6 +1411,17 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state, if (ret) return ret; + /* 1D Curve - BLND TF */ + colorop = colorop->next; + if (!colorop) { + drm_dbg(dev, "no Blend TF colorop found\n"); + return -EINVAL; + } + + ret = __set_dm_plane_colorop_blend(plane_state, dc_plane_state, colorop); + if (ret) + return ret; + return 0; } diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c index 0d1626abf577..449a2ad6a184 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c @@ -37,6 +37,9 @@ const u64 amdgpu_dm_supported_degam_tfs = const u64 amdgpu_dm_supported_shaper_tfs = BIT(DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF); +const u64 amdgpu_dm_supported_blnd_tfs = + BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF); + int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_prop_enum_list *list) { struct drm_colorop *op, *prev_op; @@ -72,5 +75,20 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr drm_colorop_set_next_property(prev_op, op); + prev_op = op; + + /* 1D curve - BLND TF */ + op = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL); + if (!op) { + DRM_ERROR("KMS: Failed to allocate colorop\n"); + return -ENOMEM; + } + + ret = drm_colorop_curve_1d_init(dev, op, plane, amdgpu_dm_supported_blnd_tfs); + if (ret) + return ret; + + drm_colorop_set_next_property(prev_op, op); + return 0; } \ No newline at end of file diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.h index c4b1b187e9bf..a342c096f406 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.h +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.h @@ -29,6 +29,7 @@ extern const u64 amdgpu_dm_supported_degam_tfs; extern const u64 amdgpu_dm_supported_shaper_tfs; +extern const u64 amdgpu_dm_supported_blnd_tfs; int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_prop_enum_list *list);