From patchwork Thu Oct 3 20:00:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821502 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 18E3CCF34C4 for ; Thu, 3 Oct 2024 20:02:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5C3C610E8F3; Thu, 3 Oct 2024 20:01:49 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="bBZKEjJm"; dkim-atps=neutral Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2056.outbound.protection.outlook.com [40.107.92.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5835610E912; Thu, 3 Oct 2024 20:01:45 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=W3RLDsElmYMAbplS2eIuOS1pdhEFI4TNwHM+nh8it3xoBDyScR1bI0e/8Qussp1NMgkZaEfwhgZTBu+pIf/koTQXJrt3dHXfhyMCpHWg7DEJSMQzu0+MZfH8Df7E9XG1Y7/GWR76boXPMyZHREc0giA4IOlejZkq2xCmS8DJlUA49fTfQzJp3GWjZCy2yuSwS6fdZURub/P1qNVub8wwtUSd9ecRpSkclsJVnkT2VOEyJToVWaBnTMGUvgAX254Dxmt1+NSG1w+URSBU5BghDEaGKMdnKwAoOXq7ec1Je52F+Tddm+4M5TfaQ0uljcubxwdnJdSrRLtL+oACK/NrSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=6WIRcrG8jXQrlSzQktHMP2dWxS1Vvi22DWyvKMIVAGI=; b=yRoyEf6sZQae76wY8qxoDaJnWrtN3QBAzTKxgU6hR9M9ytTm7FPHUfwZs7MVyC8NJ6LXj1homffzQQ/tORCQMk4MWZWcZCt0Ey9mBd46KuUTpq5F3VAOvMMPaRj7nZaO5jUnoc4LsMixETaEjk9zsHh1H9lXorfGXhGCVRkWzq30QU/B8Xo/exXU6dI5jgonW7vqwjK1VxGxoZik8cRPftlG2vf4cbaKz5RK+uBKW6lsitvCQJzlbu07puQyz8c0iZgnKDz0cs+9GjNbJBHY/uZCKOts1eFusqlrNaFaOcUrxO2fEKZ4wiZ49sZMwAUeRW2roYkVjHR6dS4VEQDSyA== 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=6WIRcrG8jXQrlSzQktHMP2dWxS1Vvi22DWyvKMIVAGI=; b=bBZKEjJmlittVvsdoKAwBlPZlYt49lWzJaYou1ItTDYEMdUb178s+SXo01wrWcYc3EFVn9aD0NfVJXKlx7wu0DGF9nUCZIR/0cVoMmdc2ta7ABvXX6gab9SflclplHWyTxbmtJh6TqSp0BfcB5+cphL1rv7L/sqzGesegqK6sJU= Received: from CH2PR14CA0047.namprd14.prod.outlook.com (2603:10b6:610:56::27) by CH3PR12MB8329.namprd12.prod.outlook.com (2603:10b6:610:12e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18; Thu, 3 Oct 2024 20:01:40 +0000 Received: from DS2PEPF0000343E.namprd02.prod.outlook.com (2603:10b6:610:56:cafe::e2) by CH2PR14CA0047.outlook.office365.com (2603:10b6:610:56::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:01:40 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS2PEPF0000343E.mail.protection.outlook.com (10.167.18.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:40 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:33 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:33 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:32 -0500 From: Harry Wentland To: , CC: , Harry Wentland Subject: [PATCH v6 01/44] drm: Add helper for conversion from signed-magnitude Date: Thu, 3 Oct 2024 16:00:43 -0400 Message-ID: <20241003200129.1732122-2-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB05.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343E:EE_|CH3PR12MB8329:EE_ X-MS-Office365-Filtering-Correlation-Id: 35db2853-0978-428f-491b-08dce3e63267 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: GkFyW05V+T1Dw+D5AtFu+4HqqP8/gmWU+A8oYblKppGJ2JznWfFMINUV6QjbTZelVnfLRS5Vzjm5Ry7dRG5h8/eBCkzrwVIANbN4642OJTLqVkIKgzz/ClDNlFI5gWUSJC1GiUTNXfrkOSoCd1zBok62ZujjrfULVawZ2L3oBo4l6Ss8Rd/GJrnk4pAWIbr4MMmvMeAfV23GQHXHXhXZVpa+eQhhnql26tEcy2Cb9YdNoZP65RieZROMwwGWkSVLYOpqBzR8tRpFjOAqMNQiis94twUre1KduXfrQxiAqV2xMSeD7iNK644DsChUOSKzrQciQx7iPJg5zdmYlQIAwcElcVeYE42oH7nerNyNWnJJLVq9wElEAQ6Qtb6Pwv+e+FRie4JuoISEZfD73TaR2AjexrB//u6ISrFycKfe9E/P2szWNv6Rx3y5yPNtu8ORTZS3I7JqAi1w3K39iAa0b1oSQNnfwBncsV96GYchHwLppT/OHqfhrzKHKeUVyMal9Ys91FOLTeB+SW8VlEZUcvfeOVf6rWw2uN0Y6hWiDkKN6u8o6/CAQn/DL6YNNbj9ZFFq5w7BZ0jVQTNYpJx7U5efL/iOtSaxQmz6Pxfz/CMqKCA1Sihp1jdccohp6zcH0RKo9DbgOS97oLlDgC37au8O3HJeGL2/8pl4gebxhLB+fVO6/KMcZXItl5SREPCKIl/losmoMVnLEdL0GUfyJnn1MXj8yTNDxrMmvvEI5mdqLL5igbOJLYzI+7mTFkCxkQSidVF0vPlAau+9JT9deK0jRQcpu7Qfoh9S6aVUpbq1hwHuM/5DE6v6hz6ITgB3P0mL3IGelVgmyNayLtWi9F2pxFfZMEIA0QaqRl9rHDeUm8l3+/j38Sz13r4ffoSvK/kYKK3msh5mN/6TzMD2scuMaO7FbG3IrGI7DlAqyFBogH5bWBHyz31L/R4avybDXrARFdf7HwrvuWQEFVXt1jFhb614YKXuAUnlG9vH82cLGVeWOHzeePm5G8MuJKNI8eGJN9ac8Y2y6w25fQzxQHsMjXlPgT7ShpMlvJl9hJsulDdlKs3axws9xsWXTDBKIirNnfH6z+LAu1RdWaK4dbA5ICkR3Gmy2DQUuQXK9PQWGIS4wHxgXTWW3sRWBdo3Wdp4KovSQgC/B+qXiJVsKb1pn84HkPkHL/q4QuPWN2df/bKe77IsZeNZ8KGn8hkaZL/InA9t8YptXvHuA5CeFXdq9wYCnYQAdCWcVvWhw/GIcV6pgKf1znEh6Jd6R8S/s3raioPbUJtzjVPRmJpzJPqrsZRd8CQn+jvtB+gGkwR6yFHGpE16+jPK9ojJggyfzITaVjFLTzfsAvCt6xAIZb1UXlbbvSZmKXdaWI5O2h4= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(36860700013)(1800799024)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:40.6287 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 35db2853-0978-428f-491b-08dce3e63267 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF0000343E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8329 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" CTM values are defined as signed-magnitude values. Add a helper that converts from CTM signed-magnitude fixed point value to the twos-complement value used by drm_fixed. Signed-off-by: Harry Wentland --- include/drm/drm_fixed.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/drm/drm_fixed.h b/include/drm/drm_fixed.h index 1922188f00e8..0b44f2f294ce 100644 --- a/include/drm/drm_fixed.h +++ b/include/drm/drm_fixed.h @@ -78,6 +78,24 @@ static inline u32 dfixed_div(fixed20_12 A, fixed20_12 B) #define DRM_FIXED_EPSILON 1LL #define DRM_FIXED_ALMOST_ONE (DRM_FIXED_ONE - DRM_FIXED_EPSILON) +/** + * @drm_sm2fixp + * + * Convert a 1.31.32 signed-magnitude fixed point to 32.32 + * 2s-complement fixed point + * + * @return s64 2s-complement fixed point + */ +static inline s64 drm_sm2fixp(__u64 a) +{ + if ((a & (1LL << 63))) { + return -(a & 0x7fffffffffffffffll); + } else { + return a; + } + +} + static inline s64 drm_int2fixp(int a) { return ((s64)a) << DRM_FIXED_POINT; From patchwork Thu Oct 3 20:00:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821495 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 3EF90CF34C3 for ; Thu, 3 Oct 2024 20:01:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3C04A10E8F2; Thu, 3 Oct 2024 20:01:43 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="hFYVe6bZ"; dkim-atps=neutral Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2069.outbound.protection.outlook.com [40.107.100.69]) by gabe.freedesktop.org (Postfix) with ESMTPS id CD25110E8EB; Thu, 3 Oct 2024 20:01:41 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DQR5xYzFBStR9KeFfD4NqImc82EBxa+CZ5oF9MvmKehiNWsMG/TKuk9XvWRphouNkWtxnDIuiB6cKKxevAV0BPvNP2q4XcUk3fNyfvMKcNHe9PC/bUondWatuYm/cbfcbipblzLVlm8/COO8xDXt4dnPo6u+nfkIW/FVS0Tsc5Hne2zgHRrqOyvkNnIO6w7xfW05fNd9NeK4mwATbMAT544owvFh+KBJvRnEq6XtPVd99VHmi5pzuTvh1hy6MphUBy3rLNm7YxeAleBS6X9BlWsabLYn0r4RUP3uYhVXybGazl1iUlg5uGKImx4ZbCdXsJezrj3N8DtDwDaq8gaItg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=GKhFuF2R67lF3Fx3qUcWAp+7TtXF1wlCDOCZIn6ep4U=; b=yrQEJyj3soHt1zxI7i0woB5zAgbIuDsMX9JG9aRdWv1aXMTSXcKfDx/5GzeURt9aPL+4BSRlcadQqs5O9HWhT8mzOdUToPF4Gf8iWGi3kWYHon0ASA2hingLTlF+95/pJ4CpesB2oagwdTWmeFJPAHO2JCKS7SV5nizd/+VVO+OAUv66FwNbPqZ5fjxLLlkSzuhqxrxzC6un0WbmNvzYCYBO7M65wIzhr8vYcnB04Dpr6E1rqxUz2E5PBM50YzYE4nPjtBpWV6qzsO4aXo6XBq+MedjJ9B32WbMImW+kaCQId+s2fCO7oVxyrmhBike5tx+FiCb53MH7QwGuXdDUOg== 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=GKhFuF2R67lF3Fx3qUcWAp+7TtXF1wlCDOCZIn6ep4U=; b=hFYVe6bZYOECxLutabLoiOB8G7190Lq8aUrrlTfBKFf7f+vsAO4jPfIYHkHHBWtmwxgEKUqykruxZKRbNi0FvL/NJxifQXvv9qP8LM70yD62jBOFoi30dca2/gQlHF0SkF2V2RFiHEEz7jAhvgGzykmWiGUmx0mlr/lKD8Go1mo= Received: from CH0PR03CA0066.namprd03.prod.outlook.com (2603:10b6:610:cc::11) by MN0PR12MB5859.namprd12.prod.outlook.com (2603:10b6:208:37a::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Thu, 3 Oct 2024 20:01:37 +0000 Received: from CH2PEPF00000140.namprd02.prod.outlook.com (2603:10b6:610:cc:cafe::1) by CH0PR03CA0066.outlook.office365.com (2603:10b6:610:cc::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.17 via Frontend Transport; Thu, 3 Oct 2024 20:01:37 +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 CH2PEPF00000140.mail.protection.outlook.com (10.167.244.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:37 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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.39; Thu, 3 Oct 2024 15:01:33 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:34 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:33 -0500 From: Harry Wentland To: , CC: , Harry Wentland , Louis Chauvet Subject: [PATCH v6 02/44] drm/vkms: Round fixp2int conversion in lerp_u16 Date: Thu, 3 Oct 2024 16:00:44 -0400 Message-ID: <20241003200129.1732122-3-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB05.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000140:EE_|MN0PR12MB5859:EE_ X-MS-Office365-Filtering-Correlation-Id: 508d94bd-86fe-4150-af5e-08dce3e6303e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: i5IUu61E+iCtzkvDRvirIEfe2YQ9K7pxZ63q4icrncxOs/zAL8ILG+hCzQtENbqw2XGzTUGgRxnbWD/oKlKnTpv/Hja4JsVP3lxkjF0GehXBgA3LjlSDoK3V1h550z5TsDAqvRR+SgVyzpsXjM6/sGuBdckCU1LlFZU49Hz7gNkQKmOfbl8usY6/eQQhABP1geAkaT6g1Lm5Sr83+QrGPJYoD8GtK0KoG/6CaMEQ2LQIx+EHK7aJMv1GDlWJY50wEh1mYGaVyiwYU8JIy8ltCJR68z6lXQUVZ5ZYmksc11n7+KEDd8MysU7+L++y+vQzKoLb/rvAhrecbsZ20/94WB49qlFDiqE+94jEiWwrfcNzbbi6zlrv/q0LvRFefjIWwhy9YOm1URDaxERbUn+sHOH9bIobv5wGlJvu/CTjFk1N4+aZ1Q+YhAIyppWwlqSoa7r70Xe4lWfU0OBGWH16bkXJUyYyGd5vuAqTXYtRCTdYHvcb9rHm8AJr6nxywcwSEQPBzOB/Oc81w8P6eY6RBB/W1j4iT9Gth1eCB9XfI2LxjEQHRHWHdnT474O+JqZqp1Bvbt65qqHOk9I7o0dGfRg6m1nFb+PZc9HpFfN0euJl+D8pBFGKFt9DhI25nZD6mQsraRZwJ3bg0alPA28lhbt1SvoJ8jsKNjnhz0QeFWkz6jGH/c8wNM6jv5+xrkJ7CMs1aVSfdsHT0Y9se3Oeqc3sUcaFnfK4EbbHlviYYpa9IdQLUBFOKrmagIxGo9qdSr0C6Gb4i9mvJMwFK99IJp+I+GDiM52tC1YPpzrL8DBuvjqvBcRJl4CJl86O9bcjo3Xp/Om3oyvCKeci3qmHRjK4hNXIVXAu6l3LPj7HNegipfCiquEGO7d02o3sdS0DLn6rRx/4BLXu6/mAevsDXJvb0l08dYOeYTXf3yPobkM6FBQ1dhlYVil6JSwYUJgK9f6yUapFXK6H3VaO8Pn4OlXKmiFDRASv3XhmJwg3zqpG8Qjfptp8LJrCDUJqCyWONr6phgTrjx/lXisgdyWqK1N3DwJxgJdtaLEc+Uyf1gGnPrwKUuPbiUBip1+2jTvzhNO6G7pHizGw4trGnkoI/GWSWQDk97L/nwPn+Fl+WD85su1u2Oh87iKaVdOzUqAX7ivjVQFc26vhpl5JeRf/9aqVHqxLTNWBA0OvaXhXB8TgFlwIp85i+X9ki3Eum4nWbt+figFOJq5Jby74FVOOi608u1h3AixNCg2T4ul+GCsiEHW6NqzaQgL8KZEeQHrtHEAQcm1vkDDInKGffRwcHLbOQVMqurs3bqCfqg5fDm7eDD0Gxdgj6nyiWnFyH4XinHlEtQkdCWX5oBM/CjgA453QmMkAwQm/Z1JcpvTl1G5qZxskPS6+3cNf4DgRcrIf 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:(13230040)(376014)(36860700013)(1800799024)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:37.0070 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 508d94bd-86fe-4150-af5e-08dce3e6303e 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: CH2PEPF00000140.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5859 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" fixp2int always rounds down, fixp2int_ceil rounds up. We need the new fixp2int_round. Signed-off-by: Harry Wentland Reviewed-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_composer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index e7441b227b3c..3d6785d081f2 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -98,7 +98,7 @@ static u16 lerp_u16(u16 a, u16 b, s64 t) s64 delta = drm_fixp_mul(b_fp - a_fp, t); - return drm_fixp2int(a_fp + delta); + return drm_fixp2int_round(a_fp + delta); } static s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel_value) From patchwork Thu Oct 3 20:00:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821512 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 2A8C5CF34C1 for ; Thu, 3 Oct 2024 20:02:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DD2FD10E930; Thu, 3 Oct 2024 20:01:54 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="QuybcetD"; dkim-atps=neutral Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2054.outbound.protection.outlook.com [40.107.101.54]) by gabe.freedesktop.org (Postfix) with ESMTPS id B7A3210E91D; Thu, 3 Oct 2024 20:01:49 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jOe8Zj7sGEa5gGs/DD9/aQmm310lAuraGMe9Dm+7DV/H/kLtyruyE21gh1oYofhscZ4GIBQZG0+MTDEaAfOZ1pL9OrU4GI57liY/AgpbG5gqr724AAsSB0B5OYSKK+EPEdXKQUvsm9wbcmKNVd/SywZlL84dHb7Vq1epWJYCfkpI4oPWZ1pjgeAGG7RE3IQT5CJ7QV3jmFm0axvgOXeuJxiiy/Rx2uhQQQVOQ3xEpkzNLlSrhV26Cb1Bmwx0+dsL80Xn7dZ/mKXhXJ1HSt13JnbVIf2SAWP4sn61UcxOj8TMTPhXuC4EuEh9bDaOvD/GET5JWx4s7BidDgVl00M4yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=5lZCGhQr6SR9tJFYJssAetG/GdiY3N87mbNKs35mEjI=; b=mzL0xXp/clIapOnRfXzMXnXb9OSHbl3qJQ4jNeL0bQLN1M3VLcg4zMkTpvx1VwZuHLll3leWJfnaXuMgJ/kc+NzySW1S67Y5UXOAdj4N59tVWbsi7yIVu6WbTlkAmaK2pfNd79OCYosTo6Nr4AVACGZ84lepSncL2cnOmVtCIMAYNRDsUiguNv8x0pgkwssULTXWdefPaKG4RBgKueTRLXWgDkkvYbcUNzhkTBxOu7Ffs4BYtbsyZSerq3am+LUVkfaKdDo/ZhPR6WsCkcp4jYIVEAGQjKDSPCe8mbAU49DOuHuEJVAxXIdGLkcnku4usSXMXb6QkULwoBO3bLC9ig== 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=5lZCGhQr6SR9tJFYJssAetG/GdiY3N87mbNKs35mEjI=; b=QuybcetD8UPaP3xGJ/+hG4reSH2bjt7m4w4xUIEseNtEcDuOADcOzKB9ZpIvAeKsdpKwl/AZLGtqvu92sOmsYyck9mBb/b6Lupf8Cy4AAZn7z8lcR05Yp2R7eCs8yeuQB+zZopghXW0zeIC1AzHCcRA0bxYpYhIadq7jcepGzLM= Received: from CH2PR14CA0051.namprd14.prod.outlook.com (2603:10b6:610:56::31) by PH7PR12MB5712.namprd12.prod.outlook.com (2603:10b6:510:1e3::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Thu, 3 Oct 2024 20:01:42 +0000 Received: from DS2PEPF0000343E.namprd02.prod.outlook.com (2603:10b6:610:56:cafe::81) by CH2PR14CA0051.outlook.office365.com (2603:10b6:610:56::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.17 via Frontend Transport; Thu, 3 Oct 2024 20:01:42 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS2PEPF0000343E.mail.protection.outlook.com (10.167.18.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:42 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:34 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:34 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:33 -0500 From: Harry Wentland To: , CC: , Harry Wentland , Arthur Grillo Subject: [PATCH v6 03/44] drm/vkms: Add kunit tests for VKMS LUT handling Date: Thu, 3 Oct 2024 16:00:45 -0400 Message-ID: <20241003200129.1732122-4-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB05.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343E:EE_|PH7PR12MB5712:EE_ X-MS-Office365-Filtering-Correlation-Id: 2fc5ea56-b33f-4454-0153-08dce3e63383 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: OdYte6JaFEQjcneEeadmxuaozUQooXrvDTprrJmxKXjxzHVsmWQmrmfOjxN+uNEeqLPESyeSjRm+XCskXFuNxBur81tAPBbJ4KCF7FiHRLiSQrAZz81chmW7hqcONals9Y7ubyvKpFWIMJY6Oml8Pf9I8Q3y/aQQ1V9bMJB9cRk7UGGARlvTFpaU74IaC89MJMD/6LKUXxOH5YIsHwJjR70zHhfofArKjJS0GwxjX/v//hTpg0h/8Up/q9bdjF2Fr6gnlFBOGSw35xb5+PRJmnujnVwkJ9MqIMSJC6bogwQaPLVpV5hJNoEGz1z7+jDc1j3ICjecvpPWtfYOsZe17nw1GLcly6qNHJ6K7KbvzBfoQttHAvt2nSCge7kVUAzIgJZ7FtRsXckKe9EtlpXOLSg28GEnm+ru8hnTs4/wTX8tFf61t1DQaE7TvJ6ARarscKygpB8liXaAMFbQiFx4I80RdFmUVKTGWZ3nvDOC0+ebKKB2RnmsQw7GjYFUPLzmOzBbWKEdxBuV7n9z8xNQMkLa9bBdfhDY6ZiYuOIgOR0tCh4vx9J9unYy8b2azFvZ0Kdcfo8qsPdovPz3k2f5ZnFggSdl64Vc5eLpR8ZR2k4xT/bzc8+EUovA+Kb8bvivnz/B6YNRg4pIqfHhsN1ntpW12Gg1OpGGtOk154HqbD5wbJRJn4UtAnMA1JmkcNRTjP12PKPVyesVBq4FkgZWyjO64QtDPretpXtxepM/qrg8zRZ9V9dWqcdtInq2pVjYVXtrW9mZO+AEPdUKS8wf1yT5OFYZiF60DymAR2AJksRDEjPInN7PCSXvU4Oa/oQTbM0sVr6jRcbogxnUa2L8i5nn5DbGWAhple3GGoXSurmWlMXMbqWC3LgAV5f69n3CmhiPfBc9TpU5teh6AKi7l0Xzg+g9sw20seoO2GU4EjRBIB7YeLf5C+ctfZ9qympGX/XpfdZ0cXFCPezzHp8EaMfLBeJoRWvq1re36GOTXZ7yevat8QNHKrPcgS4eoNNIpiSUNs8sSDfNUHBA8MZkdMhmFmpCPTJqUEKdztghKNjp2uuA7eBTXvEBYDR5XHQVZmLxDE9Wq7LUM3klronunXObnZljPRElLG+3SlY0y6KZpJcj6akHQzVki/PEcMYN8gIyfUzpIj6Eksh8YX96wvYk03U/A5FWtW2PYtTJwotYbE/6rl4A8bOOzcmdSZFtNnIqjiA7GGKO4kLBn9EF/F5MEfaz21zOU+5IILfYtFnBV7cNANnajk/SUK4DTBxqx7/9zzTFmgeR9FFGeov5uQKP3jjfrzSfBxEVj8cBC2ZwXcRZy/8Zbp6h6hbw9JFi5z3fCmBgBH9vHT8e+WXBBV/cOIgNuRZOJqsTdqlmHnfL9GKUsvqx2guk6Hht+QBy X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(36860700013)(1800799024)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:42.4880 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2fc5ea56-b33f-4454-0153-08dce3e63383 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF0000343E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5712 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" Debugging LUT math is much easier when we can unit test it. Add kunit functionality to VKMS and add tests for - get_lut_index - lerp_u16 Signed-off-by: Harry Wentland Cc: Arthur Grillo Reviewed-by: Louis Chauvet --- v6: - Eliminate need to include test as .c file (Louis Chauvet) v5: - Bring back static for lerp_u16 and get_lut_index (Arthur) v4: - Test the critical points of the lerp function (Pekka) v3: - Use include way of testing static functions (Arthur) drivers/gpu/drm/vkms/Kconfig | 15 ++ drivers/gpu/drm/vkms/Makefile | 1 + drivers/gpu/drm/vkms/tests/.kunitconfig | 4 + drivers/gpu/drm/vkms/tests/Makefile | 3 + drivers/gpu/drm/vkms/tests/vkms_color_test.c | 168 +++++++++++++++++++ drivers/gpu/drm/vkms/vkms_composer.c | 10 +- drivers/gpu/drm/vkms/vkms_composer.h | 13 ++ 7 files changed, 211 insertions(+), 3 deletions(-) create mode 100644 drivers/gpu/drm/vkms/tests/.kunitconfig create mode 100644 drivers/gpu/drm/vkms/tests/Makefile create mode 100644 drivers/gpu/drm/vkms/tests/vkms_color_test.c create mode 100644 drivers/gpu/drm/vkms/vkms_composer.h -- 2.46.2 diff --git a/drivers/gpu/drm/vkms/Kconfig b/drivers/gpu/drm/vkms/Kconfig index b9ecdebecb0b..59c4a32adb9d 100644 --- a/drivers/gpu/drm/vkms/Kconfig +++ b/drivers/gpu/drm/vkms/Kconfig @@ -13,3 +13,18 @@ config DRM_VKMS a VKMS. If M is selected the module will be called vkms. + +config DRM_VKMS_KUNIT_TESTS + tristate "KUnit tests for VKMS." if !KUNIT_ALL_TESTS + depends on DRM_VKMS=y && KUNIT + default KUNIT_ALL_TESTS + help + This builds unit tests for VKMS. This option is not useful for + distributions or general kernels, but only for kernel + developers working on VKMS. + + For more information on KUnit and unit tests in general, + please refer to the KUnit documentation in + Documentation/dev-tools/kunit/. + + If in doubt, say "N". diff --git a/drivers/gpu/drm/vkms/Makefile b/drivers/gpu/drm/vkms/Makefile index 1b28a6a32948..8d3e46dde635 100644 --- a/drivers/gpu/drm/vkms/Makefile +++ b/drivers/gpu/drm/vkms/Makefile @@ -9,3 +9,4 @@ vkms-y := \ vkms_writeback.o obj-$(CONFIG_DRM_VKMS) += vkms.o +obj-$(CONFIG_DRM_VKMS_KUNIT_TESTS) += tests/ diff --git a/drivers/gpu/drm/vkms/tests/.kunitconfig b/drivers/gpu/drm/vkms/tests/.kunitconfig new file mode 100644 index 000000000000..70e378228cbd --- /dev/null +++ b/drivers/gpu/drm/vkms/tests/.kunitconfig @@ -0,0 +1,4 @@ +CONFIG_KUNIT=y +CONFIG_DRM=y +CONFIG_DRM_VKMS=y +CONFIG_DRM_VKMS_KUNIT_TESTS=y diff --git a/drivers/gpu/drm/vkms/tests/Makefile b/drivers/gpu/drm/vkms/tests/Makefile new file mode 100644 index 000000000000..7876ca7a3c42 --- /dev/null +++ b/drivers/gpu/drm/vkms/tests/Makefile @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0-only + +obj-$(CONFIG_DRM_VKMS_KUNIT_TESTS) += vkms_color_test.o \ No newline at end of file diff --git a/drivers/gpu/drm/vkms/tests/vkms_color_test.c b/drivers/gpu/drm/vkms/tests/vkms_color_test.c new file mode 100644 index 000000000000..efe139978860 --- /dev/null +++ b/drivers/gpu/drm/vkms/tests/vkms_color_test.c @@ -0,0 +1,168 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#include + +#include +#include +#include "../vkms_drv.h" +#include "../vkms_composer.h" + +#define TEST_LUT_SIZE 16 + +MODULE_IMPORT_NS(EXPORTED_FOR_KUNIT_TESTING); + +static struct drm_color_lut test_linear_array[TEST_LUT_SIZE] = { + { 0x0, 0x0, 0x0, 0 }, + { 0x1111, 0x1111, 0x1111, 0 }, + { 0x2222, 0x2222, 0x2222, 0 }, + { 0x3333, 0x3333, 0x3333, 0 }, + { 0x4444, 0x4444, 0x4444, 0 }, + { 0x5555, 0x5555, 0x5555, 0 }, + { 0x6666, 0x6666, 0x6666, 0 }, + { 0x7777, 0x7777, 0x7777, 0 }, + { 0x8888, 0x8888, 0x8888, 0 }, + { 0x9999, 0x9999, 0x9999, 0 }, + { 0xaaaa, 0xaaaa, 0xaaaa, 0 }, + { 0xbbbb, 0xbbbb, 0xbbbb, 0 }, + { 0xcccc, 0xcccc, 0xcccc, 0 }, + { 0xdddd, 0xdddd, 0xdddd, 0 }, + { 0xeeee, 0xeeee, 0xeeee, 0 }, + { 0xffff, 0xffff, 0xffff, 0 }, +}; + +const struct vkms_color_lut test_linear_lut = { + .base = test_linear_array, + .lut_length = TEST_LUT_SIZE, + .channel_value2index_ratio = 0xf000fll +}; + + +static void vkms_color_test_get_lut_index(struct kunit *test) +{ + int i; + + KUNIT_EXPECT_EQ(test, drm_fixp2int(get_lut_index(&test_linear_lut, test_linear_array[0].red)), 0); + + for (i = 0; i < TEST_LUT_SIZE; i++) + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&test_linear_lut, test_linear_array[i].red)), i); +} + +static void vkms_color_test_lerp(struct kunit *test) +{ + /*** half-way round down ***/ + s64 t = 0x80000000 - 1; + KUNIT_EXPECT_EQ(test, lerp_u16(0x0, 0x10, t), 0x8); + + /* odd a */ + KUNIT_EXPECT_EQ(test, lerp_u16(0x1, 0x10, t), 0x8); + + /* odd b */ + KUNIT_EXPECT_EQ(test, lerp_u16(0x1, 0xf, t), 0x8); + + /* b = a */ + KUNIT_EXPECT_EQ(test, lerp_u16(0x10, 0x10, t), 0x10); + + /* b = a + 1 */ + KUNIT_EXPECT_EQ(test, lerp_u16(0x10, 0x11, t), 0x10); + + + /*** half-way round up ***/ + t = 0x80000000; + KUNIT_EXPECT_EQ(test, lerp_u16(0x0, 0x10, t), 0x8); + + /* odd a */ + KUNIT_EXPECT_EQ(test, lerp_u16(0x1, 0x10, t), 0x9); + + /* odd b */ + KUNIT_EXPECT_EQ(test, lerp_u16(0x1, 0xf, t), 0x8); + + /* b = a */ + KUNIT_EXPECT_EQ(test, lerp_u16(0x10, 0x10, t), 0x10); + + /* b = a + 1 */ + KUNIT_EXPECT_EQ(test, lerp_u16(0x10, 0x11, t), 0x11); + + /*** t = 0.0 ***/ + t = 0x0; + KUNIT_EXPECT_EQ(test, lerp_u16(0x0, 0x10, t), 0x0); + + /* odd a */ + KUNIT_EXPECT_EQ(test, lerp_u16(0x1, 0x10, t), 0x1); + + /* odd b */ + KUNIT_EXPECT_EQ(test, lerp_u16(0x1, 0xf, t), 0x1); + + /* b = a */ + KUNIT_EXPECT_EQ(test, lerp_u16(0x10, 0x10, t), 0x10); + + /* b = a + 1 */ + KUNIT_EXPECT_EQ(test, lerp_u16(0x10, 0x11, t), 0x10); + + /*** t = 1.0 ***/ + t = 0x100000000; + KUNIT_EXPECT_EQ(test, lerp_u16(0x0, 0x10, t), 0x10); + + /* odd a */ + KUNIT_EXPECT_EQ(test, lerp_u16(0x1, 0x10, t), 0x10); + + /* odd b */ + KUNIT_EXPECT_EQ(test, lerp_u16(0x1, 0xf, t), 0xf); + + /* b = a */ + KUNIT_EXPECT_EQ(test, lerp_u16(0x10, 0x10, t), 0x10); + + /* b = a + 1 */ + KUNIT_EXPECT_EQ(test, lerp_u16(0x10, 0x11, t), 0x11); + + + /*** t = 0.0 + 1 ***/ + t = 0x0 + 1; + KUNIT_EXPECT_EQ(test, lerp_u16(0x0, 0x10, t), 0x0); + + /* odd a */ + KUNIT_EXPECT_EQ(test, lerp_u16(0x1, 0x10, t), 0x1); + + /* odd b */ + KUNIT_EXPECT_EQ(test, lerp_u16(0x1, 0xf, t), 0x1); + + /* b = a */ + KUNIT_EXPECT_EQ(test, lerp_u16(0x10, 0x10, t), 0x10); + + /* b = a + 1 */ + KUNIT_EXPECT_EQ(test, lerp_u16(0x10, 0x11, t), 0x10); + + /*** t = 1.0 - 1 ***/ + t = 0x100000000 - 1; + KUNIT_EXPECT_EQ(test, lerp_u16(0x0, 0x10, t), 0x10); + + /* odd a */ + KUNIT_EXPECT_EQ(test, lerp_u16(0x1, 0x10, t), 0x10); + + /* odd b */ + KUNIT_EXPECT_EQ(test, lerp_u16(0x1, 0xf, t), 0xf); + + /* b = a */ + KUNIT_EXPECT_EQ(test, lerp_u16(0x10, 0x10, t), 0x10); + + /* b = a + 1 */ + KUNIT_EXPECT_EQ(test, lerp_u16(0x10, 0x11, t), 0x11); + + + /*** t chosen to verify the flipping point of result a (or b) to a+1 (or b-1) ***/ + KUNIT_EXPECT_EQ(test, lerp_u16(0x0, 0x1, 0x80000000 - 1), 0x0); + KUNIT_EXPECT_EQ(test, lerp_u16(0x0, 0x1, 0x80000000), 0x1); +} + +static struct kunit_case vkms_color_test_cases[] = { + KUNIT_CASE(vkms_color_test_get_lut_index), + KUNIT_CASE(vkms_color_test_lerp), + {} +}; + +static struct kunit_suite vkms_color_test_suite = { + .name = "vkms-color", + .test_cases = vkms_color_test_cases, +}; +kunit_test_suite(vkms_color_test_suite); + +MODULE_LICENSE("GPL"); \ No newline at end of file diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index 3d6785d081f2..93f4ed5ea52f 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -12,6 +12,8 @@ #include #include "vkms_drv.h" +#include +#include "vkms_composer.h" static u16 pre_mul_blend_channel(u16 src, u16 dst, u16 alpha) { @@ -91,7 +93,7 @@ static void fill_background(const struct pixel_argb_u16 *background_color, } // lerp(a, b, t) = a + (b - a) * t -static u16 lerp_u16(u16 a, u16 b, s64 t) +VISIBLE_IF_KUNIT u16 lerp_u16(u16 a, u16 b, s64 t) { s64 a_fp = drm_int2fixp(a); s64 b_fp = drm_int2fixp(b); @@ -100,13 +102,15 @@ static u16 lerp_u16(u16 a, u16 b, s64 t) return drm_fixp2int_round(a_fp + delta); } +EXPORT_SYMBOL_IF_KUNIT(lerp_u16); -static s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel_value) +VISIBLE_IF_KUNIT s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel_value) { s64 color_channel_fp = drm_int2fixp(channel_value); return drm_fixp_mul(color_channel_fp, lut->channel_value2index_ratio); } +EXPORT_SYMBOL_IF_KUNIT(get_lut_index); /* * This enum is related to the positions of the variables inside @@ -434,4 +438,4 @@ int vkms_set_crc_source(struct drm_crtc *crtc, const char *src_name) vkms_set_composer(out, enabled); return ret; -} +} \ No newline at end of file diff --git a/drivers/gpu/drm/vkms/vkms_composer.h b/drivers/gpu/drm/vkms/vkms_composer.h new file mode 100644 index 000000000000..9316a053e7d7 --- /dev/null +++ b/drivers/gpu/drm/vkms/vkms_composer.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef _VKMS_COMPOSER_H_ +#define _VKMS_COMPOSER_H_ + +#include + +#if IS_ENABLED(CONFIG_KUNIT) +u16 lerp_u16(u16 a, u16 b, s64 t); +s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel_value); +#endif + +#endif /* _VKMS_COMPOSER_H_ */ From patchwork Thu Oct 3 20:00:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821497 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 3B3B7CF34C3 for ; Thu, 3 Oct 2024 20:01:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5F66110E900; Thu, 3 Oct 2024 20:01:44 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="vEGLpn2w"; dkim-atps=neutral Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2044.outbound.protection.outlook.com [40.107.243.44]) by gabe.freedesktop.org (Postfix) with ESMTPS id D129510E8F2; Thu, 3 Oct 2024 20:01:41 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lfhVIVviFvvuODiPiNihKQ83NOTsfVqZVSWkxtk1IQKn8sO32IsBHBUWn6dYvtOAltPXz+ApPqDHKqKW//OZNVtgqItaTzL5CtoffzqtD1H2abBFsNiUPw2ou562PwmCIj3UIgNQzUSmbeQEzKJDvv/WArLvVUMet5PbmKHZOI0/p6d6tSqaCURysj5Li37yh+58EfYIro0AbOL9UCzJi6w+vJKpAdEDO9UHKnNn/aF/38Vn9i7N4iBna9nzuRsjs3IKvqJ0NuTguKEs+IyCX0nkovTuR/jV6LpWCUIELzezHcoOyjSmWdZUNjg2dDY7TVvU0qFpwza6xS7+TTjgFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=hhx5CtqX+SUtzKjmcj8r/yzq+w5ZJFnBBke8bL/Jpi0=; b=Inrx42QWnrSW7Q5k9jjG+2L5xoX1PuEKIiFWlkiFVdweLAi9hN5DjY6UG/gKXgVyQl+++7T1DVfFP1pqVIL4SNoGPkg4hlxG4kXKhb4SQwotDgzRfIQ/HFMDGQJPW4wX6XdVue7FYFXZLZS/cwIx/u/DxT1Q1LBGEDn4ULKvv4Gx6fW5SHYg5e6MZc827/mXTbjZS4alcU32RavVmGgXGdr6r/VtNSgOaCM12w92y5ozns94DUMVEB4cTjd61UWSWA1xdQO2hdBz/3ayPYQ6HWsPzkgpw0o8ySZb84BTVg3+dZY8VulyGUMrHvshbmnszSJ1zhfvnOQ6BNm8rdE2hw== 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=hhx5CtqX+SUtzKjmcj8r/yzq+w5ZJFnBBke8bL/Jpi0=; b=vEGLpn2wqPE9Y5KLqTI9xNXdlb80rFUyHl64LOfw37bE9P0xET5iVK7KLz8pTx9x49gBhmPoJu9ZjY3svW2pYwFbfeyh4hBXt7ikO56Nxfsc/OoOKMBMLTQg8FdXlXlp2miQCFks1iWwryZBVe2d3MmcBxZqXaTKfSmlEYfzbN4= Received: from CH2PR14CA0054.namprd14.prod.outlook.com (2603:10b6:610:56::34) by PH8PR12MB7160.namprd12.prod.outlook.com (2603:10b6:510:228::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.28; Thu, 3 Oct 2024 20:01:36 +0000 Received: from DS2PEPF0000343E.namprd02.prod.outlook.com (2603:10b6:610:56:cafe::f4) by CH2PR14CA0054.outlook.office365.com (2603:10b6:610:56::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:01:35 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS2PEPF0000343E.mail.protection.outlook.com (10.167.18.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:35 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:34 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:34 -0500 From: Harry Wentland To: , CC: , Harry Wentland Subject: [PATCH v6 04/44] drm/doc/rfc: Describe why prescriptive color pipeline is needed Date: Thu, 3 Oct 2024 16:00:46 -0400 Message-ID: <20241003200129.1732122-5-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343E:EE_|PH8PR12MB7160:EE_ X-MS-Office365-Filtering-Correlation-Id: ecb864c3-192e-4320-8067-08dce3e62f54 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|1800799024|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?t3RsSNKpOwYM2Ue5SZzzrZQ5EWxX3Yp?= =?utf-8?q?4neJLDsPOMc3lGXrxg9FaaCeRoae3CoUjxLPoo7heXTX0F2Et8DmN0EGUHDF0QnKm?= =?utf-8?q?dxnjQA+NHP+ErRwPLg6g50oD7SxTx+hkqsDk38I+tCesMyJc0eiziEVIv6KqX4+yy?= =?utf-8?q?46HGv+kcO+axnGF+S9E8BLGIBLNYk/Zv50h6qo8in/UnBoaLcjrB1j9YyO7IBxugY?= =?utf-8?q?8wPy1QAGXIYWsmePEnC3BHFh2T2B1RtGB6k8Nf4+DjiOvi1EMZmF5uRulmRjPiiTr?= =?utf-8?q?NkUvxsu4YAcPk6iNOo38lvMHUV9TDG2i9AS5Yc9LoxaeYfVDLhAyUNg4Ad//plKm6?= =?utf-8?q?9w8Tmev9WDAEiPGKPPTskS3Q3GB5lFQRJdfgI793XCjzq5H1Zsdc3X/t1kx2Hhwyk?= =?utf-8?q?rM4KssMG9C2k9L0F3SltY3zUTzYAkqtxNLH1rNsvkyoZvmEGSbKYJXuZ9jLmBkucB?= =?utf-8?q?d1ll72kb6LGT/5VvhutDSR8rbchMWBXp6r+9XHJzD/BUFHsnz25JKYXDp2er/3kT7?= =?utf-8?q?u7Ud6OC09nIGFBcysLdLM0Jg2z1cYrjmqTvRYm/ItzmkLie48WqQixwMOIw7SfJO/?= =?utf-8?q?EKVnZy05l3TtAg6WMtFEhl1UPONp1e3UJA06vw2TXUpo3nerpwdkIiDo0f0H5EjYr?= =?utf-8?q?lFcPT4Nmyj9AfpgedBgmhTaFPe2bYWPZEkx+dy57mZIC8014288Hey9SSk4oxitEx?= =?utf-8?q?XFSRj5jfXYaUIhB+U8R21FpmkeYcylIC32Tez+K3v6+V/6BgGw0QdUVLYpQCPqYbV?= =?utf-8?q?yg2ovKk4Q88HE0km28p8OGYHoWe6uM6fKfU/ZrvXLYEH0PJfgFSuv4Qwk6NSJ01ww?= =?utf-8?q?FvIYroL3Z0DrFFQnOesAZgeAQUAVxqzORjRHrc2P/8eOheiUaPjA0RmtH++AwDFeM?= =?utf-8?q?nYHEf7RI9HLlOfaYgsG0YuXgDdXgsTp6QqKYNk+fPtF1DHOyXJB9x+BjPJ61VeD2l?= =?utf-8?q?zOQBYxsgYdyS/TFKCHEkD2Z0EZi1PUhF3kJ0L9JR7g9uxIddCthWywNBv18mkXUfc?= =?utf-8?q?s1sQnSIWhvUY4AnmkbzyIRlG9PNGOA/hybBbpl0kpAXVgi8JXzAviGuzXt9XQ/EyB?= =?utf-8?q?ycWJOtCO6Z1ko8/WOmC9SrqiQdxLjP9j25LyEB0GiX5zCpZ0pPr4HjI/HDEFB5aZs?= =?utf-8?q?VNi6u/b/crhz4uJaMaugCET2y2PoG+YiheDuxgXeheYvpIFArtUCRkINBAidQinKW?= =?utf-8?q?nM+1/6YILbPyTA8tWj32BjnYC7bgOoly84QSWhZfIfNT6S/jmrXu8JHbkGjQbvzCw?= =?utf-8?q?bcg6pWGHEru5YsBP+CbNRy5KXF7Xuionk1wpfNPoQ/nV+oce7sTcuhg1oIsFfFJCM?= =?utf-8?q?IZngMILV4cm3?= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700013)(1800799024)(376014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:35.3943 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ecb864c3-192e-4320-8067-08dce3e62f54 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF0000343E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7160 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" Signed-off-by: Harry Wentland --- v5: - Don't require BYPASS to succeed (Sebastian) - use DATA for 1D and 3D LUT types (Sebastian) - update 3DLUT ops to use 3DLUT_MODES and 3DLUT_MODE_INDEX - Add section on drm_colorop extensibility - Add color_pipeline.rst to RFC toc tree v4: - Drop IOCTL docs since we dropped the IOCTLs (Pekka) - Clarify reading and setting of COLOR_PIPELINE prop (Pekka) - Add blurb about not requiring to reject a pipeline due to incompatible ops, as long as op can be bypassed (Pekka) - Dropped informational strings (such as input CSC) as they're not actually intended to be advertised (Pekka) v3: - Describe DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE (Sebastian) - Ask for clear documentation of colorop behavior (Sebastian) v2: - Update colorop visualizations to match reality (Sebastian, Alex Hung) - Updated wording (Pekka) - Change BYPASS wording to make it non-mandatory (Sebastian) - Drop cover-letter-like paragraph from COLOR_PIPELINE Plane Property section (Pekka) - Use PQ EOTF instead of its inverse in Pipeline Programming example (Melissa) - Add "Driver Implementer's Guide" section (Pekka) - Add "Driver Forward/Backward Compatibility" section (Sebastian, Pekka) Documentation/gpu/rfc/color_pipeline.rst | 376 +++++++++++++++++++++++ Documentation/gpu/rfc/index.rst | 3 + 2 files changed, 379 insertions(+) create mode 100644 Documentation/gpu/rfc/color_pipeline.rst -- 2.46.2 diff --git a/Documentation/gpu/rfc/color_pipeline.rst b/Documentation/gpu/rfc/color_pipeline.rst new file mode 100644 index 000000000000..4135f07b85a7 --- /dev/null +++ b/Documentation/gpu/rfc/color_pipeline.rst @@ -0,0 +1,376 @@ +======================== +Linux Color Pipeline API +======================== + +What problem are we solving? +============================ + +We would like to support pre-, and post-blending complex color +transformations in display controller hardware in order to allow for +HW-supported HDR use-cases, as well as to provide support to +color-managed applications, such as video or image editors. + +It is possible to support an HDR output on HW supporting the Colorspace +and HDR Metadata drm_connector properties, but that requires the +compositor or application to render and compose the content into one +final buffer intended for display. Doing so is costly. + +Most modern display HW offers various 1D LUTs, 3D LUTs, matrices, and other +operations to support color transformations. These operations are often +implemented in fixed-function HW and therefore much more power efficient than +performing similar operations via shaders or CPU. + +We would like to make use of this HW functionality to support complex color +transformations with no, or minimal CPU or shader load. + + +How are other OSes solving this problem? +======================================== + +The most widely supported use-cases regard HDR content, whether video or +gaming. + +Most OSes will specify the source content format (color gamut, encoding transfer +function, and other metadata, such as max and average light levels) to a driver. +Drivers will then program their fixed-function HW accordingly to map from a +source content buffer's space to a display's space. + +When fixed-function HW is not available the compositor will assemble a shader to +ask the GPU to perform the transformation from the source content format to the +display's format. + +A compositor's mapping function and a driver's mapping function are usually +entirely separate concepts. On OSes where a HW vendor has no insight into +closed-source compositor code such a vendor will tune their color management +code to visually match the compositor's. On other OSes, where both mapping +functions are open to an implementer they will ensure both mappings match. + +This results in mapping algorithm lock-in, meaning that no-one alone can +experiment with or introduce new mapping algorithms and achieve +consistent results regardless of which implementation path is taken. + +Why is Linux different? +======================= + +Unlike other OSes, where there is one compositor for one or more drivers, on +Linux we have a many-to-many relationship. Many compositors; many drivers. +In addition each compositor vendor or community has their own view of how +color management should be done. This is what makes Linux so beautiful. + +This means that a HW vendor can now no longer tune their driver to one +compositor, as tuning it to one could make it look fairly different from +another compositor's color mapping. + +We need a better solution. + + +Descriptive API +=============== + +An API that describes the source and destination colorspaces is a descriptive +API. It describes the input and output color spaces but does not describe +how precisely they should be mapped. Such a mapping includes many minute +design decision that can greatly affect the look of the final result. + +It is not feasible to describe such mapping with enough detail to ensure the +same result from each implementation. In fact, these mappings are a very active +research area. + + +Prescriptive API +================ + +A prescriptive API describes not the source and destination colorspaces. It +instead prescribes a recipe for how to manipulate pixel values to arrive at the +desired outcome. + +This recipe is generally an ordered list of straight-forward operations, +with clear mathematical definitions, such as 1D LUTs, 3D LUTs, matrices, +or other operations that can be described in a precise manner. + + +The Color Pipeline API +====================== + +HW color management pipelines can significantly differ between HW +vendors in terms of availability, ordering, and capabilities of HW +blocks. This makes a common definition of color management blocks and +their ordering nigh impossible. Instead we are defining an API that +allows user space to discover the HW capabilities in a generic manner, +agnostic of specific drivers and hardware. + + +drm_colorop Object +================== + +To support the definition of color pipelines we define the DRM core +object type drm_colorop. Individual drm_colorop objects will be chained +via the NEXT property of a drm_colorop to constitute a color pipeline. +Each drm_colorop object is unique, i.e., even if multiple color +pipelines have the same operation they won't share the same drm_colorop +object to describe that operation. + +Note that drivers are not expected to map drm_colorop objects statically +to specific HW blocks. The mapping of drm_colorop objects is entirely a +driver-internal detail and can be as dynamic or static as a driver needs +it to be. See more in the Driver Implementation Guide section below. + +Each drm_colorop has three core properties: + +TYPE: An enumeration property, definint the type of transformation, such as +* enumerated curve +* custom (uniform) 1D LUT +* 3x3 matrix +* 3x4 matrix +* 3D LUT +* etc. + +Depending on the type of transformation other properties will describe +more details. + +BYPASS: A boolean property that can be used to easily put a block into +bypass mode. The BYPASS property is not mandatory for a colorop, as long +as the entire pipeline can get bypassed by setting the COLOR_PIPELINE on +a plane to '0'. + +NEXT: The ID of the next drm_colorop in a color pipeline, or 0 if this +drm_colorop is the last in the chain. + +An example of a drm_colorop object might look like one of these:: + + /* 1D enumerated curve */ + Color operation 42 + ├─ "TYPE": immutable enum {1D enumerated curve, 1D LUT, 3x3 matrix, 3x4 matrix, 3D LUT, etc.} = 1D enumerated curve + ├─ "BYPASS": bool {true, false} + ├─ "CURVE_1D_TYPE": enum {sRGB EOTF, sRGB inverse EOTF, PQ EOTF, PQ inverse EOTF, …} + └─ "NEXT": immutable color operation ID = 43 + + /* custom 4k entry 1D LUT */ + Color operation 52 + ├─ "TYPE": immutable enum {1D enumerated curve, 1D LUT, 3x3 matrix, 3x4 matrix, 3D LUT, etc.} = 1D LUT + ├─ "BYPASS": bool {true, false} + ├─ "SIZE": immutable range = 4096 + ├─ "DATA": blob + └─ "NEXT": immutable color operation ID = 0 + + /* 17^3 3D LUT */ + Color operation 72 + ├─ "TYPE": immutable enum {1D enumerated curve, 1D LUT, 3x3 matrix, 3x4 matrix, 3D LUT, etc.} = 3D LUT + ├─ "BYPASS": bool {true, false} + ├─ "3DLUT_MODES": read-only blob of supported 3DLUT modes + ├─ "3DLUT_MODE_INDEX": index of selected 3DLUT mode + ├─ "DATA": blob + └─ "NEXT": immutable color operation ID = 73 + +drm_colorop extensibility +------------------------- + +Unlike existing DRM core objects, like &drm_plane, drm_colorop is not +extensible. This simplifies implementations and keeps all functionality +for managing &drm_colorop objects in the DRM core. + +If there is a need one may introduce a simple &drm_colorop_funcs +function table in the future, for example to support an IN_FORMATS +property on a &drm_colorop. + +If a driver requires the ability to create a driver-specific colorop +object they will need to add &drm_colorop func table support with +support for the usual functions, like destroy, atomic_duplicate_state, +and atomic_destroy_state. + + +COLOR_PIPELINE Plane Property +============================= + +Color Pipelines are created by a driver and advertised via a new +COLOR_PIPELINE enum property on each plane. Values of the property +always include object id 0, which is the default and means all color +processing is disabled. Additional values will be the object IDs of the +first drm_colorop in a pipeline. A driver can create and advertise none, +one, or more possible color pipelines. A DRM client will select a color +pipeline by setting the COLOR PIPELINE to the respective value. + +NOTE: Many DRM clients will set enumeration properties via the string +value, often hard-coding it. Since this enumeration is generated based +on the colorop object IDs it is important to perform the Color Pipeline +Discovery, described below, instead of hard-coding color pipeline +assignment. Drivers might generate the enum strings dynamically. +Hard-coded strings might only work for specific drivers on a specific +pieces of HW. Color Pipeline Discovery can work universally, as long as +drivers implement the required color operations. + +The COLOR_PIPELINE property is only exposed when the +DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE is set. Drivers shall ignore any +existing pre-blend color operations when this cap is set, such as +COLOR_RANGE and COLOR_ENCODING. If drivers want to support COLOR_RANGE +or COLOR_ENCODING functionality when the color pipeline client cap is +set, they are expected to expose colorops in the pipeline to allow for +the appropriate color transformation. + +Setting of the COLOR_PIPELINE plane property or drm_colorop properties +is only allowed for userspace that sets this client cap. + +An example of a COLOR_PIPELINE property on a plane might look like this:: + + Plane 10 + ├─ "TYPE": immutable enum {Overlay, Primary, Cursor} = Primary + ├─ … + └─ "COLOR_PIPELINE": enum {0, 42, 52} = 0 + + +Color Pipeline Discovery +======================== + +A DRM client wanting color management on a drm_plane will: + +1. Get the COLOR_PIPELINE property of the plane +2. iterate all COLOR_PIPELINE enum values +3. for each enum value walk the color pipeline (via the NEXT pointers) + and see if the available color operations are suitable for the + desired color management operations + +If userspace encounters an unknown or unsuitable color operation during +discovery it does not need to reject the entire color pipeline outright, +as long as the unknown or unsuitable colorop has a "BYPASS" property. +Drivers will ensure that a bypassed block does not have any effect. + +An example of chained properties to define an AMD pre-blending color +pipeline might look like this:: + + Plane 10 + ├─ "TYPE" (immutable) = Primary + └─ "COLOR_PIPELINE": enum {0, 44} = 0 + + Color operation 44 + ├─ "TYPE" (immutable) = 1D enumerated curve + ├─ "BYPASS": bool + ├─ "CURVE_1D_TYPE": enum {sRGB EOTF, PQ EOTF} = sRGB EOTF + └─ "NEXT" (immutable) = 45 + + Color operation 45 + ├─ "TYPE" (immutable) = 3x4 Matrix + ├─ "BYPASS": bool + ├─ "DATA": blob + └─ "NEXT" (immutable) = 46 + + Color operation 46 + ├─ "TYPE" (immutable) = 1D enumerated curve + ├─ "BYPASS": bool + ├─ "CURVE_1D_TYPE": enum {sRGB Inverse EOTF, PQ Inverse EOTF} = sRGB EOTF + └─ "NEXT" (immutable) = 47 + + Color operation 47 + ├─ "TYPE" (immutable) = 1D LUT + ├─ "SIZE": immutable range = 4096 + ├─ "DATA": blob + └─ "NEXT" (immutable) = 48 + + Color operation 48 + ├─ "TYPE" (immutable) = 3D LUT + ├─ "3DLUT_MODE_INDEX": 0 + ├─ "DATA": blob + └─ "NEXT" (immutable) = 49 + + Color operation 49 + ├─ "TYPE" (immutable) = 1D enumerated curve + ├─ "BYPASS": bool + ├─ "CURVE_1D_TYPE": enum {sRGB EOTF, PQ EOTF} = sRGB EOTF + └─ "NEXT" (immutable) = 0 + + +Color Pipeline Programming +========================== + +Once a DRM client has found a suitable pipeline it will: + +1. Set the COLOR_PIPELINE enum value to the one pointing at the first + drm_colorop object of the desired pipeline +2. Set the properties for all drm_colorop objects in the pipeline to the + desired values, setting BYPASS to true for unused drm_colorop blocks, + and false for enabled drm_colorop blocks +3. Perform (TEST_ONLY or not) atomic commit with all the other KMS + states it wishes to change + +To configure the pipeline for an HDR10 PQ plane and blending in linear +space, a compositor might perform an atomic commit with the following +property values:: + + Plane 10 + └─ "COLOR_PIPELINE" = 42 + + Color operation 42 + └─ "BYPASS" = true + + Color operation 44 + └─ "BYPASS" = true + + Color operation 45 + └─ "BYPASS" = true + + Color operation 46 + └─ "BYPASS" = true + + Color operation 47 + ├─ "LUT_3D_DATA" = Gamut mapping + tone mapping + night mode + └─ "BYPASS" = false + + Color operation 48 + ├─ "CURVE_1D_TYPE" = PQ EOTF + └─ "BYPASS" = false + + +Driver Implementer's Guide +========================== + +What does this all mean for driver implementations? As noted above the +colorops can map to HW directly but don't need to do so. Here are some +suggestions on how to think about creating your color pipelines: + +- Try to expose pipelines that use already defined colorops, even if + your hardware pipeline is split differently. This allows existing + userspace to immediately take advantage of the hardware. + +- Additionally, try to expose your actual hardware blocks as colorops. + Define new colorop types where you believe it can offer significant + benefits if userspace learns to program them. + +- Avoid defining new colorops for compound operations with very narrow + scope. If you have a hardware block for a special operation that + cannot be split further, you can expose that as a new colorop type. + However, try to not define colorops for "use cases", especially if + they require you to combine multiple hardware blocks. + +- Design new colorops as prescriptive, not descriptive; by the + mathematical formula, not by the assumed input and output. + +A defined colorop type must be deterministic. The exact behavior of the +colorop must be documented entirely, whether via a mathematical formula +or some other description. Its operation can depend only on its +properties and input and nothing else, allowed error tolerance +notwithstanding. + + +Driver Forward/Backward Compatibility +===================================== + +As this is uAPI drivers can't regress color pipelines that have been +introduced for a given HW generation. New HW generations are free to +abandon color pipelines advertised for previous generations. +Nevertheless, it can be beneficial to carry support for existing color +pipelines forward as those will likely already have support in DRM +clients. + +Introducing new colorops to a pipeline is fine, as long as they can be +bypassed or are purely informational. DRM clients implementing support +for the pipeline can always skip unknown properties as long as they can +be confident that doing so will not cause unexpected results. + +If a new colorop doesn't fall into one of the above categories +(bypassable or informational) the modified pipeline would be unusable +for user space. In this case a new pipeline should be defined. + + +References +========== + +1. https://lore.kernel.org/dri-devel/QMers3awXvNCQlyhWdTtsPwkp5ie9bze_hD5nAccFW7a_RXlWjYB7MoUW_8CKLT2bSQwIXVi5H6VULYIxCdgvryZoAoJnC5lZgyK1QWn488=@emersion.fr/ \ No newline at end of file diff --git a/Documentation/gpu/rfc/index.rst b/Documentation/gpu/rfc/index.rst index 476719771eef..d3726adeca6a 100644 --- a/Documentation/gpu/rfc/index.rst +++ b/Documentation/gpu/rfc/index.rst @@ -31,3 +31,6 @@ host such documentation: .. toctree:: i915_vm_bind.rst + +.. toctree:: + color_pipeline.rst \ No newline at end of file From patchwork Thu Oct 3 20:00: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: 13821500 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 4A96ACF34C4 for ; Thu, 3 Oct 2024 20:02:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BCCF010E91B; Thu, 3 Oct 2024 20:01:46 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="AAVg0JNj"; dkim-atps=neutral Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2044.outbound.protection.outlook.com [40.107.220.44]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7B4BD10E901; Thu, 3 Oct 2024 20:01:44 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qXsTW1XL0ev2v596z6eOxVe/OWtZgzf7ALD1nxdVe3VzCjUJo5fpjhtbkKZJ5WLIfhMzjXcJAlKHN7Uq9L+ubZEwDVG2WTJ/yqOIS0eTS7jVKsyG/IVUiE9oPfbxQ2eN0ttdlnXJTPziQkFGUE/wgSLBgjLnzL2Ej3GoKEBxyblB+m4H3gEBTm3epjjjkf42QgzWEpCSYgRjvr+bUfPduze+Y2uXq2fyEubvSORJxuW6AUlzBZNgvT14ijBXRFAL9RsKc8A0NyD8WroqmAWNhRD6uHK3USTxt3+u0IfHTOhEBuH/VrcaSfDhomWlInV/fEcMGm+FzHM9XJpl/1h3eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=IHXypd5M3zJwPVOHDvQPdC6Kc8BWUKNbz/5RNe0s5NY=; b=Z1cm2BmUynyfYa9AqEa464NEAoLj+gw8i73LTOjHgMmZrcIoFGv6UkR5L1+Gb7HWJYToONSaYG4ehinlFVp7JhlOFNLCKoyKElIPzutllG8MpSBtNHVmkVZtY4EQDw5nF8h5Mqwn88Rkv7ioG0+B5DtnW0u+mDTu5insiLUGQa46K5Z3n2qn6DqUVVyGbuJpF8nQyTnZ0Q7Xee5ZFhX0Q3AYGrwr9iVtNWhMAXGaPyFNaP/mj+rzuGqleOYLau7HhcBj+mRihd+J3J+Jf05qQq/lzDtxCH7t67NHnG75aDRFV2BR/9r2zJhM9I7lh8cUvL/n1eHefLIJ6v9Q1CpbKQ== 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=IHXypd5M3zJwPVOHDvQPdC6Kc8BWUKNbz/5RNe0s5NY=; b=AAVg0JNjoIMeg41vA1aXJWwMQBlCM/JJMAnIFHUkm4DAoZUOOiMPa6fxCzLtLkOp0oB5UYX1eduY+tgWxaYEYsIkpfti4nwLRgU/YmJ1jruZFoKxck+1Iu7MYVRbRR5LnC0+1ZbFRdny9RdIEMtb13C2YN/kv3XBQGogmjHC1M0= Received: from CH2PR14CA0032.namprd14.prod.outlook.com (2603:10b6:610:56::12) by CH2PR12MB4069.namprd12.prod.outlook.com (2603:10b6:610:ac::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.25; Thu, 3 Oct 2024 20:01:36 +0000 Received: from DS2PEPF0000343E.namprd02.prod.outlook.com (2603:10b6:610:56:cafe::cc) by CH2PR14CA0032.outlook.office365.com (2603:10b6:610:56::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:01:36 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS2PEPF0000343E.mail.protection.outlook.com (10.167.18.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:36 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:35 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:35 -0500 From: Harry Wentland To: , CC: , Harry Wentland Subject: [PATCH v6 05/44] drm/colorop: Introduce new drm_colorop mode object Date: Thu, 3 Oct 2024 16:00:47 -0400 Message-ID: <20241003200129.1732122-6-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343E:EE_|CH2PR12MB4069:EE_ X-MS-Office365-Filtering-Correlation-Id: 17eb14d4-49bb-48c4-a058-08dce3e62ff6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: jlaF/htt1XN6w0QZPVMgX0AxmtcvVmiMGYMAwZd1R87jgEl03TjImt79rGVrv8aW8tte0ly+KCScIxdSU8T7kOTOU2eOZFXUfq/qlzmtOAWAVIOos+XcZcJdxg3KP28N/VuYgV8ru+jn4FzjDuLgkjAzxhNZJW6jEHXzzipNUHbDY97qsUWp4yEId3RZCHHEMvG5sGq30iRilrBLFnpOhrzgv7TWspT4Dz31UgYDjJf6EmQkBxUNOTf+yKDn8K599XANmdMSLzuhYNq0ZHkqxcgwUjzGoy2x+4to5+mSAaHRwsbpFBdF0AgpF57+Gsl9yQ1rQbeqv+d9N+bpoE/lkriIP0DLg6gi+y4wlrrwPckQmihk/fCkYLAEsPg+pHEVPHe80aZ0twSy6PfuyUADllCgCVdRzxmkL/4TA9QHktjlo1EVlJYWTOSrIXUlnaUeXeTQwivOUCBKOZ+MpZnK6OaZpy2ecxJ/yUQIH71XiEAR5jskzbrgxVvn52/pUyA8HywSUBY8co5svPs5odpK0gXSQ65d1QKQEdsp9Me0u7knBxaHfgDjTfa7kqD/WX0bG4SjbWmyaNtCj8wF1hjYmqOv57H33ymOvB+RKpqte5qeyI9iosBM5gqPKvLu7rwAMwn+PYScqNn1pN5JotDsa4CFPyIfEsTFoHfPlWJO0juDn93kG8o1CfuDHgN6WKey0ceiT5/bXPrCp1gQJEwvIfZN8clmERiroaMfo+4TCGDEEON8omkCKFfIFCbG6FA153uWsNw4LRGkdoaQsEjdl6BulJLXyOZ1W50YL6Gsobdpw6fKNr0t5LWc0Jg+B3i9KcziYTh4DPmmUZ/5k/0cHsI6dLW2mG7XB0WWbDR9sUk6f3h0Jy0k1Gl+luBwfx1l5QTTo9BWJuH/38Cx2weKh+CyWqK+xGfVAeSmnmUnQblEpyhjFHIDQYkBSdemD9wx4osgvbX8qzTdRSrljfiGQ3VrJPgrHI6WPpgNbdPiCd7EG65uNqoW085TGFdiv+WyARY9d3xZlGleO2uSXvAIE3o5OQCgs6exWwfQ/T3l90iLrSDmafER+tjbdyVaTujeabaS05LNbmVslH0wUuH0mWrLNALDFN0V5duGecIemT28HLhLNej3xaT2YD6+kFOxQsWWfiewI/aeyjA4SHcavZ0CWu8ILGg2TbQJQeFDbxEO2GvGQUA6gk7AxSznOFa+RTXzXEUjmUmF9rFzsTQXKmicRcxXslfOswUcKIn+yt14rhLJFfmmWkhzYUTY/HUxMGR3/y5tC4Xesh64wF9LXBNXGRKWBMI4ME+StsTpWuoc0UHv0AEGvXzmPPVsvwEkON1eXxHy03iBFJTRei86g2EAgo/B9OJGOtcImF7evjIXBTOh2yZGjD2m+nJrjiDP X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700013)(376014)(1800799024)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:36.4724 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 17eb14d4-49bb-48c4-a058-08dce3e62ff6 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF0000343E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4069 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" This patches introduces a new drm_colorop mode object. This object represents color transformations and can be used to define color pipelines. We also introduce the drm_colorop_state here, as well as various helpers and state tracking bits. Signed-off-by: Harry Wentland --- v6: - Comment that properties validity depends on type (Louis Chauvet) v5: - Add comment to drm_atomic_state.colorops - Replace a misplaced 'plane' with 'colorop' in comment - Fix colorop_list kernel doc - Add kernel doc for color_pipeline - drop unused drm_colorop_destroy_state - drop drm_colorop_init, to be introduced in later patch when used - Add kernel docs - Drop TODOs v4: - Drop IOCTL definitions (Pekka) - add missing declaration (Chaitanya Kumar Borah) v3: - Drop TODO for lock (it's handled in drm_modeset_drop_locks) (Melissa) - Don't get plane state when getting colorop state - Make some functions static (kernel test robot) drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/drm_atomic.c | 70 ++++++++++++ drivers/gpu/drm/drm_atomic_helper.c | 12 ++ drivers/gpu/drm/drm_atomic_uapi.c | 48 ++++++++ drivers/gpu/drm/drm_colorop.c | 103 +++++++++++++++++ drivers/gpu/drm/drm_mode_config.c | 7 ++ include/drm/drm_atomic.h | 89 +++++++++++++++ include/drm/drm_atomic_uapi.h | 1 + include/drm/drm_colorop.h | 164 ++++++++++++++++++++++++++++ include/drm/drm_mode_config.h | 18 +++ include/drm/drm_plane.h | 8 ++ include/uapi/drm/drm_mode.h | 1 + 12 files changed, 522 insertions(+) create mode 100644 drivers/gpu/drm/drm_colorop.c create mode 100644 include/drm/drm_colorop.h -- 2.46.2 diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 784229d4504d..055f3e535d15 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -44,6 +44,7 @@ drm-y := \ drm_client.o \ drm_client_modeset.o \ drm_color_mgmt.o \ + drm_colorop.o \ drm_connector.o \ drm_crtc.o \ drm_displayid.o \ diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 0fc99da93afe..327d906c48c5 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -42,6 +42,7 @@ #include #include #include +#include #include "drm_crtc_internal.h" #include "drm_internal.h" @@ -107,6 +108,7 @@ void drm_atomic_state_default_release(struct drm_atomic_state *state) kfree(state->connectors); kfree(state->crtcs); kfree(state->planes); + kfree(state->colorops); kfree(state->private_objs); } EXPORT_SYMBOL(drm_atomic_state_default_release); @@ -138,6 +140,10 @@ drm_atomic_state_init(struct drm_device *dev, struct drm_atomic_state *state) sizeof(*state->planes), GFP_KERNEL); if (!state->planes) goto fail; + state->colorops = kcalloc(dev->mode_config.num_colorop, + sizeof(*state->colorops), GFP_KERNEL); + if (!state->colorops) + goto fail; /* * Because drm_atomic_state can be committed asynchronously we need our @@ -249,6 +255,20 @@ void drm_atomic_state_default_clear(struct drm_atomic_state *state) state->planes[i].new_state = NULL; } + for (i = 0; i < config->num_colorop; i++) { + struct drm_colorop *colorop = state->colorops[i].ptr; + + if (!colorop) + continue; + + drm_colorop_atomic_destroy_state(colorop, + state->colorops[i].state); + state->colorops[i].ptr = NULL; + state->colorops[i].state = NULL; + state->colorops[i].old_state = NULL; + state->colorops[i].new_state = NULL; + } + for (i = 0; i < state->num_private_objs; i++) { struct drm_private_obj *obj = state->private_objs[i].ptr; @@ -568,6 +588,56 @@ drm_atomic_get_plane_state(struct drm_atomic_state *state, } EXPORT_SYMBOL(drm_atomic_get_plane_state); + +/** + * drm_atomic_get_colorop_state - get colorop state + * @state: global atomic state object + * @colorop: colorop to get state object for + * + * This function returns the colorop state for the given colorop, allocating it + * if needed. It will also grab the relevant plane lock to make sure that the + * state is consistent. + * + * Returns: + * + * Either the allocated state or the error code encoded into the pointer. When + * the error is EDEADLK then the w/w mutex code has detected a deadlock and the + * entire atomic sequence must be restarted. All other errors are fatal. + */ +struct drm_colorop_state * +drm_atomic_get_colorop_state(struct drm_atomic_state *state, + struct drm_colorop *colorop) +{ + int ret, index = drm_colorop_index(colorop); + struct drm_colorop_state *colorop_state; + + WARN_ON(!state->acquire_ctx); + + colorop_state = drm_atomic_get_existing_colorop_state(state, colorop); + if (colorop_state) + return colorop_state; + + ret = drm_modeset_lock(&colorop->plane->mutex, state->acquire_ctx); + if (ret) + return ERR_PTR(ret); + + colorop_state = drm_atomic_helper_colorop_duplicate_state(colorop); + if (!colorop_state) + return ERR_PTR(-ENOMEM); + + state->colorops[index].state = colorop_state; + state->colorops[index].ptr = colorop; + state->colorops[index].old_state = colorop->state; + state->colorops[index].new_state = colorop_state; + colorop_state->state = state; + + drm_dbg_atomic(colorop->dev, "Added [COLOROP:%d] %p state to %p\n", + colorop->base.id, colorop_state, state); + + return colorop_state; +} +EXPORT_SYMBOL(drm_atomic_get_colorop_state); + static bool plane_switching_crtc(const struct drm_plane_state *old_plane_state, const struct drm_plane_state *new_plane_state) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index 43cdf39019a4..70ed524bb3c1 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -3022,6 +3022,8 @@ int drm_atomic_helper_swap_state(struct drm_atomic_state *state, struct drm_crtc_state *old_crtc_state, *new_crtc_state; struct drm_plane *plane; struct drm_plane_state *old_plane_state, *new_plane_state; + struct drm_colorop *colorop; + struct drm_colorop_state *old_colorop_state, *new_colorop_state; struct drm_crtc_commit *commit; struct drm_private_obj *obj; struct drm_private_state *old_obj_state, *new_obj_state; @@ -3099,6 +3101,16 @@ int drm_atomic_helper_swap_state(struct drm_atomic_state *state, } } + for_each_oldnew_colorop_in_state(state, colorop, old_colorop_state, new_colorop_state, i) { + WARN_ON(colorop->state != old_colorop_state); + + old_colorop_state->state = state; + new_colorop_state->state = NULL; + + state->colorops[i].state = old_colorop_state; + colorop->state = new_colorop_state; + } + drm_panic_lock(state->dev, flags); for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) { WARN_ON(plane->state != old_plane_state); diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index 7936c2023955..cfc1485b592e 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -642,6 +643,26 @@ drm_atomic_plane_get_property(struct drm_plane *plane, return 0; } + +static int drm_atomic_colorop_set_property(struct drm_colorop *colorop, + struct drm_colorop_state *state, struct drm_file *file_priv, + struct drm_property *property, uint64_t val) +{ + drm_dbg_atomic(colorop->dev, + "[COLOROP:%d] unknown property [PROP:%d:%s]]\n", + colorop->base.id, + property->base.id, property->name); + return -EINVAL; +} + +static int +drm_atomic_colorop_get_property(struct drm_colorop *colorop, + const struct drm_colorop_state *state, + struct drm_property *property, uint64_t *val) +{ + return -EINVAL; +} + static int drm_atomic_set_writeback_fb_for_connector( struct drm_connector_state *conn_state, struct drm_framebuffer *fb) @@ -908,6 +929,16 @@ int drm_atomic_get_property(struct drm_mode_object *obj, plane->state, property, val); break; } + case DRM_MODE_OBJECT_COLOROP: { + struct drm_colorop *colorop = obj_to_colorop(obj); + + if (colorop->plane) + WARN_ON(!drm_modeset_is_locked(&colorop->plane->mutex)); + + ret = drm_atomic_colorop_get_property(colorop, + colorop->state, property, val); + break; + } default: drm_dbg_atomic(dev, "[OBJECT:%d] has no properties\n", obj->id); ret = -EINVAL; @@ -1084,6 +1115,23 @@ int drm_atomic_set_property(struct drm_atomic_state *state, ret = drm_atomic_plane_set_property(plane, plane_state, file_priv, prop, prop_value); + + break; + } + case DRM_MODE_OBJECT_COLOROP: { + struct drm_colorop *colorop = obj_to_colorop(obj); + struct drm_colorop_state *colorop_state; + + colorop_state = drm_atomic_get_colorop_state(state, colorop); + if (IS_ERR(colorop_state)) { + ret = PTR_ERR(colorop_state); + break; + } + + ret = drm_atomic_colorop_set_property(colorop, + colorop_state, file_priv, + prop, prop_value); + break; } default: diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c new file mode 100644 index 000000000000..e005aba7d28a --- /dev/null +++ b/drivers/gpu/drm/drm_colorop.c @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: AMD + * + */ + +#include +#include +#include +#include + +#include "drm_crtc_internal.h" + +static void __drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop, + struct drm_colorop_state *state) +{ + memcpy(state, colorop->state, sizeof(*state)); +} + +struct drm_colorop_state * +drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop) +{ + struct drm_colorop_state *state; + + if (WARN_ON(!colorop->state)) + return NULL; + + state = kmalloc(sizeof(*state), GFP_KERNEL); + if (state) + __drm_atomic_helper_colorop_duplicate_state(colorop, state); + + return state; +} + + +void drm_colorop_atomic_destroy_state(struct drm_colorop *colorop, + struct drm_colorop_state *state) +{ + kfree(state); +} + +/** + * __drm_colorop_state_reset - resets colorop state to default values + * @colorop_state: atomic colorop state, must not be NULL + * @colorop: colorop object, must not be NULL + * + * Initializes the newly allocated @colorop_state with default + * values. This is useful for drivers that subclass the CRTC state. + */ +static void __drm_colorop_state_reset(struct drm_colorop_state *colorop_state, + struct drm_colorop *colorop) +{ + colorop_state->colorop = colorop; +} + +/** + * __drm_colorop_reset - reset state on colorop + * @colorop: drm colorop + * @colorop_state: colorop state to assign + * + * Initializes the newly allocated @colorop_state and assigns it to + * the &drm_crtc->state pointer of @colorop, usually required when + * initializing the drivers or when called from the &drm_colorop_funcs.reset + * hook. + * + * This is useful for drivers that subclass the colorop state. + */ +static void __drm_colorop_reset(struct drm_colorop *colorop, + struct drm_colorop_state *colorop_state) +{ + if (colorop_state) + __drm_colorop_state_reset(colorop_state, colorop); + + colorop->state = colorop_state; +} + +void drm_colorop_reset(struct drm_colorop *colorop) +{ + kfree(colorop->state); + colorop->state = kzalloc(sizeof(*colorop->state), GFP_KERNEL); + + if (colorop->state) + __drm_colorop_reset(colorop, colorop->state); +} diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c index 37d2e0a4ef4b..f238a2f049b0 100644 --- a/drivers/gpu/drm/drm_mode_config.c +++ b/drivers/gpu/drm/drm_mode_config.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include "drm_crtc_internal.h" @@ -182,11 +183,15 @@ int drm_mode_getresources(struct drm_device *dev, void *data, void drm_mode_config_reset(struct drm_device *dev) { struct drm_crtc *crtc; + struct drm_colorop *colorop; struct drm_plane *plane; struct drm_encoder *encoder; struct drm_connector *connector; struct drm_connector_list_iter conn_iter; + drm_for_each_colorop(colorop, dev) + drm_colorop_reset(colorop); + drm_for_each_plane(plane, dev) if (plane->funcs->reset) plane->funcs->reset(plane); @@ -420,6 +425,7 @@ int drmm_mode_config_init(struct drm_device *dev) INIT_LIST_HEAD(&dev->mode_config.property_list); INIT_LIST_HEAD(&dev->mode_config.property_blob_list); INIT_LIST_HEAD(&dev->mode_config.plane_list); + INIT_LIST_HEAD(&dev->mode_config.colorop_list); INIT_LIST_HEAD(&dev->mode_config.privobj_list); idr_init_base(&dev->mode_config.object_idr, 1); idr_init_base(&dev->mode_config.tile_idr, 1); @@ -441,6 +447,7 @@ int drmm_mode_config_init(struct drm_device *dev) dev->mode_config.num_crtc = 0; dev->mode_config.num_encoder = 0; dev->mode_config.num_total_plane = 0; + dev->mode_config.num_colorop = 0; if (IS_ENABLED(CONFIG_LOCKDEP)) { struct drm_modeset_acquire_ctx modeset_ctx; diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h index 31ca88deb10d..8e2af84a0b01 100644 --- a/include/drm/drm_atomic.h +++ b/include/drm/drm_atomic.h @@ -30,6 +30,7 @@ #include #include +#include /** * struct drm_crtc_commit - track modeset commits on a CRTC @@ -157,6 +158,11 @@ struct drm_crtc_commit { bool abort_completion; }; +struct __drm_colorops_state { + struct drm_colorop *ptr; + struct drm_colorop_state *state, *old_state, *new_state; +}; + struct __drm_planes_state { struct drm_plane *ptr; struct drm_plane_state *state, *old_state, *new_state; @@ -408,6 +414,14 @@ struct drm_atomic_state { */ bool duplicated : 1; + /** + * @colorops: + * + * Pointer to array of @drm_colorop and @drm_colorop_state part of this + * update. + */ + struct __drm_colorops_state *colorops; + /** * @planes: * @@ -549,6 +563,9 @@ drm_atomic_get_crtc_state(struct drm_atomic_state *state, struct drm_plane_state * __must_check drm_atomic_get_plane_state(struct drm_atomic_state *state, struct drm_plane *plane); +struct drm_colorop_state * +drm_atomic_get_colorop_state(struct drm_atomic_state *state, + struct drm_colorop *colorop); struct drm_connector_state * __must_check drm_atomic_get_connector_state(struct drm_atomic_state *state, struct drm_connector *connector); @@ -678,6 +695,55 @@ drm_atomic_get_new_plane_state(const struct drm_atomic_state *state, return state->planes[drm_plane_index(plane)].new_state; } + +/** + * drm_atomic_get_existing_colorop_state - get colorop state, if it exists + * @state: global atomic state object + * @colorop: colorop to grab + * + * This function returns the colorop state for the given colorop, or NULL + * if the colorop is not part of the global atomic state. + * + * This function is deprecated, @drm_atomic_get_old_colorop_state or + * @drm_atomic_get_new_colorop_state should be used instead. + */ +static inline struct drm_colorop_state * +drm_atomic_get_existing_colorop_state(struct drm_atomic_state *state, + struct drm_colorop *colorop) +{ + return state->colorops[drm_colorop_index(colorop)].state; +} + +/** + * drm_atomic_get_old_colorop_state - get colorop state, if it exists + * @state: global atomic state object + * @colorop: colorop to grab + * + * This function returns the old colorop state for the given colorop, or + * NULL if the colorop is not part of the global atomic state. + */ +static inline struct drm_colorop_state * +drm_atomic_get_old_colorop_state(struct drm_atomic_state *state, + struct drm_colorop *colorop) +{ + return state->colorops[drm_colorop_index(colorop)].old_state; +} + +/** + * drm_atomic_get_new_colorop_state - get colorop state, if it exists + * @state: global atomic state object + * @colorop: colorop to grab + * + * This function returns the new colorop state for the given colorop, or + * NULL if the colorop is not part of the global atomic state. + */ +static inline struct drm_colorop_state * +drm_atomic_get_new_colorop_state(struct drm_atomic_state *state, + struct drm_colorop *colorop) +{ + return state->colorops[drm_colorop_index(colorop)].new_state; +} + /** * drm_atomic_get_existing_connector_state - get connector state, if it exists * @state: global atomic state object @@ -925,6 +991,29 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p); (new_crtc_state) = (__state)->crtcs[__i].new_state, \ (void)(new_crtc_state) /* Only to avoid unused-but-set-variable warning */, 1)) +/** + * for_each_oldnew_colorop_in_state - iterate over all colorops in an atomic update + * @__state: &struct drm_atomic_state pointer + * @colorop: &struct drm_colorop iteration cursor + * @old_colorop_state: &struct drm_colorop_state iteration cursor for the old state + * @new_colorop_state: &struct drm_colorop_state iteration cursor for the new state + * @__i: int iteration cursor, for macro-internal use + * + * This iterates over all colorops in an atomic update, tracking both old and + * new state. This is useful in places where the state delta needs to be + * considered, for example in atomic check functions. + */ +#define for_each_oldnew_colorop_in_state(__state, colorop, old_colorop_state, new_colorop_state, __i) \ + for ((__i) = 0; \ + (__i) < (__state)->dev->mode_config.num_colorop; \ + (__i)++) \ + for_each_if ((__state)->colorops[__i].ptr && \ + ((colorop) = (__state)->colorops[__i].ptr, \ + (void)(colorop) /* Only to avoid unused-but-set-variable warning */, \ + (old_colorop_state) = (__state)->colorops[__i].old_state,\ + (new_colorop_state) = (__state)->colorops[__i].new_state, 1)) + + /** * for_each_oldnew_plane_in_state - iterate over all planes in an atomic update * @__state: &struct drm_atomic_state pointer diff --git a/include/drm/drm_atomic_uapi.h b/include/drm/drm_atomic_uapi.h index 4c6d39d7bdb2..70a115d523cd 100644 --- a/include/drm/drm_atomic_uapi.h +++ b/include/drm/drm_atomic_uapi.h @@ -37,6 +37,7 @@ struct drm_crtc; struct drm_connector_state; struct dma_fence; struct drm_framebuffer; +struct drm_colorop; int __must_check drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state, diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h new file mode 100644 index 000000000000..df127b4b2123 --- /dev/null +++ b/include/drm/drm_colorop.h @@ -0,0 +1,164 @@ +/* + * Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: AMD + * + */ + +#ifndef __DRM_COLOROP_H__ +#define __DRM_COLOROP_H__ + +#include +#include +#include + +/** + * struct drm_colorop_state - mutable colorop state + */ +struct drm_colorop_state { + /** @colorop: backpointer to the colorop */ + struct drm_colorop *colorop; + + /* + * Color properties + * + * The following fields are not always valid, their usage depends + * on the colorop type. See their associated comment for more + * information. + */ + + /** @state: backpointer to global drm_atomic_state */ + struct drm_atomic_state *state; +}; + +/** + * struct drm_colorop - DRM color operation control structure + * + * A colorop represents one color operation. They can be chained via + * the 'next' pointer to build a color pipeline. + */ +struct drm_colorop { + /** @dev: parent DRM device */ + struct drm_device *dev; + + /** + * @head: + * + * List of all colorops on @dev, linked from &drm_mode_config.colorop_list. + * Invariant over the lifetime of @dev and therefore does not need + * locking. + */ + struct list_head head; + + /** + * @index: Position inside the mode_config.list, can be used as an array + * index. It is invariant over the lifetime of the colorop. + */ + unsigned index; + + /** @base: base mode object */ + struct drm_mode_object base; + + /** + * @plane: + * + * The plane on which the colorop sits. A drm_colorop is always unique + * to a plane. + */ + struct drm_plane *plane; + + /** + * @state: + * + * Current atomic state for this colorop. + * + * This is protected by @mutex. Note that nonblocking atomic commits + * access the current colorop state without taking locks. + */ + struct drm_colorop_state *state; + + /* + * Color properties + * + * The following fields are not always valid, their usage depends + * on the colorop type. See their associated comment for more + * information. + */ + + /** @properties: property tracking for this colorop */ + struct drm_object_properties properties; + +}; + +#define obj_to_colorop(x) container_of(x, struct drm_colorop, base) + +/** + * drm_colorop_find - look up a Colorop object from its ID + * @dev: DRM device + * @file_priv: drm file to check for lease against. + * @id: &drm_mode_object ID + * + * This can be used to look up a Colorop from its userspace ID. Only used by + * drivers for legacy IOCTLs and interface, nowadays extensions to the KMS + * userspace interface should be done using &drm_property. + */ +static inline struct drm_colorop *drm_colorop_find(struct drm_device *dev, + struct drm_file *file_priv, + uint32_t id) +{ + struct drm_mode_object *mo; + mo = drm_mode_object_find(dev, file_priv, id, DRM_MODE_OBJECT_COLOROP); + return mo ? obj_to_colorop(mo) : NULL; +} + +struct drm_colorop_state * +drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop); + +void drm_colorop_atomic_destroy_state(struct drm_colorop *colorop, + struct drm_colorop_state *state); + +/** + * drm_colorop_reset - reset colorop atomic state + * @colorop: drm colorop + * + * Resets the atomic state for @colorop by freeing the state pointer (which might + * be NULL, e.g. at driver load time) and allocating a new empty state object. + */ +void drm_colorop_reset(struct drm_colorop *colorop); + +/** + * drm_colorop_index - find the index of a registered colorop + * @colorop: colorop to find index for + * + * Given a registered colorop, return the index of that colorop within a DRM + * device's list of colorops. + */ +static inline unsigned int drm_colorop_index(const struct drm_colorop *colorop) +{ + return colorop->index; +} + + +#define drm_for_each_colorop(colorop, dev) \ + list_for_each_entry(colorop, &(dev)->mode_config.colorop_list, head) + + +#endif /* __DRM_COLOROP_H__ */ diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h index 271765e2e9f2..d4661d4431dc 100644 --- a/include/drm/drm_mode_config.h +++ b/include/drm/drm_mode_config.h @@ -499,6 +499,24 @@ struct drm_mode_config { */ struct raw_spinlock panic_lock; + /** + * @num_colorop: + * + * Number of colorop objects on this device. + * This is invariant over the lifetime of a device and hence doesn't + * need any locks. + */ + int num_colorop; + + /** + * @colorop_list: + * + * List of colorop objects linked with &drm_colorop.head. This is + * invariant over the lifetime of a device and hence doesn't need any + * locks. + */ + struct list_head colorop_list; + /** * @num_crtc: * diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h index dd718c62ac31..2a9b902623c0 100644 --- a/include/drm/drm_plane.h +++ b/include/drm/drm_plane.h @@ -243,6 +243,14 @@ struct drm_plane_state { */ enum drm_scaling_filter scaling_filter; + /** + * @color_pipeline: + * + * The first colorop of the active color pipeline, or NULL, if no + * color pipeline is active. + */ + struct drm_colorop *color_pipeline; + /** * @commit: Tracks the pending commit to prevent use-after-free conditions, * and for async plane updates. diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index c082810c08a8..d49cded6c568 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -629,6 +629,7 @@ struct drm_mode_connector_set_property { #define DRM_MODE_OBJECT_FB 0xfbfbfbfb #define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb #define DRM_MODE_OBJECT_PLANE 0xeeeeeeee +#define DRM_MODE_OBJECT_COLOROP 0xfafafafa #define DRM_MODE_OBJECT_ANY 0 struct drm_mode_obj_get_properties { From patchwork Thu Oct 3 20:00:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821494 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 D5AD0CF34C1 for ; Thu, 3 Oct 2024 20:01:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3ACA310E8E9; Thu, 3 Oct 2024 20:01:42 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="ERJhMfdv"; dkim-atps=neutral Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2047.outbound.protection.outlook.com [40.107.243.47]) by gabe.freedesktop.org (Postfix) with ESMTPS id AB63510E8E9; Thu, 3 Oct 2024 20:01:41 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=k6rzGjv19t6fOWQ72OZZHBr0qMv59lLCm6+89Na2aDzzV0jiOPMNt71argef9HfSKBm7do1r7i08gOpxuvR0L3uqeu5Gcij6SMUEms7Jo46lvw1UHrAcLvo1hDmL7sMXn5fnK9MfQZ5RaPoZ74tfmdbRD5JPUOX23Kn2kHI2bAS3i3sW0YO5ZkQlnlMMrq/QCyK0ZKbxK71yWQ1ei3dhGTVpxuzLTxFpanxWXSvxtbSjfkHJnBrZ8EonljHtCxHY/apJbRfSlRAHnsqDW/XlzwyPErg++cO61RTMa7xiLWGd7ZLNwXTMNuiErZke/nszCuwnX8Fvs2l4HyflW9dkxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=GI+kFDyq5HszBkiyRQhQfquEU27BOxBkE8J3J2UAn4Y=; b=aiFYqr1SE9uy8xtBMmq+zS51b7ZbR9WQNmx4prRf4sCuJF2VhzP40/Yl6TlUjcBBTO8+o7iyOYxU5Qj49TNHRT/Xsg1b82DJrBnyOXjrADrFtZSa1ZNMZNdMtgmJXjBQ2sZt3beU50xb6t2vdlWGGSV1nYKDicUAhn2IJIa7sH0HXKaIX6Jy8B4jzuniHy1lkdAx2gq0yOqUXjxrxI6EaRJXWvto14gywWL4TLUqZ1pmvzGPwPMMN0KBoZVdPE/GM9Ydo7+mIQ17AJ9b/9nrKmeYKuy6D75DH7Wv2b2KAsyLZv+03GTPkic/Bv1tl++cMPj6pTMTGm/zR/zT7IGr/Q== 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=GI+kFDyq5HszBkiyRQhQfquEU27BOxBkE8J3J2UAn4Y=; b=ERJhMfdvEilHbXID/PNuf2PUHdXH6GEddYDSC4HfRADrNyLBGdBP7ZecCmprYt9dWHyaE/K7FfC1T9Z87ArWXqgtI4PW0vtGFVanERPYhG5i5l6JeFnbwdX4aNvxHOWqyEcFEul7vp9eV6AEtUefoLVbJjlq18v3ArXRfO/WbmU= Received: from CH2PR14CA0052.namprd14.prod.outlook.com (2603:10b6:610:56::32) by CY8PR12MB7313.namprd12.prod.outlook.com (2603:10b6:930:53::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.27; Thu, 3 Oct 2024 20:01:37 +0000 Received: from DS2PEPF0000343E.namprd02.prod.outlook.com (2603:10b6:610:56:cafe::4a) by CH2PR14CA0052.outlook.office365.com (2603:10b6:610:56::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:01:37 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS2PEPF0000343E.mail.protection.outlook.com (10.167.18.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:37 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:35 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:35 -0500 From: Harry Wentland To: , CC: , Harry Wentland Subject: [PATCH v6 06/44] drm/colorop: Add TYPE property Date: Thu, 3 Oct 2024 16:00:48 -0400 Message-ID: <20241003200129.1732122-7-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343E:EE_|CY8PR12MB7313:EE_ X-MS-Office365-Filtering-Correlation-Id: 12dbc7ab-ccf2-4fd1-ebaf-08dce3e63042 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: eKgtv1742ygGv5f8zTpqGUHcdv07eBUsqsYDUOvtwfBBTkh9MF0yliJmSZGqHpjFAAkrFG5XqBJKsQN5LLC8p651vG5Z5hcmIYIp6ZvTnerQ18i2Sn2kLU7wfUiT7KqvT/tRK6qCIVDdU9F+WnLB5vTIkzAd9IQUHjSqINPPWV5qh8GdrWRzPNUyp2sbnikhvuq3ODULO8jNkRe+rT0Si/EaFCepsSL8WLiKwA9VlIJFoaF5hQLnHTuoVIo6p2PqDUso0sFS1rHH0bvn6XmuPxtOcAoPTrEm6EO7NeXz1Yum6PjVYchoEqaXDDJ3VVSCIrvH4VCkIm8bFZxTOU65hGGOz+q4C76xcnRZyJggVPAojwSb67W88+tlVrCEHjvjz7evZfeMO8WH/I9ZFm79mcWoRx9RQxESJgHJIKA+L4E7BKQoBshRfWAcLoYCTSl0yPbXX/8v7YVINngJNScpbfQFn4xp/56vsapov9TV89y7v+ILY3+Bcakn0U9w/MXOM1jih0TtrbvZng2mjSstIuAZcVYRrIR7VfMsATIRvKlBOefMdeIkm+QIlo0uRYpeqV2v8JKcW3rtf5arjCngInOTWkqu/NUa7RaStl63HftcxBmCz4PwrkLXSG4g/WQsCTgk2R2n2OMqYH6cpfAUUGvlE71D07GRl7lCStAt4j3l7ShS71eUeR3nCYQKINiLufBGrsn8Pas6KyYF6W29PKY4i9l+Cn8xPJXpY/eMKvgx6jCZsWb8IAtUrT6CrZDUwdtzx/Hgsqd83bVSHj78OD7ydDwpAbdqIZjbOJknOBxctcFu9tPyELSBqb3rQGOGE0+bCN8JPF8290dQCpyJakmNFF1Waj3KDx2NAoFQawiL/W+efV61qoRUipES8V7fCiTKs54uVKuLlsYtT9VS/ElsPWSoKwGx51Q+ZeM/s3+mXxJM7Wvz+Po79n6SmyE4UsSkLSacGVhOaAamah4t5EalmC6bJvF0A9lwgScvcUV0PoXwV/Bq7+8JmKyN1G82yLPmHLaeyIh8ZJka01kKbSyoZUlPP2thFKOR7uO5cJswONq74jrHzsGN2pI9oYpnrRMNudcap27T0EVzEqKN+A0DTQi8Eq1RJvsc16SspsKGIjZwC4sfMvUDORNKiQOT7m1XQQShunxnEww62GUQWCa72eQVx+Kz2ZZD0icP3ro9vabWozcWNcrbjF9cKEI5cTICaYglE+cbN3Pn4WAJ/cUKMy7EpacGYjotr/JbZTNrHhI8Neu1YTodn6+VsFLOv28yS/1X7o/QnoxPN2W+1htDqyfzLV1V3DqSkDVBoNXFnJbi8wDNmpm5Fr3Od3lko5dZMBGZGrIiZI8NwHBf2WZ8QQd7Wb/1ycDZHiCcMSFP3lT6CiAIvvx3x3EM61ZC X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(376014)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:37.0193 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 12dbc7ab-ccf2-4fd1-ebaf-08dce3e63042 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF0000343E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7313 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" Add a read-only TYPE property. The TYPE specifies the colorop type, such as enumerated curve, 1D LUT, CTM, 3D LUT, PWL LUT, etc. For now we're only introducing an enumerated 1D LUT type to illustrate the concept. Signed-off-by: Harry Wentland --- v6: - fix doc typo (Alex Hung) v5: - Add drm_get_colorop_type_name in header - Add kernel docs v4: - Use enum property for TYPE (Pekka) v3: - Make TYPE a range property - Move enum drm_colorop_type to uapi header - Fix drm_get_colorop_type_name description drivers/gpu/drm/drm_atomic.c | 4 ++-- drivers/gpu/drm/drm_atomic_uapi.c | 8 +++++++- drivers/gpu/drm/drm_colorop.c | 12 ++++++++++++ include/drm/drm_colorop.h | 23 +++++++++++++++++++++++ include/uapi/drm/drm_mode.h | 17 +++++++++++++++++ 5 files changed, 61 insertions(+), 3 deletions(-) -- 2.46.2 diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 327d906c48c5..44c5b5dd8b33 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -631,8 +631,8 @@ drm_atomic_get_colorop_state(struct drm_atomic_state *state, state->colorops[index].new_state = colorop_state; colorop_state->state = state; - drm_dbg_atomic(colorop->dev, "Added [COLOROP:%d] %p state to %p\n", - colorop->base.id, colorop_state, state); + drm_dbg_atomic(colorop->dev, "Added [COLOROP:%d:%d] %p state to %p\n", + colorop->base.id, colorop->type, colorop_state, state); return colorop_state; } diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index cfc1485b592e..59fc25b59100 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -660,7 +660,13 @@ drm_atomic_colorop_get_property(struct drm_colorop *colorop, const struct drm_colorop_state *state, struct drm_property *property, uint64_t *val) { - return -EINVAL; + if (property == colorop->type_property) { + *val = colorop->type; + } else { + return -EINVAL; + } + + return 0; } static int drm_atomic_set_writeback_fb_for_connector( diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c index e005aba7d28a..79af42b349a0 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -101,3 +101,15 @@ void drm_colorop_reset(struct drm_colorop *colorop) if (colorop->state) __drm_colorop_reset(colorop, colorop->state); } + +static const char * const colorop_type_name[] = { + [DRM_COLOROP_1D_CURVE] = "1D Curve", +}; + +const char *drm_get_colorop_type_name(enum drm_colorop_type type) +{ + if (WARN_ON(type >= ARRAY_SIZE(colorop_type_name))) + return "unknown"; + + return colorop_type_name[type]; +} diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h index df127b4b2123..877e3054e46e 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -106,6 +106,21 @@ struct drm_colorop { /** @properties: property tracking for this colorop */ struct drm_object_properties properties; + /** + * @type: + * + * Read-only + * Type of color operation + */ + enum drm_colorop_type type; + + /** + * @type_property: + * + * Read-only "TYPE" property for specifying the type of + * this color operation. The type is enum drm_colorop_type. + */ + struct drm_property *type_property; }; #define obj_to_colorop(x) container_of(x, struct drm_colorop, base) @@ -160,5 +175,13 @@ static inline unsigned int drm_colorop_index(const struct drm_colorop *colorop) #define drm_for_each_colorop(colorop, dev) \ list_for_each_entry(colorop, &(dev)->mode_config.colorop_list, head) +/** + * drm_get_colorop_type_name - return a string for colorop type + * @type: colorop type to compute name of + * + * In contrast to the other drm_get_*_name functions this one here returns a + * const pointer and hence is threadsafe. + */ +const char *drm_get_colorop_type_name(enum drm_colorop_type type); #endif /* __DRM_COLOROP_H__ */ diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index d49cded6c568..53985d2b7eea 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -858,6 +858,23 @@ struct drm_color_lut { __u16 reserved; }; +/** + * enum drm_colorop_type - Type of color operation + * + * drm_colorops can be of many different types. Each type behaves differently + * and defines a different set of properties. This enum defines all types and + * gives a high-level description. + */ +enum drm_colorop_type { + /** + * @DRM_COLOROP_1D_CURVE: + * + * A 1D curve that is being applied to all color channels. The + * curve is specified via the CURVE_1D_TYPE colorop property. + */ + DRM_COLOROP_1D_CURVE +}; + /** * struct drm_plane_size_hint - Plane size hints * @width: The width of the plane in pixel From patchwork Thu Oct 3 20:00:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821499 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 BF9FACF34C1 for ; Thu, 3 Oct 2024 20:01:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CD6E010E915; Thu, 3 Oct 2024 20:01:45 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="ByCDOMws"; dkim-atps=neutral Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2040.outbound.protection.outlook.com [40.107.93.40]) by gabe.freedesktop.org (Postfix) with ESMTPS id C65BB10E90A; Thu, 3 Oct 2024 20:01:44 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ycoGgKCqJKcEkgJ79ZyTa0T2dffkunmt0Nsa63mTQsdE27SeeuebKiXXc6IRhXjeaRNe5LIkHgaYJ4JoqC2m+Zl/okkemA/cPwCNrymKy/ai4wLuN977fy+njKqA7B1NJz5pjlR+9Y+Lkou/vPoIIx+pKgPrx1UZmKyEkuAyn5a0JOcMD4a0wUaYFh7KCtqM5nw/WqGYbSYTyWE1ujoLkY1INm46dMuocHfxKQIqp1KfyXyqJJCytrt32cprVfOwTQrhE0UaMkHir8t4GZShoj6mQ6ghtsM8j4SXM9KIWsAP9Nnoj3jHSjquK4ZMA2aZZSiZ1uLNMHF52VSawHrDQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=WkgJvEuoQPSLN1VMGTdRHsb0qj/Wj91aA47NDzrVBs0=; b=cETgMqc4Gymr9akNLRSd/Bax6MLStCGiqMnFXhNR0XUMK9hTmt4WBoDA/jMz39Qhoaq9wxOrYpLJCF4f/patGMjJCI2jgb6A7OUI6TBXwgcya1mfSeeY/e7VORkK01SONVO76Ai2VDLHVMse/VcwTkgCuNhJOQyn0uZ4JaUkbcNIrn+0UJiSH6NwkhVhIJP1D5iQwQ9lnzPeRrBSD8f9JQYAkBDRM1u/I2io+DvKDb3jG/4J2krNKo/1ViUSvrAN/2pUy47Tja543ceNLUBgefv57HOfgpitokZl3AYN9nCvOS2RZLsiA1LHbnD9ew16V/YnEVVhuIV2Cd54ADDyBw== 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=WkgJvEuoQPSLN1VMGTdRHsb0qj/Wj91aA47NDzrVBs0=; b=ByCDOMwskbJ1d8hwJmoMS9v7yS7hC1cr18eAdQsBZXn3hO5AClMF4Gmscvruv9aJ6VXiw4Aqlwv7l3bPz/5xzA0cpIJqZKJ8W1jIZ1KmhemWunCvD8v5C4eUlu+ZGMb5Gmka5g4h4pSAei9GwAeGgbDciJZSmg3Ie9rjnNEFGSE= Received: from CH0PR03CA0078.namprd03.prod.outlook.com (2603:10b6:610:cc::23) by DM6PR12MB4140.namprd12.prod.outlook.com (2603:10b6:5:221::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.15; Thu, 3 Oct 2024 20:01:37 +0000 Received: from CH2PEPF00000140.namprd02.prod.outlook.com (2603:10b6:610:cc:cafe::68) by CH0PR03CA0078.outlook.office365.com (2603:10b6:610:cc::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:01:37 +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 CH2PEPF00000140.mail.protection.outlook.com (10.167.244.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:37 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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.39; Thu, 3 Oct 2024 15:01:37 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:37 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:36 -0500 From: Harry Wentland To: , CC: , Harry Wentland , Alex Hung Subject: [PATCH v6 07/44] drm/colorop: Add 1D Curve subtype Date: Thu, 3 Oct 2024 16:00:49 -0400 Message-ID: <20241003200129.1732122-8-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB05.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000140:EE_|DM6PR12MB4140:EE_ X-MS-Office365-Filtering-Correlation-Id: 05f56ec6-4aa2-4f24-cdc2-08dce3e630a2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: Leu/rNz/s+3mg+xxIQBLXR0A5JMHIiHydZ31AVrg7HPBn9PS4IyhMPfydaW6yPcaK+i9IMhwyn4Y0p3EfUMCG6uw497L24MFVO+u8Qp3eFRZgZrZH5oNxsWSYVcjXpRkEE0lMv1Hr8ICZkGAygqbcnVyOAyjq7CVIdpFd3KVrk8YkywdbP73RENm6zNaAgcgjIUPXLqbBB2+hs7HqVeBgKoLPdFBELTlPT+smhJN29GttveId9JSPq9P+gGULUV5DxafNHD7H4Yt01d1Xhlg5id/HxW6RjMJPqiG+V3LMbU/qlvQCJfzDBs/AA2gFAuv40/mam6kQg3DvNT6R04WaC1fNZK/VTHIAB30lINS/HTtgZTOjW6Khh+F7fVu/cwFlfDpY1JrAByOYUviaSTUHrUigxTFhpaQ8Lw64MdGSkjhJxTetr4f1Dr2ZoQCDS2LnCtEsUmDriwcWVZaWJE5r+z/22Yl6qRgFAVQnaLCJe1X6yJnBr0ucik8nvkiOTVT/cOPUkmskp8PJpSj2ZTN13kFhQtlKy7gWXOMHEq1egeshHqqCwPRIQuMxqVQLPSTwjKnbebb+BbXAytHJFOqWn6LEzSPTpEyPgTFfaFLRNQRLTljDpQAlg7yvVPOyP6QS2bt1g/WjsGJPyFWKo+DXDkFi0zKeohrMyRCXnSnQmgD20QY1PbgcvRwTZj0B5X2YM5aNMjU0StDuyOPjwBVNL9YFhSUQ9NKp6Kd581GN7kMm0KWf0zXIbOMG3L3Ih0VXlg5QkeexnNZfM6R4MuETxicRr4x6a7KbdtigM1mnoVBS/lwKi53LkL/hTfg2F25iLDJuxL+Sc6Gd0pQNJ7KCeqBXMMIrTmfkYSXbTBsh1+RZxnRclvWEkPGsQk2Q1HNO8YMHR9lZEBBq4Hyp3BZangx57F5OXTEu1yVvo0nDtxwNZ0QsUeomDsMErY1pE97ddPREZNzwtPDk9HACdOTmhejxDmsQtZ9tDDthflqo5pe2cG988lmB8PsS8Pd72ZdCXa3V0HOus5oxhjSU1BHTHHX+r3KO5xn1FWVgN0RhAn8OMykbOG5nZtRntnii3CwlAzfD4Jfhq3UX8p9XiB//8FKmv+TJ6ynQKXHBVTYAI4TDGDolHeQM/OrgmvJ9dm1t5o2z2A6GcuWu8yomCjpO+MtqHDfOaBnlyMKXlhWLXVMSh4/sT2LxE3cl3lPjuVz7rNeuBfk4I8FbAXFnp1/9F8Nkmot0srY1vwh377pX+zacp9tXgo4J9Qaa2XugLXoTWvB6x65W1ggJW0vN+LcICdAH1jswOgYJJoBEUUSj9Xo/rcgqzOan4f3d4PCL/b/Ijx0/yJk7WZDShf3AJJlgTnE6pxRJxRSZwghBgIi5Ta7LquHkSwG2iVrQANm6IYb 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:(13230040)(376014)(36860700013)(1800799024)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:37.6633 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 05f56ec6-4aa2-4f24-cdc2-08dce3e630a2 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: CH2PEPF00000140.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4140 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" Signed-off-by: Harry Wentland Signed-off-by: Alex Hung Co-developed-by: Alex Hung --- v5: - Add drm_get_colorop_curve_1d_type_name in header - Add drm_colorop_init - Set default curve - Add kernel docs v4: - Use drm_colorop_curve_1d_type_enum_list to get name (Pekka) - Create separate init function for 1D curve - Pass supported TFs into 1D curve init function drivers/gpu/drm/drm_atomic_uapi.c | 18 ++-- drivers/gpu/drm/drm_colorop.c | 134 ++++++++++++++++++++++++++++++ include/drm/drm_colorop.h | 60 +++++++++++++ 3 files changed, 207 insertions(+), 5 deletions(-) -- 2.46.2 diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index 59fc25b59100..9a5dbf0a1306 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -648,11 +648,17 @@ static int drm_atomic_colorop_set_property(struct drm_colorop *colorop, struct drm_colorop_state *state, struct drm_file *file_priv, struct drm_property *property, uint64_t val) { - drm_dbg_atomic(colorop->dev, - "[COLOROP:%d] unknown property [PROP:%d:%s]]\n", - colorop->base.id, - property->base.id, property->name); - return -EINVAL; + if (property == colorop->curve_1d_type_property) { + state->curve_1d_type = val; + } else { + drm_dbg_atomic(colorop->dev, + "[COLOROP:%d:%d] unknown property [PROP:%d:%s]]\n", + colorop->base.id, colorop->type, + property->base.id, property->name); + return -EINVAL; + } + + return 0; } static int @@ -662,6 +668,8 @@ drm_atomic_colorop_get_property(struct drm_colorop *colorop, { if (property == colorop->type_property) { *val = colorop->type; + } else if (property == colorop->curve_1d_type_property) { + *val = state->curve_1d_type; } else { return -EINVAL; } diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c index 79af42b349a0..98d22ac163e8 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -30,6 +30,123 @@ #include "drm_crtc_internal.h" +static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { + { DRM_COLOROP_1D_CURVE, "1D Curve" }, +}; + +static const char * const colorop_curve_1d_type_names[] = { + [DRM_COLOROP_1D_CURVE_SRGB_EOTF] = "sRGB EOTF", + [DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF] = "sRGB Inverse EOTF", +}; + + +/* Init Helpers */ + +static int drm_colorop_init(struct drm_device *dev, struct drm_colorop *colorop, + struct drm_plane *plane, enum drm_colorop_type type) +{ + struct drm_mode_config *config = &dev->mode_config; + struct drm_property *prop; + int ret = 0; + + ret = drm_mode_object_add(dev, &colorop->base, DRM_MODE_OBJECT_COLOROP); + if (ret) + return ret; + + colorop->base.properties = &colorop->properties; + colorop->dev = dev; + colorop->type = type; + colorop->plane = plane; + + list_add_tail(&colorop->head, &config->colorop_list); + colorop->index = config->num_colorop++; + + /* add properties */ + + /* type */ + prop = drm_property_create_enum(dev, + DRM_MODE_PROP_IMMUTABLE, + "TYPE", drm_colorop_type_enum_list, + ARRAY_SIZE(drm_colorop_type_enum_list)); + + if (!prop) + return -ENOMEM; + + colorop->type_property = prop; + + drm_object_attach_property(&colorop->base, + colorop->type_property, + colorop->type); + + return ret; +} + +/** + * drm_colorop_curve_1d_init - Initialize a DRM_COLOROP_1D_CURVE + * + * @dev: DRM device + * @colorop: The drm_colorop object to initialize + * @plane: The associated drm_plane + * @supported_tfs: A bitfield of supported drm_colorop_curve_1d_init enum values, + * created using BIT(curve_type) and combined with the OR '|' + * operator. + * @return zero on success, -E value on failure + */ +int drm_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop, + struct drm_plane *plane, u64 supported_tfs) +{ + struct drm_prop_enum_list enum_list[DRM_COLOROP_1D_CURVE_COUNT]; + int i, len; + + struct drm_property *prop; + int ret; + + if (!supported_tfs) { + drm_err(dev, + "No supported TFs for new 1D curve colorop on [PLANE:%d:%s]\n", + plane->base.id, plane->name); + return -EINVAL; + } + + if ((supported_tfs & -BIT(DRM_COLOROP_1D_CURVE_COUNT)) != 0) { + drm_err(dev, "Unknown TF provided on [PLANE:%d:%s]\n", + plane->base.id, plane->name); + return -EINVAL; + } + + ret = drm_colorop_init(dev, colorop, plane, DRM_COLOROP_1D_CURVE); + if (ret) + return ret; + + len = 0; + for (i = 0; i < DRM_COLOROP_1D_CURVE_COUNT; i++) { + if ((supported_tfs & BIT(i)) == 0) + continue; + + enum_list[len].type = i; + enum_list[len].name = colorop_curve_1d_type_names[i]; + len++; + } + + if (WARN_ON(len <= 0)) + return -EINVAL; + + + /* initialize 1D curve only attribute */ + prop = drm_property_create_enum(dev, DRM_MODE_PROP_ATOMIC, "CURVE_1D_TYPE", + enum_list, len); + if (!prop) + return -ENOMEM; + + colorop->curve_1d_type_property = prop; + drm_object_attach_property(&colorop->base, colorop->curve_1d_type_property, + enum_list[0].type); + drm_colorop_reset(colorop); + + return 0; +} +EXPORT_SYMBOL(drm_colorop_curve_1d_init); + static void __drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop, struct drm_colorop_state *state) { @@ -69,7 +186,16 @@ void drm_colorop_atomic_destroy_state(struct drm_colorop *colorop, static void __drm_colorop_state_reset(struct drm_colorop_state *colorop_state, struct drm_colorop *colorop) { + u64 val; + colorop_state->colorop = colorop; + + if (colorop->curve_1d_type_property) { + drm_object_property_get_default_value(&colorop->base, + colorop->curve_1d_type_property, + &val); + colorop_state->curve_1d_type = val; + } } /** @@ -113,3 +239,11 @@ const char *drm_get_colorop_type_name(enum drm_colorop_type type) return colorop_type_name[type]; } + +const char *drm_get_colorop_curve_1d_type_name(enum drm_colorop_curve_1d_type type) +{ + if (WARN_ON(type >= ARRAY_SIZE(colorop_curve_1d_type_names))) + return "unknown"; + + return colorop_curve_1d_type_names[type]; +} diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h index 877e3054e46e..6b8722ea22c7 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -30,6 +30,39 @@ #include #include + +/** + * enum drm_colorop_curve_1d_type - type of 1D curve + * + * Describes a 1D curve to be applied by the DRM_COLOROP_1D_CURVE colorop. + * + */ +enum drm_colorop_curve_1d_type { + /** + * @DRM_COLOROP_1D_CURVE_SRGB_EOTF: + * + * sRGB piece-wise electro-optical transfer function. Transfer + * characteristics as defined by IEC 61966-2-1 sRGB. Equivalent + * to H.273 TransferCharacteristics code point 13 with + * MatrixCoefficients set to 0. + */ + DRM_COLOROP_1D_CURVE_SRGB_EOTF, + + /** + * @DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF: + * + * The inverse of &DRM_COLOROP_1D_CURVE_SRGB_EOTF + */ + DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF, + + /** + * @DRM_COLOROP_1D_CURVE_COUNT: + * + * enum value denoting the size of the enum + */ + DRM_COLOROP_1D_CURVE_COUNT +}; + /** * struct drm_colorop_state - mutable colorop state */ @@ -45,6 +78,13 @@ struct drm_colorop_state { * information. */ + /** + * @curve_1d_type: + * + * Type of 1D curve. + */ + enum drm_colorop_curve_1d_type curve_1d_type; + /** @state: backpointer to global drm_atomic_state */ struct drm_atomic_state *state; }; @@ -121,6 +161,14 @@ struct drm_colorop { * this color operation. The type is enum drm_colorop_type. */ struct drm_property *type_property; + + /** + * @curve_1d_type_property: + * + * Sub-type for DRM_COLOROP_1D_CURVE type. + */ + struct drm_property *curve_1d_type_property; + }; #define obj_to_colorop(x) container_of(x, struct drm_colorop, base) @@ -144,6 +192,9 @@ static inline struct drm_colorop *drm_colorop_find(struct drm_device *dev, return mo ? obj_to_colorop(mo) : NULL; } +int drm_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop, + struct drm_plane *plane, u64 supported_tfs); + struct drm_colorop_state * drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop); @@ -184,4 +235,13 @@ static inline unsigned int drm_colorop_index(const struct drm_colorop *colorop) */ const char *drm_get_colorop_type_name(enum drm_colorop_type type); +/** + * drm_get_colorop_curve_1d_type_name - return a string for 1D curve type + * @type: 1d curve type to compute name of + * + * In contrast to the other drm_get_*_name functions this one here returns a + * const pointer and hence is threadsafe. + */ +const char *drm_get_colorop_curve_1d_type_name(enum drm_colorop_curve_1d_type type); + #endif /* __DRM_COLOROP_H__ */ From patchwork Thu Oct 3 20:00:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821496 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 BE679CF34C1 for ; Thu, 3 Oct 2024 20:01:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 57A4F10E8FC; Thu, 3 Oct 2024 20:01:44 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="CNxhX5Lk"; dkim-atps=neutral Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2082.outbound.protection.outlook.com [40.107.220.82]) by gabe.freedesktop.org (Postfix) with ESMTPS id DFDA910E8F2; Thu, 3 Oct 2024 20:01:42 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SIlZueeLRRz18turLjuGFx3gw8VPLg2UGFSDJF1EV3KSzSWhTaM/yRTtOC7hXgb3rTVQuIvqP51QX1ERsQ0Jhk+/kVbhytU45f5v/rDH0/byf1pYkWQauoCSi361Trlj6ME59M42lCdQNHD1PAu1gel1K1rySSok7tPsJO6xPVNV88IA4OnW5Nl0asMi07FYyTuUCgaLqcFxiT+bSXWwOvKIp+k5PWPuFV7PfkAuV3qlyNrIp3+tTTiFHK7ATtHzR4yFDkhLk0IP6xlaM2QgWy9wBlx3PY7nkrhbIMO9xqXPU1qpuVRzPUmP63z/M70LJAgWr0GAYc8xsGbFYQnOSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=b2+bviKUSTa9gVfLALtIAE9OtEO6eW+RBqn7qKp8BLQ=; b=S5ci39vP4YTgusw3IecsaRhh8NQBeu0Pdccaohu5aw6sePbvJsIjLdiKb2IndnE3pe0IbLksQBqMID/Pg1q5juRNzM0nJm36JZLFD8Q6KHpF+uwZ2jw0I+Yn19nEoNllucgvpM/ir9L5KtKK+Yv3mIwXJi2cCBvA0jOaZLMTU35AUXODKFX+ozIM7NL6vxYCAze+ONju02Km/6ofyJocyXN0YIgOUapCmZklURI0fd8PqiUD27hTVfcaZSi44RKHPx4KplTUovGvi5Lu3DQPo6jwV79TaubIAw/U7Pys2ARCcq1+6pCD+IB1+khhiaJPAng6DX/w9T6ccw/X5arsJw== 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=b2+bviKUSTa9gVfLALtIAE9OtEO6eW+RBqn7qKp8BLQ=; b=CNxhX5LkyNTvar6aCf6XT7kyVDgL0mus7IQy10D+P+SC5Ahvo/cdgaWs6Ori4lMk1CS6LhF2DBYiy7RbFfZwR3OcGMSdLyeWBaiKkwsJx4t+AMWHNo4tT1WQr0sH2Y7YNLJQ7XGtOA2l8BOreP4lTtTtZlfRHXVaozDoa1ZTg10= Received: from CH2PR14CA0044.namprd14.prod.outlook.com (2603:10b6:610:56::24) by SA3PR12MB7901.namprd12.prod.outlook.com (2603:10b6:806:306::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.29; Thu, 3 Oct 2024 20:01:38 +0000 Received: from DS2PEPF0000343E.namprd02.prod.outlook.com (2603:10b6:610:56:cafe::4a) by CH2PR14CA0044.outlook.office365.com (2603:10b6:610:56::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:01:37 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS2PEPF0000343E.mail.protection.outlook.com (10.167.18.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:37 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:37 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:37 -0500 From: Harry Wentland To: , CC: , Harry Wentland Subject: [PATCH v6 08/44] Documentation/gpu: document drm_colorop Date: Thu, 3 Oct 2024 16:00:50 -0400 Message-ID: <20241003200129.1732122-9-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343E:EE_|SA3PR12MB7901:EE_ X-MS-Office365-Filtering-Correlation-Id: 06e38070-0083-47bb-83b7-08dce3e630bc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|82310400026|376014|36860700013; X-Microsoft-Antispam-Message-Info: vbmrQ5yRW2342I3phUAW2FHzJArM95CvqFTOkzRTeswUwdUfTjgKAMYfbyrMcmftVsK7WmWt/BJFd5iQxHmGNOMwypTeZQ2L/rn8fL5rbBdddHJP5YY5rEvoLEnqkyzpA2M0vhtgdlj2WWPEAkmkZcxvHXrXguuZzXeRjec0X1hY3UeN/3MHZyS6LGydjRirz7H6L6V4MbpUUrMExnskv4lpk4nL0pRQik//In7TmIvoh/5pGvR0IS/d/j4x/rf6SuD6gMc6vZ2V20hx6BFD2zAxtUcDVO0M0kHkBU+LgQRTS92097BTYfwCfsGqSUPP7JVg6xKB3JlC3XHtWKvKJZ/BJRsLKJQTwgW3fTPOZdD8aOEFPUpEC8Z7AF2t1Ny44BIjOh8lQGG+b4EYoqkGXCPFBQoPL7WlSeT495VESq+ML0T4icwM6E8n4PIqZ0lsCE2MOJhU6n5ZzMWzZHP1ycrwtzNp4ktJZXgXa5B4kCHfQXRvbXokOkVjR7mAX6Dc88qLnVS2mU7U9bUBRcX/2AHpv9ZXkY4ZCgC5oQQrd0H/DjaLuJB/XsR9p/yvlkH6LufK0U/jA+wRMgdRrJmuQSGffVNH3M2c2uHVwlVDLdTh5R3Hesu6c1AWBU3J4y4bzX7Ixm+BmmD+KmVp2s3XfYFBe3bJIvdBuq15jddiL7yR/6c4JXcN1jsvt83nQ7uwJ/8WbuYOKQ7d0WKFkobU1nzyF/JPeOIoLMhLqF10SjEWcNYn9GOoVqJb1uDF3vKRyXpBh7t2kOs1xZiV90Hkdva/MOThhl6vZ/Otf4QHI4XG1sXJLq7TyEcHwlbhpCh6V6ElxKIRmpFd5FkQ5V4+mxXmbldRE9wVz3zWsU9paYeMkzi/c6kuepMqa3Vr8xGiGvg4B+4jpqRMnSw1kNKBm4JqDYSKTzEyjfy7AAZBK0cXJUAsNwvbT0tEqOpFkjTj+sePC1ofR2Nkt2+wYOqpDRITH6mQuy4Wr7svDtF/SA2kznmKHkuhYJpWX8qTa+5BI7pZVG/k1usgN9RD98Hf4R5VwNYQjDL4r6FRmSAhz59QTWT6dZBRFYL0jyF8zV2LHUK7K24GHgSt4fY0KEz/azaxX9X/8fXNNivF3UBVRdHwolrI6kYqs6Ou3bBFO0SwWM2HuwoJwMl0iqjDSQXT8DCpnbkeGdZzL4HBKPtakfWR7LIPllPi/QLlZi8a4bA4XC8C19ev0fb4BBPqPxuXoC/DjCtrJMthQfkr1I+UFjcNmoUYctGb/R3cXNLqJx0NM7msYG9FBTkiqzTephTaxEr/rKstH1Rv8Y7cO8plHY5e0kIQ4RvGqFscK5pN/YGc/Y0vjTPxF8JQJ34sXwBrvvUasRoH2XwICkbsqoIgxfNTGzB+825DQG44qeL0acwj X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(82310400026)(376014)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:37.8161 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 06e38070-0083-47bb-83b7-08dce3e630bc 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF0000343E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7901 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" Signed-off-by: Harry Wentland --- v5: - Drop TODO Documentation/gpu/drm-kms.rst | 15 +++++++++++++++ drivers/gpu/drm/drm_colorop.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) -- 2.46.2 diff --git a/Documentation/gpu/drm-kms.rst b/Documentation/gpu/drm-kms.rst index abfe220764e1..2292e65f044c 100644 --- a/Documentation/gpu/drm-kms.rst +++ b/Documentation/gpu/drm-kms.rst @@ -413,6 +413,21 @@ Plane Panic Functions Reference .. kernel-doc:: drivers/gpu/drm/drm_panic.c :export: +Colorop Abstraction +=================== + +.. kernel-doc:: drivers/gpu/drm/drm_colorop.c + :doc: overview + +Colorop Functions Reference +--------------------------- + +.. kernel-doc:: include/drm/drm_colorop.h + :internal: + +.. kernel-doc:: drivers/gpu/drm/drm_colorop.c + :export: + Display Modes Function Reference ================================ diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c index 98d22ac163e8..5b844daabd44 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -30,6 +30,37 @@ #include "drm_crtc_internal.h" +/** + * DOC: overview + * + * A colorop represents a single color operation. Colorops are chained + * via the NEXT property and make up color pipelines. Color pipelines + * are advertised and selected via the COLOR_PIPELINE &drm_plane + * property. + * + * A colorop will be of a certain type, advertised by the read-only TYPE + * property. Each type of colorop will advertise a different set of + * properties and is programmed in a different manner. Types can be + * enumerated 1D curves, 1D LUTs, 3D LUTs, matrices, etc. See the + * &drm_colorop_type documentation for information on each type. + * + * If a colorop advertises the BYPASS property it can be bypassed. + * + * Since colorops cannot stand-alone and are used to describe colorop + * operations on a plane they don't have their own locking mechanism but + * are locked and programmed along with their associated &drm_plane. + * + * Colorops are only advertised and valid for atomic drivers and atomic + * userspace that signals the DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE client + * cap. When a driver advertises the COLOR_PIPELINE property on a + * &drm_plane and userspace signals the + * DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE the driver shall ignore all other + * plane color properties, such as COLOR_ENCODING and COLOR_RANGE. + * + * More information about colorops and color pipelines can be found at + * rfc/color_pipeline.rst. + */ + static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { { DRM_COLOROP_1D_CURVE, "1D Curve" }, }; From patchwork Thu Oct 3 20:00:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821507 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 91ADCCF34C6 for ; Thu, 3 Oct 2024 20:02:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 070E610E92A; Thu, 3 Oct 2024 20:01:51 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="MnP7i1M6"; dkim-atps=neutral Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2044.outbound.protection.outlook.com [40.107.100.44]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8A3AD10E910; Thu, 3 Oct 2024 20:01:48 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ebz4uLV9pfx8fkEqXFytTKMZCg1F/ae5pRoU2kFEyZcT+GKtNCL1KFhNCNoMuxuB5M9o5qCeR2iIM7y2wQIOtpUTltb8U3J5UALm6/U0FD9yDMQNVUKyMlKMrB/BVtWAEddDNzI/zLaUO3+Z7O5Mjdh2LuCxEV2jtjlP9OtakRNY3tOHymzOmjTNJBWmYhFByL+nNLVnxBIBetflEBBANyV0AeoEjOspIRThelDE+CEop8w9KdwU50+F8dMojZ0OjZQOOaqUAWdkVxwQCHsOT7fC+5gRE5giumyHxjBIwDXSkMVMV/Aqp122zAp9J06lRLp1L/KnemtaIW+8wV4hrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=FTw8vhtoPflEIJrUOoDA9LVUW1laJQQy3b+mJMeT35I=; b=bQD6BEVltUQfcVulfPRa0JkcYn79gSJyRJbjDnJ2B70FhrB1SUZjhgW2B+GWBOeRWySb2G5T5EPrpVwTt+fSEQOem5pdCBd+Ru22kU211ldUtz6/qx2IaF5j4FRJH3aMWoXOg37I/Sz0XzQseG4EVsi31la94MozPphrn3Hi/PKLqNNZGMt9Mf3CRTNVwb1Q8g60DCZI6uCZfke1LIgo7WuSdXDfQoVbvtpguCBnn26tbKTOSNVfgJkv4R+5U7+jS2EmKoD4gPmq3VZPP3HJn4J7REb225EgDXFZQ4WFPzi77D8dcVYY7eJXzfCG2XVWPEKsZYsh6vPd1mnmq/v/cA== 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=FTw8vhtoPflEIJrUOoDA9LVUW1laJQQy3b+mJMeT35I=; b=MnP7i1M6uX+HP9/ZZnA0DuEAdpbmnRPdbGf19zGiR707y/5l2VnFFgnldg5m445KzwAf4Zzfh623YfPPlz6QPjPAniPhAd8d36zBZmUyBtC978bf1NL1zitLhUGp5vAK8s+kndeSKrFaI302X5FnvSQFdpykcinWj7WMkmdEiGk= Received: from CH2PR14CA0052.namprd14.prod.outlook.com (2603:10b6:610:56::32) by LV8PR12MB9183.namprd12.prod.outlook.com (2603:10b6:408:193::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Thu, 3 Oct 2024 20:01:40 +0000 Received: from DS2PEPF0000343E.namprd02.prod.outlook.com (2603:10b6:610:56:cafe::49) by CH2PR14CA0052.outlook.office365.com (2603:10b6:610:56::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:01:39 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS2PEPF0000343E.mail.protection.outlook.com (10.167.18.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:39 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:38 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:38 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:37 -0500 From: Harry Wentland To: , CC: , Harry Wentland Subject: [PATCH v6 09/44] drm/colorop: Add BYPASS property Date: Thu, 3 Oct 2024 16:00:51 -0400 Message-ID: <20241003200129.1732122-10-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343E:EE_|LV8PR12MB9183:EE_ X-MS-Office365-Filtering-Correlation-Id: 2eca0d4b-6716-4d24-a279-08dce3e6317d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: /HUkJBkDsoOIWyswGtmgQvYyjjwOxm+ZMiycvpkJ176sWdR+8qjezbFzT1QF1g2dkuj7KBCQOmizYjzl6Bkcimv2XtRqrzyYFgkBMcgFTtvpW8qbhzdqdc7dFJ2hnnS7x2wnCU14fOq8DWkaerWxK0Clxmtol3S8ll2X5lPh67GnXZUEANi1CznLijokHpmRbgkvv3z1OO8dRATkFKlLd2LuTXXAYld/r0qNISI4q+1+A7vGWw7/pMsuFi+aDypPn2OuSn9kqI9ZLqLt5g3/ljpJYHTiSnAKaI0DNbNQETAGQj+RRVeyFNlVZAiVZmx89Zx+3ZKIXibFp1zltec0kgqmVW+vkz9XBprmBbFzFPXwA4qXKNGwk7tnJy4p4w/kBhTnARrhUfMHgFOILdcNgabBhStPbDLwl0v3c0EuZswmcm8vZXCydE1qA5qPW/MVvVQCBeNgAC7/g/f7brIWwAZDzr8WgIwsWYXSWrrcA6RKzbESTI6+GxTEVXMEqZdq1gWdZrGWstS9IF+PjF+oXsF4ihTm8XybolNu7ytxN5ZCaH5x7vW8ZF7VW9a+j1HBPm6TzlGd6M7RPkKRMGnWpbOOw/rOijTu0+tBzgBJYSHcy0cF1iagcclV4uqZvz7fL464QFbHZ7Wm+3Ir+LZpyVIdLktpBeLovw2+P1CHKUHcbVedT3aHYhlMhFl5YR/BK2RdOk7m5PEED6C9WHFjuxXts6ag9EuW70wA6DWQ2c2unI3iNUYTyq6rlICQjgv6gh7sJkiNI5Tk1Q+4+DzFxRaI2OVjDSkJ5JTc+LXHsAB9mLWYSMY6vK7FGdXAJUEOzR5SCZk/AxAkZ4AwpwKzNdZK1/fCcK9qAbct+IeZmf/GsDm9aQUxI55LUUfs1QNHhOppPVqDMoFKoK1Gezs6mYQkTXks19VdVPpl0844Exb097tscwPD1nTk85cpPrCekHDibJOk/8kQn897oZ1wNXewxOfYMeoZIZLL31wLx+NIAb2Obtewi6/nQXTTH6APwJ1MxWGOlVYGskp+kNCfscXio5Dg9Hxio4mnkxs5A3cZlcIlqlCcfgTHRGli+BkazX8K5tdGQfzaJGZqTA4/nvwMvxbRBSycIIFDZ2TKkEmh2Bqe4wbPVFqfpgw4WJugk38cTwdYrdcjUQa3c5rc5wXMBq/6pvrXIIzfKkF14BDMhRbT6lT385DvQrzPjlG/hOZ57XbC/W3OqNWBRwFQxQICuY3AmlC0OOTKjpSSmM4Scf2xqQd6IgUCojtEznMBUrbistm1nck0wFQTsKsZ8CxmdcQKHp4XJ8sMfPs7eIIAsRVLzKoun1pEQ3C5qqBFyza6cTlG8QvTomRNe+ya5wyy2GXquHtl1Xsfo/tzIwk= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(36860700013)(1800799024)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:39.0818 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2eca0d4b-6716-4d24-a279-08dce3e6317d 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF0000343E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9183 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" We want to be able to bypass each colorop at all times. Introduce a new BYPASS boolean property for this. Signed-off-by: Harry Wentland --- v6: - clarify that bypass is only valid if BYPASS prop exists (Louis Chauvet) drivers/gpu/drm/drm_atomic_uapi.c | 6 +++++- drivers/gpu/drm/drm_colorop.c | 15 +++++++++++++++ include/drm/drm_colorop.h | 22 ++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) -- 2.46.2 diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index 9a5dbf0a1306..8a038e04be58 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -648,7 +648,9 @@ static int drm_atomic_colorop_set_property(struct drm_colorop *colorop, struct drm_colorop_state *state, struct drm_file *file_priv, struct drm_property *property, uint64_t val) { - if (property == colorop->curve_1d_type_property) { + if (property == colorop->bypass_property) { + state->bypass = val; + } else if (property == colorop->curve_1d_type_property) { state->curve_1d_type = val; } else { drm_dbg_atomic(colorop->dev, @@ -668,6 +670,8 @@ drm_atomic_colorop_get_property(struct drm_colorop *colorop, { if (property == colorop->type_property) { *val = colorop->type; + } else if (property == colorop->bypass_property) { + *val = state->bypass; } else if (property == colorop->curve_1d_type_property) { *val = state->curve_1d_type; } else { diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c index 5b844daabd44..054e7f01151b 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -109,6 +109,17 @@ static int drm_colorop_init(struct drm_device *dev, struct drm_colorop *colorop, colorop->type_property, colorop->type); + /* bypass */ + prop = drm_property_create_bool(dev, DRM_MODE_PROP_ATOMIC, + "BYPASS"); + if (!prop) + return -ENOMEM; + + colorop->bypass_property = prop; + drm_object_attach_property(&colorop->base, + colorop->bypass_property, + 1); + return ret; } @@ -166,6 +177,7 @@ int drm_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *coloro /* initialize 1D curve only attribute */ prop = drm_property_create_enum(dev, DRM_MODE_PROP_ATOMIC, "CURVE_1D_TYPE", enum_list, len); + if (!prop) return -ENOMEM; @@ -182,6 +194,8 @@ static void __drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colo struct drm_colorop_state *state) { memcpy(state, colorop->state, sizeof(*state)); + + state->bypass = true; } struct drm_colorop_state * @@ -220,6 +234,7 @@ static void __drm_colorop_state_reset(struct drm_colorop_state *colorop_state, u64 val; colorop_state->colorop = colorop; + colorop_state->bypass = true; if (colorop->curve_1d_type_property) { drm_object_property_get_default_value(&colorop->base, diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h index 6b8722ea22c7..29be3563eda1 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -78,6 +78,16 @@ struct drm_colorop_state { * information. */ + + /** + * @bypass: + * + * When the property BYPASS exists on this colorop, this stores + * the requested bypass state: true if colorop shall be bypassed, + * false if colorop is enabled. + */ + bool bypass; + /** * @curve_1d_type: * @@ -162,6 +172,18 @@ struct drm_colorop { */ struct drm_property *type_property; + /** + * @bypass_property: + * + * Boolean property to control enablement of the color + * operation. Setting bypass to "true" shall always be supported + * in order to allow compositors to quickly fall back to + * alternate methods of color processing. This is important + * since setting color operations can fail due to unique + * HW constraints. + */ + struct drm_property *bypass_property; + /** * @curve_1d_type_property: * From patchwork Thu Oct 3 20:00:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821501 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 31C95CF34C7 for ; Thu, 3 Oct 2024 20:02:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A782A10E925; Thu, 3 Oct 2024 20:01:48 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="ZvX+Rr83"; dkim-atps=neutral Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2047.outbound.protection.outlook.com [40.107.236.47]) by gabe.freedesktop.org (Postfix) with ESMTPS id A29D210E90F; Thu, 3 Oct 2024 20:01:46 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wbM6iTSgPLsYGTFOpiD4uPFLacuTRENtFU6ZY0z+hvmdD8Y1GjWzq44ZTV47qTtdiEjbiHZLu5Lfe55VjzDGBytMWlvoENNqlIlpNa8f0LTzMbOt3uZAAursIOtQynLiHnmYdeHNGa1dpkuS3MGPxpb1O0+OrkXq5f9jcGY5zxFyJflwNl9ZI95VD/xmHcmJf6E3JZ9FGs8iYk1YTCcoydrw+neWsNJt0f2OHcLUBnIeiK4FOOVX92s0CZutBD2uBoe7ddD/0hhEfuEhUR2whcCXn6atOUrpoKW0wbm4z0kH74F6i791qXSwP2ZjEM60kMQD4OyaK5vqnAS3ZdzkwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=n9GQ8d0mtw9wSfTSz23nkF1dIKD0AhmfFGKaCDl9uck=; b=YuF1y4jHHMImzrDxfKd+azl8cufXDfzzsIxybKkga+K/BiMnFUW997dFP6Vt86HyNnXB62YEzF45RHjDMk13mhm9m9SQF+Z3YThc2t1Hr+8UtYDmS/XpsmwFRkRndyjjgXR4IX4OzJMo+delSqwP5C0nIlhXZjB3hFxHhycH66S/hGw04Qcu0ocicVfSzOVa/nLV18mIXllXkaFSf/PR8hRV1qsR82ZiNBaNFJLenatX6b4bE1kskRzzIP4kDEL+4DDEHFdzXVU+9A+SkTZJquG/zSpfJCMnpWrdL+RhiGI/DeuF/4gG6B59L9sPJWw8f9pZraQac5GWTVTM8ONsgA== 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=n9GQ8d0mtw9wSfTSz23nkF1dIKD0AhmfFGKaCDl9uck=; b=ZvX+Rr83khTsYLPbcNAOKj9oHNYJrAF3rEsFwvR5bsB+q2hKkZPEMLbz/8Fw2wOxMm6b7zRWtqbOsTxv21gxECmzn8VYZQmVqDLLyaNKB5NPY43j8zRMJoQqvDm8ChGYIPs5wxxy9KIoqvxkl6tASmuFxpVRRUsi03aDeJmCKss= Received: from CH0PR03CA0256.namprd03.prod.outlook.com (2603:10b6:610:e5::21) by PH8PR12MB7374.namprd12.prod.outlook.com (2603:10b6:510:216::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Thu, 3 Oct 2024 20:01:42 +0000 Received: from CH2PEPF00000142.namprd02.prod.outlook.com (2603:10b6:610:e5:cafe::db) by CH0PR03CA0256.outlook.office365.com (2603:10b6:610:e5::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:01:40 +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 CH2PEPF00000142.mail.protection.outlook.com (10.167.244.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:40 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) 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.39; Thu, 3 Oct 2024 15:01:38 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:38 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:38 -0500 From: Harry Wentland To: , CC: , Harry Wentland Subject: [PATCH v6 10/44] drm/colorop: Add NEXT property Date: Thu, 3 Oct 2024 16:00:52 -0400 Message-ID: <20241003200129.1732122-11-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000142:EE_|PH8PR12MB7374:EE_ X-MS-Office365-Filtering-Correlation-Id: 83991185-f8f9-44b5-3e82-08dce3e6322f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: 8BQfKybRV704ORx4BHN96kfHNM0tsAEyvE/o3heMTkfWGexQVEhjUdqM3tarb6IHAGS6ChkSdrAuspc/USGHrgK0DOh9ncjGB4P19N3+BFl3v05Z+xwT5io2IN+yr2y/0bLstB7QeB3aPDq2ImpO9FfRMLMnAfxVWocWfmHFhtJDbO2SMG9JsB7ELL/JuWMFvL+iFGgiPUqIlaHhd6Vj+3oiSg8m6UTR13LsGS3hF118Jh7P2zshl1AiIn6o9iG+0J/9o044Kt2YjYm541Vc0dI96vAd5vFtkEsCxT7+twiomd5/aLY6ESWUYs20zSzYRULxs8Zzd/dGjvZpJtrMQsupkUkNjg013zVCzs4bimfid3CWFWtM7EscR/sUi4mkxXI5YzGy+27XQOt/ckzVY6CvJOkzg75wvh9pFx3p/8qBZXBkhmhEc1aIOsG2Z+rfdSwWlt4B+IVaAYkUwvlOrS6u1Zo7a2EKgQ1oVJoRXgF+VZkPJu29Dvh2UoQWYQZY2Nb8zSV+9RUmK3eKrH/0cS9K8qfdv8+CjLk3lFZOuaxKn7N+Bcl9G2bhfALBd79F5BfAitSo4srIgQYVGHTdpN/6y69pbjUdtlN93fcrkvxfbPWiGnLXia1R+4FMTmqCGFLFIQML5EN7SghF7lc2+e37MVw2esFiRBXaWfcLD2Lc+5BZijKoE0jVYBcIV/LO5fLReB2V2K/rmf9h8Sb6XJ6/g7QvfcCNZBe7TgGHNSIIQXn07VTq9BpF1cfXAPSEUQ8EDBdcqhoR2QxBXmhPUNDEztYgBkCsY3kdVFt6y4Rzfpgg1z7qnIrV145MPqKGXo70S/LVi/LlyRmEJVcm6+OWyZrI07GyvealNl8HMgWWn3r2suR9xoF/wDuARdd6z4kWdZ5w5llxUTQchsDvzBMVWpDCSdUq1VbtoBnFYeUvdyngkIolP4JQaoHTvkFeXETUKMSVhi6nlH2eroGnAASCM423zKESl3OVU6+HtoMBf/NEbi/PE2GqvML7eoPrHVBUkDqPf1yCvrShxchXkk9bqVzR3qVRkMNSN2+13OKcHsBy2A0zA6KNqpqpZ3gLou49WMvhY0sTvTCJtCGBWJa//fontDgMNMyt5SNZTtitcyAFfQr0P3sLe/Uyv83et725nL6xqBF1yk0LcehJ7dLRq3pMaJ1gRoOjOByi9nRBCCcUHAFiGgUkqp4gBzDSVkMb9Uo1nE5521ew7IsSxJiVLmcepjZTvEh+6J64Dzhg5yb5vLjSjVx1IYpxQx4RMqB5G8I+ecFR0SiQKnxUWir8IqjU9y/qqFhUrPMIbPRrE5bVPtky5UoAihlFLKlRqfiqSnKF82/qK12E09kcArNpPIzzEdPOAlb8Kgt34cs= 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:(13230040)(1800799024)(36860700013)(376014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:40.0582 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 83991185-f8f9-44b5-3e82-08dce3e6322f 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: CH2PEPF00000142.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7374 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" We'll construct color pipelines out of drm_colorop by chaining them via the NEXT pointer. NEXT will point to the next drm_colorop in the pipeline, or by 0 if we're at the end of the pipeline. Signed-off-by: Harry Wentland --- v5: - move next comment here from Add 3x4 CTM patch (Sebastian) - Add kernel doc v4: - Allow setting of NEXT property to NULL (Chaitanya Kumar Borah) v3: - Add next pointer to colorop to be used by drivers and in DRM core drivers/gpu/drm/drm_colorop.c | 30 ++++++++++++++++++++++++++++++ include/drm/drm_colorop.h | 20 ++++++++++++++++++++ 2 files changed, 50 insertions(+) -- 2.46.2 diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c index 054e7f01151b..685dd18126aa 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -88,6 +88,7 @@ static int drm_colorop_init(struct drm_device *dev, struct drm_colorop *colorop, colorop->dev = dev; colorop->type = type; colorop->plane = plane; + colorop->next = NULL; list_add_tail(&colorop->head, &config->colorop_list); colorop->index = config->num_colorop++; @@ -120,6 +121,16 @@ static int drm_colorop_init(struct drm_device *dev, struct drm_colorop *colorop, colorop->bypass_property, 1); + /* next */ + prop = drm_property_create_object(dev, DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_ATOMIC, + "NEXT", DRM_MODE_OBJECT_COLOROP); + if (!prop) + return -ENOMEM; + colorop->next_property = prop; + drm_object_attach_property(&colorop->base, + colorop->next_property, + 0); + return ret; } @@ -293,3 +304,22 @@ const char *drm_get_colorop_curve_1d_type_name(enum drm_colorop_curve_1d_type ty return colorop_curve_1d_type_names[type]; } + +/** + * drm_colorop_set_next_property - sets the next pointer + * @colorop: drm colorop + * @next: next colorop + * + * Should be used when constructing the color pipeline + */ +void drm_colorop_set_next_property(struct drm_colorop *colorop, struct drm_colorop *next) +{ + if (!colorop->next_property) + return; + + drm_object_property_set_value(&colorop->base, + colorop->next_property, + next ? next->base.id : 0); + colorop->next = next; +} +EXPORT_SYMBOL(drm_colorop_set_next_property); diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h index 29be3563eda1..9721f90bdf90 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -164,6 +164,14 @@ struct drm_colorop { */ enum drm_colorop_type type; + /** + * @next: + * + * Read-only + * Pointer to next drm_colorop in pipeline + */ + struct drm_colorop *next; + /** * @type_property: * @@ -191,10 +199,20 @@ struct drm_colorop { */ struct drm_property *curve_1d_type_property; + /** + * @next_property: + * + * Read-only property to next colorop in the pipeline + */ + struct drm_property *next_property; + }; #define obj_to_colorop(x) container_of(x, struct drm_colorop, base) + + + /** * drm_colorop_find - look up a Colorop object from its ID * @dev: DRM device @@ -266,4 +284,6 @@ const char *drm_get_colorop_type_name(enum drm_colorop_type type); */ const char *drm_get_colorop_curve_1d_type_name(enum drm_colorop_curve_1d_type type); +void drm_colorop_set_next_property(struct drm_colorop *colorop, struct drm_colorop *next); + #endif /* __DRM_COLOROP_H__ */ From patchwork Thu Oct 3 20:00:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821506 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 30F1DCF34C4 for ; Thu, 3 Oct 2024 20:02:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3BF4D10E934; Thu, 3 Oct 2024 20:01:50 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="hS03tD4h"; dkim-atps=neutral Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2041.outbound.protection.outlook.com [40.107.223.41]) by gabe.freedesktop.org (Postfix) with ESMTPS id 745D110E918; Thu, 3 Oct 2024 20:01:46 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GK5jmqgSTQXsbgm8y8DTuc32ApayDwjoM7WpQTHr8XFsOxSBcoSlZ7c+F1pGbqfjD6JyQs2R3Voh5vrXd01k6vTfz1hVDDQhXd69E/r20EdHHua0zJfYVbD4wA43VaRb1lkED9RnMz7jvcf04my3uFIgQRmtLsMwHz74AEXsWThhY2kkFLzGFAsQoaQjZs2r5nc0ef/icwvpnnwRoKom52jiPmnn9YIJa/2wq4ORSmY8LWDRB+Zsn0geLGy0EatuxQQzuIVtk6nguYZ5qDwPJpW6sCFbkMRxUKQ7S9Z8Jk+JBs+We/m1KDV4/PUJyHaZLCHATTh1syu5Kw1leymEGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=OfW+DWDjvJ5NIIvE6pESJKLxqM5weRPBkUhMxDmq2s8=; b=AYlwUP55anV5Sn9RFp3HrQ7traeoZC3WddCge1ju3WYLfuZvllRWJ3bPcPvxZC+lVFq0SKcyAvG67CmdAmakQFljsTn+H0Gs1JIsyPGi8valFJBwYZl8PnD6mZgIpbYP2YhvFNl6DkaRHQ9GvKqRpsQ6pJ+bTr56leXkFUZMWu7+bgGMdoGLmT1PQbBomc8l7sXKo4sRaFUGAvtcP1iYq4pmt8IfzqFgiS6PadfwjHNkFlUCOTJIFqQfhSy9BfF/dUVTzboU64uMTNFMqJDPP89ZS3xxqzlUpukJEFgBQHloK0ZHDKRU/ojT4AfM8xXtD0RaxZruN9R+8FpxLnPuEw== 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=OfW+DWDjvJ5NIIvE6pESJKLxqM5weRPBkUhMxDmq2s8=; b=hS03tD4hP2IOdOUc6fZ8tR59HU/dzcFfpyS9VsqxhK8BPEAwCva6enw8r4TV8wDCaSXH2ooh8xI7oQKx+aqhf3GzbbvHs2vucOgYLD4+U7cT9CoUFejr05oMxXDdD0Pe0tg4JxoucwGA4/EYpJs///QnvSgTEu+pmXDkovAEzrg= Received: from CH0PR03CA0254.namprd03.prod.outlook.com (2603:10b6:610:e5::19) by SN7PR12MB6929.namprd12.prod.outlook.com (2603:10b6:806:263::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.15; Thu, 3 Oct 2024 20:01:43 +0000 Received: from CH2PEPF00000142.namprd02.prod.outlook.com (2603:10b6:610:e5:cafe::2e) by CH0PR03CA0254.outlook.office365.com (2603:10b6:610:e5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:01:42 +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 CH2PEPF00000142.mail.protection.outlook.com (10.167.244.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:42 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.39; Thu, 3 Oct 2024 15:01:39 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:38 -0500 From: Harry Wentland To: , CC: , Harry Wentland Subject: [PATCH v6 11/44] drm/colorop: Add atomic state print for drm_colorop Date: Thu, 3 Oct 2024 16:00:53 -0400 Message-ID: <20241003200129.1732122-12-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB03.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000142:EE_|SN7PR12MB6929:EE_ X-MS-Office365-Filtering-Correlation-Id: 037efddf-73e4-4ef1-9283-08dce3e63386 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|82310400026|1800799024|376014; X-Microsoft-Antispam-Message-Info: 4iG650huSE5oMtJYHtgylidDa/tJtVRkXp6MNywiBljm3d4eJMWTFfSX02vNWmbK21Kt1tRjWJmIoihju1YvnyTAaaqBLfXQcXnQBCTVzQr4rbeZkxaX4r5kd2BGdh0Z4QENoSOiEznkQWLzNky3o/jq0/43nteKYS7qQMdJgJ6HnPuZYcE+nHe9MeruwqzQ57gqAhpYsCyHxO4dQ4ZOTaAl05VKJbOt08PWl8wE6iXbFNBQPo6y2pAsy6N0j9YNGWXmg0JqgZLRkDDydEAMynl/kpyC52JSqGEF46ARoWLL3mhot5qTw5FFgVI6aFXFpunSxJokG1zJ24m2DfJrtQs/XTGTsyU43SU0/2Z5+iPGhkdABBA0IjRXVK7N13G9Y07k2Yrk/x0Fvt6wKVuVfKxxJWvUQX9qzMrqwCKs4wzDzozG0ge1EhJuVAf8o5DQy3v94X+XyQetrlpvxDYYAIuTC+HI4pcL/YeWS1GVMLdicqQHTRR3/C1EotQI9iRONtN4qpaDwcTP2DxTwk8k0osJ5bv7gQMNt4+Uxf81t9dM2kTiw36L04GSEejS5Ar1IXPwm+TI1qL9bfg4WMkuzvDDdKq29S8tcDUhCyJCAtRSn7ULL2/P+KDUIdwnrUjB+NDZDfLnO4H2j5R/61GfesGdG0l47R21suKgkUzpnWmK5N7ItaycAV0+eQqljiakHewKFaMbt1EhdPIWPxbgE3/0WgZjd0dUBURizheeW6A1TQgGIjtFppLrYbhhZn8V8GhdJW6IlgPLoDot4bD5vCvxAWb54oLZOmEH+iFCfBachgLEeHQNAoGAAGLkyQL3pu8cHX8SyAiJHxjtlYJiztQtAOKy8N1WcEuI+ht4Pm9QlX9jA1UsK1wjveHbTJjf18krusZuthbcNrIuYU9DlJoG5O9FRFuF2UsTZlCqfl1BatAekb+DTjY+bqEgyNHytnI7OqAhMQe3MIvZ49Ms0t2r7ZR2ek1lwokI37Q8jv/4lV+2pvlBzgn6xl1eU12XaDvdOCJFt/gLvtHWfyHsY+zI3MjLhOGsuVF4mCrWfg+HDCMc3I4tnf4Vf3D8PtOyMjp6Udig5wKKiqm8l28Lt81J7yYozXawyE1okn/o7GM/SdYUURQIEObU2Em+b/u0vkpLK8YhuT08nQzadcwOgrE0nYcOH4CrKagDyjkSEcG5WaCgE0xFQSOX1m4abaDaeM81SXu04sWLPJnVlvVZmdZVG8U3DFG09OfOPpyBuA3pt0/fjHaHYLecfyq8nPFI9amYnewUu0YPGfS/sAQlOEmCj0yyph+aOeAPMygjoF7HwpysPE7/GLPyZmdjdakiPm+PI1R4rAfEkWTpN8is0Lc9Ya3TDpIAtN7bZGv5bus= 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:(13230040)(36860700013)(82310400026)(1800799024)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:42.5270 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 037efddf-73e4-4ef1-9283-08dce3e63386 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: CH2PEPF00000142.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6929 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" Signed-off-by: Harry Wentland --- drivers/gpu/drm/drm_atomic.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 44c5b5dd8b33..0f4eba51ee4b 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -777,6 +777,19 @@ static int drm_atomic_plane_check(const struct drm_plane_state *old_plane_state, return 0; } + + +static void drm_atomic_colorop_print_state(struct drm_printer *p, + const struct drm_colorop_state *state) +{ + struct drm_colorop *colorop = state->colorop; + + drm_printf(p, "colorop[%u]:\n", colorop->base.id); + drm_printf(p, "\ttype=%s\n", drm_get_colorop_type_name(colorop->type)); + drm_printf(p, "\tbypass=%u\n", state->bypass); + drm_printf(p, "\tcurve_1d_type=%s\n", drm_get_colorop_curve_1d_type_name(state->curve_1d_type)); +} + static void drm_atomic_plane_print_state(struct drm_printer *p, const struct drm_plane_state *state) { @@ -798,7 +811,8 @@ static void drm_atomic_plane_print_state(struct drm_printer *p, drm_printf(p, "\tcolor-range=%s\n", drm_get_color_range_name(state->color_range)); drm_printf(p, "\tcolor_mgmt_changed=%d\n", state->color_mgmt_changed); - + drm_printf(p, "\tcolor-pipeline=%d\n", + state->color_pipeline ? state->color_pipeline->base.id : 0); if (plane->funcs->atomic_print_state) plane->funcs->atomic_print_state(p, state); } @@ -1842,6 +1856,7 @@ static void __drm_state_dump(struct drm_device *dev, struct drm_printer *p, bool take_locks) { struct drm_mode_config *config = &dev->mode_config; + struct drm_colorop *colorop; struct drm_plane *plane; struct drm_crtc *crtc; struct drm_connector *connector; @@ -1851,6 +1866,14 @@ static void __drm_state_dump(struct drm_device *dev, struct drm_printer *p, if (!drm_drv_uses_atomic_modeset(dev)) return; + list_for_each_entry(colorop, &config->colorop_list, head) { + if (take_locks) + drm_modeset_lock(&colorop->plane->mutex, NULL); + drm_atomic_colorop_print_state(p, colorop->state); + if (take_locks) + drm_modeset_unlock(&colorop->plane->mutex); + } + list_for_each_entry(plane, &config->plane_list, head) { if (take_locks) drm_modeset_lock(&plane->mutex, NULL); From patchwork Thu Oct 3 20:00:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821504 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 1F009CF34C1 for ; Thu, 3 Oct 2024 20:02:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ED0EC10E91F; Thu, 3 Oct 2024 20:01:49 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="B0wWRlKa"; dkim-atps=neutral Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2066.outbound.protection.outlook.com [40.107.92.66]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6F8D610E923; Thu, 3 Oct 2024 20:01:48 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DoqlyLFyoRqQ5Q7vxZv8WRegAd0pBDosoFiz711HcounGS+c3W3zwkoD5mREPoSlSYXHelA7S1Zi7Ob0Uj4Ydq5MGIZFDSU4tVc153RW78OUcsvrrk76MYyvqCkEntElxaHecmX2+E8E41vTg3dK++VG4VvG6PFZJ+yFP2wuk0zt2urm5zPx4rpsM2Fr19URrjgTPCOTumr64H8dGdotagSAYpDWLMCuL+hq8UEEjFyTB24/cXMheMcWNhq6sFtdYapnH/PZBCoVRk2MUMQCIyv4JWk33OmXllrLQDSzZvXzsL64dv7WkmS0GxeEUTDjYyz2pX9SicPSlWdSK6ac+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=E2NpIC/Ipt9KmCnnub4j76k9mrYakJOISNF5+8dhRIU=; b=HRrKDYXigArsXgQIt+zOVEuA27YaIH8hpGIzLL/AwbZKMimIh5tR+56ioQDcnT3uqSrAF1yjFpWIRmZ6FbQ8CeSN3NwYU55OV+joDDGGt+pU+3qkn1jdyEQnzH3UyT7TrLn3Bsj7E+a2lpsUtZviRHYFRq4UO+IY7/9cgLb3zVHwktvRFD2rskBfR8BDB3YwqtMGlqiw3X54phxb5T9pEnOj3K2VjfYM1RbTO/7rsrV2mw/a+sTHRJaYvfJ43asvr1VeC5kPFV3izPC83ugCsUCfqpDaveEqTLsugxpetTWWZ2OS+/BqlrS4TzsVIVgcXCXB7+FRwuPgZF5ICcuslg== 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=E2NpIC/Ipt9KmCnnub4j76k9mrYakJOISNF5+8dhRIU=; b=B0wWRlKa+B3yIBaSvTymcFhWiaWnSTDr6Jc6+3CHsyldDI6BHNUL4lhvQCy3BuPfKZ5P5X7Y5ou/hIUQ+XFC9mmvhQfh/Mz7BtU1FI1RxFuMiqhsDfB0B350Z7DEY7/HkFu/IjRYzvsjp0/3Jvl5YLdeQXpf/PrR/GakNuvp/9g= Received: from CH0PR03CA0243.namprd03.prod.outlook.com (2603:10b6:610:e5::8) by DS7PR12MB8249.namprd12.prod.outlook.com (2603:10b6:8:ea::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Thu, 3 Oct 2024 20:01:43 +0000 Received: from CH2PEPF00000142.namprd02.prod.outlook.com (2603:10b6:610:e5:cafe::2b) by CH0PR03CA0243.outlook.office365.com (2603:10b6:610:e5::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:01:43 +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 CH2PEPF00000142.mail.protection.outlook.com (10.167.244.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:43 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.39; Thu, 3 Oct 2024 15:01:39 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:39 -0500 From: Harry Wentland To: , CC: , Harry Wentland Subject: [PATCH v6 12/44] drm/plane: Add COLOR PIPELINE property Date: Thu, 3 Oct 2024 16:00:54 -0400 Message-ID: <20241003200129.1732122-13-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB03.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000142:EE_|DS7PR12MB8249:EE_ X-MS-Office365-Filtering-Correlation-Id: 431e4d25-7fea-40a3-78f7-08dce3e6340e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: yl/MOaw7sm7V9yKmPyjCr+l9B1BUaYUMFAOCOb8PpIY/IntYLEd0xjbsVW9nCvBQ7Q3xsG0ba3ZQUmQeW4WVk5pnI9BS2OtJp3OJlXiF9gzfVXw6+h2nPfjup47jE8vCfThMffH0TVXa8b+yPXixyKGath8sKK0JPBQAZzcnmkdPWqKdjJBXkVlOvIhs5Sn2btRz1BN+ndY8mzR4s371ts+WMbpF2P7mz9LjyTmz3SumJk4o0LGRWJk0LETEYr2NS5R3UfnKlSzI/tY/+zz5HOypArSxAfrOlOTZjIrDbYEGngQJFL1o/MtOB9z09veQIda0UVAhAD5ZNjVLtxjOTUNjB32jTJMxFtsyGdDnTD4YC6fcygkiAvMR6QBV0YZ+vMfjPPsSNWQNuG3F756bFMFcaoD+78JfKnLywkSPLCRJQC7UKe0H7M4Y/qi+ypILMyPWgyfyd/NZmpkaFWS3MW50QT6fultfIFy4bYvTG52/EYHoaEMOkj9DVROmCL1YGvxkgSbb6VbmUWUHy7zl6Fj/gko/3nZyJ0g/kk9cWZ8ue+nJot8k5Wk0E/AUqleLIwt+1iDdIpnKZmJrNmSCDnqtDzjHw4Jmaixcd7BRpp913qaayjy8WPhApZ4Kp+sIcBB+eLnzGNhDHOW19K5zzzWPzHgv3VD+V3YIyhpKMvrJFFqPAJrJwNbJOMNW3L1qQbLuQlSsePlnwOp+XTJ6UH2FwT+r8bxG0NUs5zJAL6h4qJAA4mBY/Rb2KvK39qHPSVGgYAEip4Nmx9Uv+1nzqxB3gU3gbcOl0hRAwEBI+AooF689QfbSOMM192x4xXjoUdijSfZJ+zuRYl10sV40bEjePIevnqTenJqxAv/IHEY1YFDZgIvUso3F270TXDpZPaiymGC0tVG6iQSViv1CJFk734MG14q4Bs4CGUhfaRLwewC6waP20VIea+EjGlxKr9R/88C337AKya2omV9OCU/dxo14iopTS2IdC0SrgV95lMeTHhMk5l+6VZ+GLSw+vjgOkqQ7npQcCrcRVdFXw9hhIyTS6mkDOaehIiF9YSfDI5gxxPFonlvi9YFpPJaiDoHzzxjChp1HE4SXeLRDYZjkmqZB5PevzDyoLO3MTMWuqPlJzmOpQKDDk4H76Xp3cGy9a0kpdsb0HMcUwGSCFhWqaU9rMZHOGylcFqi9+/2n9GOxe4FbOVUtNSnWLvLDHfmQu4De17z4uoe9/hWQrPec5+gj/p97AtboeXdkNy6irMOKu1QKQcxm7Imewek+biHnWRr1jFKJgEE+Ya0GWyRTH7khElPFdYAeTplz6soXCMwE/AGqzlsDMYZWnCBhEyokPIhSloABJTpYu0ovRwrEAKTbhWZoTh8ktGiPA4yFJsSyyqxDAm/4ggkIGhCs 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:(13230040)(376014)(82310400026)(36860700013)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:43.3708 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 431e4d25-7fea-40a3-78f7-08dce3e6340e 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: CH2PEPF00000142.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB8249 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" We're adding a new enum COLOR PIPELINE property. This property will have entries for each COLOR PIPELINE by referencing the DRM object ID of the first drm_colorop of the pipeline. 0 disables the entire COLOR PIPELINE. Userspace can use this to discover the available color pipelines, as well as set the desired one. The color pipelines are programmed via properties on the actual drm_colorop objects. Signed-off-by: Harry Wentland --- v4: - Add pipeline property creation helper (Pekka) - Fix function comment for drm_atomic_set_colorop_for_plane (Pekka) - Always create Bypass pipeline (Pekka) - Add missing function declaration (Chaitanya Kumar Borah) drivers/gpu/drm/drm_atomic.c | 46 ++++++++++++++++++++ drivers/gpu/drm/drm_atomic_state_helper.c | 5 +++ drivers/gpu/drm/drm_atomic_uapi.c | 42 ++++++++++++++++++ drivers/gpu/drm/drm_plane.c | 52 +++++++++++++++++++++++ include/drm/drm_atomic.h | 3 ++ include/drm/drm_atomic_uapi.h | 2 + include/drm/drm_plane.h | 11 +++++ 7 files changed, 161 insertions(+) -- 2.46.2 diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 0f4eba51ee4b..12e787e73c63 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -1460,6 +1460,52 @@ drm_atomic_add_affected_planes(struct drm_atomic_state *state, } EXPORT_SYMBOL(drm_atomic_add_affected_planes); +/** + * drm_atomic_add_affected_colorops - add colorops for plane + * @state: atomic state + * @plane: DRM plane + * + * This function walks the current configuration and adds all colorops + * currently used by @plane to the atomic configuration @state. This is useful + * when an atomic commit also needs to check all currently enabled colorop on + * @plane, e.g. when changing the mode. It's also useful when re-enabling a plane + * to avoid special code to force-enable all colorops. + * + * Since acquiring a colorop state will always also acquire the w/w mutex of the + * current plane for that colorop (if there is any) adding all the colorop states for + * a plane will not reduce parallelism of atomic updates. + * + * Returns: + * 0 on success or can fail with -EDEADLK or -ENOMEM. When the error is EDEADLK + * then the w/w mutex code has detected a deadlock and the entire atomic + * sequence must be restarted. All other errors are fatal. + */ +int +drm_atomic_add_affected_colorops(struct drm_atomic_state *state, + struct drm_plane *plane) +{ + struct drm_colorop *colorop; + struct drm_colorop_state *colorop_state; + + WARN_ON(!drm_atomic_get_new_plane_state(state, plane)); + + drm_dbg_atomic(plane->dev, + "Adding all current colorops for [plane:%d:%s] to %p\n", + plane->base.id, plane->name, state); + + drm_for_each_colorop(colorop, plane->dev) { + if (colorop->plane != plane) + continue; + + colorop_state = drm_atomic_get_colorop_state(state, colorop); + if (IS_ERR(colorop_state)) + return PTR_ERR(colorop_state); + } + + return 0; +} +EXPORT_SYMBOL(drm_atomic_add_affected_colorops); + /** * drm_atomic_check_only - check whether a given config would work * @state: atomic configuration to check diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/drm/drm_atomic_state_helper.c index 519228eb1095..d1dd082b1286 100644 --- a/drivers/gpu/drm/drm_atomic_state_helper.c +++ b/drivers/gpu/drm/drm_atomic_state_helper.c @@ -267,6 +267,11 @@ void __drm_atomic_helper_plane_state_reset(struct drm_plane_state *plane_state, plane_state->color_range = val; } + if (plane->color_pipeline_property) { + /* default is always NULL, i.e., bypass */ + plane_state->color_pipeline = NULL; + } + if (plane->zpos_property) { if (!drm_object_property_get_default_value(&plane->base, plane->zpos_property, diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index 8a038e04be58..c927aa65d286 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -256,6 +256,36 @@ drm_atomic_set_fb_for_plane(struct drm_plane_state *plane_state, } EXPORT_SYMBOL(drm_atomic_set_fb_for_plane); + +/** + * drm_atomic_set_colorop_for_plane - set colorop for plane + * @plane_state: atomic state object for the plane + * @colorop: colorop to use for the plane + * + * Helper function to select the color pipeline on a plane by setting + * it to the first drm_colorop element of the pipeline. + */ +void +drm_atomic_set_colorop_for_plane(struct drm_plane_state *plane_state, + struct drm_colorop *colorop) +{ + struct drm_plane *plane = plane_state->plane; + + if (colorop) + drm_dbg_atomic(plane->dev, + "Set [COLOROP:%d] for [PLANE:%d:%s] state %p\n", + colorop->base.id, plane->base.id, plane->name, + plane_state); + else + drm_dbg_atomic(plane->dev, + "Set [NOCOLOROP] for [PLANE:%d:%s] state %p\n", + plane->base.id, plane->name, plane_state); + + plane_state->color_pipeline = colorop; +} +EXPORT_SYMBOL(drm_atomic_set_colorop_for_plane); + + /** * drm_atomic_set_crtc_for_connector - set CRTC for connector * @conn_state: atomic state object for the connector @@ -539,6 +569,16 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane, state->color_encoding = val; } else if (property == plane->color_range_property) { state->color_range = val; + } else if (property == plane->color_pipeline_property) { + /* find DRM colorop object */ + struct drm_colorop *colorop = NULL; + colorop = drm_colorop_find(dev, file_priv, val); + + if (val && !colorop) + return -EACCES; + + /* set it on drm_plane_state */ + drm_atomic_set_colorop_for_plane(state, colorop); } else if (property == config->prop_fb_damage_clips) { ret = drm_property_replace_blob_from_id(dev, &state->fb_damage_clips, @@ -621,6 +661,8 @@ drm_atomic_plane_get_property(struct drm_plane *plane, *val = state->color_encoding; } else if (property == plane->color_range_property) { *val = state->color_range; + } else if (property == plane->color_pipeline_property) { + *val = (state->color_pipeline) ? state->color_pipeline->base.id : 0; } else if (property == config->prop_fb_damage_clips) { *val = (state->fb_damage_clips) ? state->fb_damage_clips->base.id : 0; diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c index a28b22fdd7a4..e3a85a27fa7a 100644 --- a/drivers/gpu/drm/drm_plane.c +++ b/drivers/gpu/drm/drm_plane.c @@ -1793,3 +1793,55 @@ int drm_plane_add_size_hints_property(struct drm_plane *plane, return 0; } EXPORT_SYMBOL(drm_plane_add_size_hints_property); + +#define MAX_COLOR_PIPELINES 5 + +/** + * drm_plane_create_color_pipeline_property - create a new color pipeline + * property + * + * @plane: drm plane + * @pipelines: list of pipelines + * @num_pipelines: number of pipelines + * + * Create the COLOR_PIPELINE plane property to specific color pipelines on + * the plane. + * + * RETURNS: + * Zero for success or -errno + */ +int drm_plane_create_color_pipeline_property(struct drm_plane *plane, + struct drm_prop_enum_list *pipelines, + int num_pipelines) +{ + struct drm_prop_enum_list all_pipelines[MAX_COLOR_PIPELINES]; + int len = 0; + int i; + struct drm_property *prop; + + if (num_pipelines > (MAX_COLOR_PIPELINES - 1)) + return -EINVAL; + + /* Create default Bypass color pipeline */ + all_pipelines[len].type = 0; + all_pipelines[len].name = "Bypass"; + len++; + + /* Add all other color pipelines */ + for (i = 0; i < num_pipelines; i++, len++) { + all_pipelines[len].type = pipelines[i].type; + all_pipelines[len].name = pipelines[i].name; + } + + prop = drm_property_create_enum(plane->dev, DRM_MODE_PROP_ATOMIC, + "COLOR_PIPELINE", + all_pipelines, len); + if (IS_ERR(prop)) + return PTR_ERR(prop); + + drm_object_attach_property(&plane->base, prop, 0); + plane->color_pipeline_property = prop; + + return 0; +} +EXPORT_SYMBOL(drm_plane_create_color_pipeline_property); diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h index 8e2af84a0b01..a2e7ac463eef 100644 --- a/include/drm/drm_atomic.h +++ b/include/drm/drm_atomic.h @@ -852,6 +852,9 @@ drm_atomic_add_affected_connectors(struct drm_atomic_state *state, int __must_check drm_atomic_add_affected_planes(struct drm_atomic_state *state, struct drm_crtc *crtc); +int __must_check +drm_atomic_add_affected_colorops(struct drm_atomic_state *state, + struct drm_plane *plane); int __must_check drm_atomic_check_only(struct drm_atomic_state *state); int __must_check drm_atomic_commit(struct drm_atomic_state *state); diff --git a/include/drm/drm_atomic_uapi.h b/include/drm/drm_atomic_uapi.h index 70a115d523cd..436315523326 100644 --- a/include/drm/drm_atomic_uapi.h +++ b/include/drm/drm_atomic_uapi.h @@ -50,6 +50,8 @@ drm_atomic_set_crtc_for_plane(struct drm_plane_state *plane_state, struct drm_crtc *crtc); void drm_atomic_set_fb_for_plane(struct drm_plane_state *plane_state, struct drm_framebuffer *fb); +void drm_atomic_set_colorop_for_plane(struct drm_plane_state *plane_state, + struct drm_colorop *colorop); int __must_check drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state, struct drm_crtc *crtc); diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h index 2a9b902623c0..8a769c6a8251 100644 --- a/include/drm/drm_plane.h +++ b/include/drm/drm_plane.h @@ -774,6 +774,14 @@ struct drm_plane { */ struct drm_property *color_range_property; + /** + * @color_pipeline_property: + * + * Optional "COLOR_PIPELINE" enum property for specifying + * a color pipeline to use on the plane. + */ + struct drm_property *color_pipeline_property; + /** * @scaling_filter_property: property to apply a particular filter while * scaling. @@ -997,4 +1005,7 @@ int drm_plane_add_size_hints_property(struct drm_plane *plane, const struct drm_plane_size_hint *hints, int num_hints); +int drm_plane_create_color_pipeline_property(struct drm_plane *plane, + struct drm_prop_enum_list *pipelines, + int num_pipelines); #endif From patchwork Thu Oct 3 20:00:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821505 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 39DD8CF34C5 for ; Thu, 3 Oct 2024 20:02:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 04AF010E926; Thu, 3 Oct 2024 20:01:50 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="sYm9X0hh"; dkim-atps=neutral Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2042.outbound.protection.outlook.com [40.107.92.42]) by gabe.freedesktop.org (Postfix) with ESMTPS id CB66F10E908; Thu, 3 Oct 2024 20:01:46 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=T6azpWa9JmYZHbrzHmyayN3mKJB5geoNs3OJGdynwIL+knxPUF4iJLeyrmPWfAs8m49PVaHPAK7K1wk2Chf1fiv4anzleSi4hXAa7cVHu6mJ7uGmzTwx+wGGCIRRHleofQK4ma/t9psyvO18tMu5aRqVrIRwM5msluRcSIXJMlW9IE48Q5NK91Zyed4V3ZSH/d3rhk22wCMdJ3jGjRM+NyaG7q2O2P+IsP8lI4CiYS4z9U19ATXILHMhSAVCT4AyM9rYmyzXG9lAF9gRHG4HUGxgc2y1009puB61BSJaQsCI863HdGeQ6A0zfOHR/Sl6s9E+T1ZsXXZHOUUuQht+Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=ENN9/RUgMyV61otFp8tylTbyGoEG5qPQekxBQiwXkWU=; b=ibOumOU/yVww92GP67htk4Tn2tw/aCxJuM8QY034Ps/RVNK5KF8z4LTYSebnQeBRIo3KRvTtsVjt5C8OvE4DFeAq872vAT6QZXIj6RjBz2ookyilKBd9FLJdvN8DubsoXCD+PeIIHjh4YXN+pCr/7PAx93CrzE0oRCCv4wTJ8M+FAi9jUo5RKYfGtXxAKmN+ISZE9igvInQ1FzrDU9FqGj1x36Ar3ik9XNCW1KyYvgeRLB9ufUblK4S8ZkfyWArZX/R/SMxJWnWaTmStu60Ts4YwG/KJLs1DjyY2PMjGHILyowITMK0jEuHJ8le01TxT9UZbpSCIIktn9gCg3ZDBpA== 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=ENN9/RUgMyV61otFp8tylTbyGoEG5qPQekxBQiwXkWU=; b=sYm9X0hhV7HIK87p1dgihnizwwHbEqg4qSxjpDwLXeb6SUmBp5QP2plPhXAZgVEy8Dh9hd9BsdbLggyT6NU5uV8Ln1mfQNzwjQEpDTMqLwTNA2oMnfKQbpiAHVunkb5WkaIBYDlzeNaAOcxqIhE5RbmMC6S7+49cRkJd3D9s0qo= Received: from CH2PR14CA0052.namprd14.prod.outlook.com (2603:10b6:610:56::32) by DS7PR12MB5958.namprd12.prod.outlook.com (2603:10b6:8:7d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.27; Thu, 3 Oct 2024 20:01:43 +0000 Received: from DS2PEPF0000343E.namprd02.prod.outlook.com (2603:10b6:610:56:cafe::76) by CH2PR14CA0052.outlook.office365.com (2603:10b6:610:56::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:01:43 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS2PEPF0000343E.mail.protection.outlook.com (10.167.18.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:43 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:40 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:40 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:39 -0500 From: Harry Wentland To: , CC: , Harry Wentland Subject: [PATCH v6 13/44] drm/colorop: Add NEXT to colorop state print Date: Thu, 3 Oct 2024 16:00:55 -0400 Message-ID: <20241003200129.1732122-14-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB05.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343E:EE_|DS7PR12MB5958:EE_ X-MS-Office365-Filtering-Correlation-Id: 73e7466a-f9a7-4389-5deb-08dce3e63401 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|82310400026|36860700013|376014; X-Microsoft-Antispam-Message-Info: 260pnWIoda1XirenU0JRM4VQ1sZn8Fqf1+oWIkQ50qGGTMh4YmH5WyjqGgyI1xwn004rao/uWh6RhN1yitxS3LoE6QM2Pz6MZyEbX8ULg0O6a5xMdBRBCCUc0wzFwHD88Vl7Mm6M1XmVkyrhjL0wbdVEygIDSCblHobWPb6JmwPuO4doYHcq21B7dMKBeOTRlyxMVZDLjKSy5FunBgdnGYmtkowIQ1JJNWSyAtvaX1aaQclASKuq0OyKnL68Ld/sxEgC0UP8G2EPi6qHGzTmNVZkA7oMO/Nnne38FoHpoKYpIjS6jxK3BSu4vrSeZmwrzrjKPU7SILxVplLCPDBPdPuLsZbXjbH/IENKRQI0whUFFU0WaX/1aBJBWjiTFYLyoOMqIj9YfUu1DCT4RmypNVQivIgyO7AXrp1R5Kby4WrH9jvWgwt7FuXiOiEUWKGqBIsluk/PuPX1qqO+N5fKbti3covrkMVOjdW9mdESMeY9W+5tVNJp5b3cj+EIw4w4cbandGSnnwalIXx4ASptSb6nOuZkROkswVyxbxNquqsj2JIy68RZusEc1zngPC2e9kN9I3zDROJbsX4yU58Uwnudw0bZo71TU37/lm3Wj012gAlndN88aqXUig58d7KQxQ4mEZdcnMgkgWOKpWgAexI6SfEp54a4MwgoH/8TbuLIh4TP8Jny7sFk4ShyJHgPaxoYqTOai2cukRFSTlFMeSq/AJzY+kNwln1d0VOjx2Not/xK/H6FJKZpjZ+kQTpgJRvMs+a3Z7eOdVn6aVrlWd/ReO6Xz5NliX4wjU832PKlpYNoDtvrAJc03crf5BKV2jflSxy+5A1xE9iSD80Yg6XLoUxvrLdtfpd5QHlfJZguRMqCoY8+e3d4IM4+BQP/NS8lLSbRa3OWGE4iFfwSByRsPc2YkMBFjWsmyqvH/sn2SM3tygOvMqCJR/MqBwD4kYEWCdedSm9/rrn+jImIPYOAZAbASfHOxKXxj33iUsrShKI4Vg4PVKBeg89xFme7u6za2ycTt82e5pzLfgYyvC8+nB6PgKAQpqdrBnV4k+Cw78gSkhfFEVCepyZgzOH4VLcMZBAe8HGUX57Gb7tHGcOxvZz16nGGYIFmhAYlfoV9OrQBRo/0lDB7v5pd8U/gYAJb9hSk9uJ22Ck0+pfQyAysdzK3kzkWu8B+g0xHPjV3M0Le+bFlmcOvSTl+/omuigaR34tfVrKK9A5XE70r8+mcZYG38MkExhhAsDzna5/ONaUYfRa+XoXcuRiqt5mmX6epgmSlfEsOt/DxG1Rd77TYc1P1cU4yLAv8neudd8bcK7Qn4W5uYQZuhN/i/ncVJPpDYKMPpkdCPnisgA+qBe6Sd8oCBp433ZY4ftyA9ck= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(82310400026)(36860700013)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:43.2068 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 73e7466a-f9a7-4389-5deb-08dce3e63401 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF0000343E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5958 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" Signed-off-by: Harry Wentland --- v5: - Drop unused header definitions v3: - Read NEXT ID from drm_colorop's next pointer drivers/gpu/drm/drm_atomic.c | 1 + 1 file changed, 1 insertion(+) -- 2.46.2 diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 12e787e73c63..35136987d5e8 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -788,6 +788,7 @@ static void drm_atomic_colorop_print_state(struct drm_printer *p, drm_printf(p, "\ttype=%s\n", drm_get_colorop_type_name(colorop->type)); drm_printf(p, "\tbypass=%u\n", state->bypass); drm_printf(p, "\tcurve_1d_type=%s\n", drm_get_colorop_curve_1d_type_name(state->curve_1d_type)); + drm_printf(p, "\tnext=%d\n", colorop->next ? colorop->next->base.id : 0); } static void drm_atomic_plane_print_state(struct drm_printer *p, From patchwork Thu Oct 3 20:00:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821523 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 855B8CF34C9 for ; Thu, 3 Oct 2024 20:03:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ACEF310E964; Thu, 3 Oct 2024 20:01:59 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="Zd90KMns"; dkim-atps=neutral Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2085.outbound.protection.outlook.com [40.107.92.85]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9885110E936; Thu, 3 Oct 2024 20:01:51 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AyPLWoxbKScZQW27fPgzonpWC6eaE7wtdVakrwtQnEFJjoy7tgLFeqHgqj6Q1icshNQ25G/Kp4eHMxpkPn7neFukAOTfJbEYH1Cf7sbmZd2lUzBw4fLoDaXImpQeRA42ZJAMCG1dNVHA1476iFnpfnfVtow170TAJNUhCNXKwUFR3M3Baiy0mIzQmaHczfTyuZoKkgDtlg1RcSdrGOXih79WrPYBXsqXOIs1qQP+8ATwN1fpaMBKXYefDEW+CoSVR59f0vYlGrfCVQAlSStTaStdZVcCBiklDNRLiXOHNBqBpHTgdSPHUIvramQN5pJdu1N9+Y3JuWTca4PbSKJHjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Bkg2fFzjR2nONFBohmZRYN+3gBVIpqeVsPnhYvhFo/A=; b=qcWZHIcC0lb0RnXmqq1zJT0bXaSwYtJaBkvRCsStqHDInpOFqjpBxXkA55JoNauq8oio7+lqX7HBLmrPZJ/nIdw7/HQ22+kyGyNtWLaTXhemyqLzTkJmUh2eYRHSHoql9khRHJsVfVE8QE3v3VonazzfjVMpkevEu+6cL+vNVlf2SkPDFXhwrgFMLPysIyIiWXyjTEjyFhsjzYOYKepQXsQ7H5rkilef16/rWMDdBByuz98DQ2n9Rya2+hccRJHz5Isp48uCN7+MRJyr9VoJ3I5LLlaQUkXn32JOKqMVLIF+h/fqxbynnP9E33Q3vs963cONS07G/OyW7qwgkv4U+A== 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=Bkg2fFzjR2nONFBohmZRYN+3gBVIpqeVsPnhYvhFo/A=; b=Zd90KMns5dfWsQ6b2+Edu4a4eHZVX2Bfr4TkN801zqrbXhHia+0VZMb6aU0buH2M1a4jA1WzO9+Z0eA3YLUPLOivgkCraHwO00/RKLjV6vMgyY0nS7JVr/zlgEd1+uGE3n7o8JljDiNPm4JnjyayHf8qJzRSAlDPCA8BEaJ7KBE= Received: from CH0PR03CA0269.namprd03.prod.outlook.com (2603:10b6:610:e5::34) by PH7PR12MB5928.namprd12.prod.outlook.com (2603:10b6:510:1db::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Thu, 3 Oct 2024 20:01:44 +0000 Received: from CH2PEPF00000142.namprd02.prod.outlook.com (2603:10b6:610:e5:cafe::6b) by CH0PR03CA0269.outlook.office365.com (2603:10b6:610:e5::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:01:44 +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 CH2PEPF00000142.mail.protection.outlook.com (10.167.244.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:44 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) 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.39; Thu, 3 Oct 2024 15:01:41 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:41 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:40 -0500 From: Harry Wentland To: , CC: , Harry Wentland , Alex Hung Subject: [PATCH v6 14/44] drm/vkms: Add enumerated 1D curve colorop Date: Thu, 3 Oct 2024 16:00:56 -0400 Message-ID: <20241003200129.1732122-15-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000142:EE_|PH7PR12MB5928:EE_ X-MS-Office365-Filtering-Correlation-Id: d7fa061e-3620-48fe-60ec-08dce3e63477 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: Id11vLCQ8VIXXmJCQn+AY80ObaOUU4v+T9H1L9amZRYjuY23y70zP7eDlpuRJqpcvWcl30nV7jG9k079X7F9z9NHwn6XpVVvTopBSNN3amXX4mRTDwzQBOJAVOGrTLPlYkovzc8/+MelBS7K8PqcC3icsclFKcXP1AS9+SOEcdueHyHYMRAFk5LfT3mhX6l6qU1xW6QSYJ9iVi/yIMmb9jJBsiH5wr+faNiSz0PHGQOTdclw0Yvnsofkg9nxupkWq5ImPJPCyi3sjHrRfNB25DOs+Hec0H0arLkvwKYWF+sUGKi+R/OAVVxyezXkU60lPRFO/jr7ioCxfOjfAwiIHfOB09phZhQuvrlAofOQIGTXx8yyDXtnzbIYWEuZ0PN8hWzvwoQTNdsBU2PjKNe23cTteiTt1KzkCkRKP3v66YdP/AJgssByImp4lKWdHrEhlro8JIlEo0VKisdlyUlOr1ID6PSenc8mk3m7auWIzhXpTzrHVUuaFiz/o1twG/d8I+Bh+G3vA2aY1RfoOJ6LR4Hq2V43NHA8eILcYWrBS+Qz1sdKGFPn7umDGnYkWT1FsMenlzEJCJnawvPr49Z3aQTatgEfByzFLBCqKFQJWce0p/FbaW18bE6cJkHRNyYHcS6r9iwTQ6ioO0EJkO+vZ6GbV55LGh17/7L5GuTHxMd+vc+eFV7yECZ/5LvHqgsHoJEs4Dt4mmVOF57dImAdNOYP9OW8rb0b8HQi019+KI3Bp4johsozu6oVDG67aXVNgaj00u+TUJScZLE8efdKcojk1E+ncG/uSVv705e8YBDav6XbzgU9n1P1McUhzDCuauN7SMuKUwDWJEMRJkJhWpuJ0vThVnSJ6k+1Hxds7ZUmck0xAN5XYqaEtEpBZFNyaK77nNIWYhEKTEBEuWR3crUTvFw9n38MZU4VpyiS3PVpVuB9H4U0/AsA1Vxh0846oHz2s1lfvIaI03oFnnMPzOqeF2zo3fcQNZOzSK61LRnHOZyayFvE/SaAiT00UKvpyyJG2SB+NnO0w03CudZ7eVSKrz7IdY9OKN8bWRxKdObP6j56toGXIB7yq/8IrNOavQth2c+U+xjnJ3pJGFVHiSDKM6YxzgdNV8k4v4G6eE0zpldmzXNB63pEgldYhlI+CWm44ZX6A+wAYrXXzXZpiein2ntv0ucjS+D7UBp9u98vfDXziSUX8SmdwUUutUQqfEGdoxh0Ay/3+TUOrTLejfnxF0i5Ut/Qq2h8VAqXL+OZ2/ImRM3owG82GCXC3DFEGtgGa08UHl4wLsM27FEQBxm/0+O9mGYki1P7yGamjfWnwJX5ZrxUO6RAVJ97DtJhd/Xwh029MnWT8VdpxdnVtYMHYH8ET5L55nokMUYsOiWP9qt3RMvQPKoMtxsTXtCV 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:(13230040)(36860700013)(376014)(82310400026)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:44.0114 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d7fa061e-3620-48fe-60ec-08dce3e63477 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: CH2PEPF00000142.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5928 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" This patch introduces a VKMS color pipeline that includes two drm_colorops for named transfer functions. For now the only ones supported are sRGB EOTF, sRGB Inverse EOTF, and a Linear TF. We will expand this in the future but I don't want to do so without accompanying IGT tests. We introduce a new vkms_luts.c file that hard-codes sRGB EOTF, sRGB Inverse EOTF, and a linear EOTF LUT. These have been generated with 256 entries each as IGT is currently testing only 8 bpc surfaces. We will likely need higher precision but I'm reluctant to make that change without clear indication that we need it. We'll revisit and, if necessary, regenerate the LUTs when we have IGT tests for higher precision buffers. Signed-off-by: Harry Wentland Signed-off-by: Alex Hung --- v6: - drop 'len' var (Louis Chauvet) - cleanup if colorop alloc or init fails (Louis Chauvet) - switch loop in pre_blend_transform (Louis Chauvet) - drop extraneous if (colorop) inside while (colorop) (Louis Chauvet) v5: - Squash with "Pull apply_colorop out of pre_blend_color_transform" (Sebastian) - Fix warnings - Fix include - Drop TODOs v4: - Drop _tf_ from color_pipeline init function - Pass supported TFs into colorop init - Create bypass pipeline in DRM helper (Pekka) v2: - Add commit description - Fix sRGB EOTF LUT definition - Add linear and sRGB inverse EOTF LUTs drivers/gpu/drm/vkms/Makefile | 4 +- drivers/gpu/drm/vkms/vkms_colorop.c | 81 +++ drivers/gpu/drm/vkms/vkms_composer.c | 49 ++ drivers/gpu/drm/vkms/vkms_drv.h | 4 + drivers/gpu/drm/vkms/vkms_luts.c | 802 +++++++++++++++++++++++++++ drivers/gpu/drm/vkms/vkms_luts.h | 12 + drivers/gpu/drm/vkms/vkms_plane.c | 2 + 7 files changed, 953 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/vkms/vkms_colorop.c create mode 100644 drivers/gpu/drm/vkms/vkms_luts.c create mode 100644 drivers/gpu/drm/vkms/vkms_luts.h -- 2.46.2 diff --git a/drivers/gpu/drm/vkms/Makefile b/drivers/gpu/drm/vkms/Makefile index 8d3e46dde635..0bf3c116f1ae 100644 --- a/drivers/gpu/drm/vkms/Makefile +++ b/drivers/gpu/drm/vkms/Makefile @@ -6,7 +6,9 @@ vkms-y := \ vkms_formats.o \ vkms_crtc.o \ vkms_composer.o \ - vkms_writeback.o + vkms_writeback.o \ + vkms_colorop.o \ + vkms_luts.o obj-$(CONFIG_DRM_VKMS) += vkms.o obj-$(CONFIG_DRM_VKMS_KUNIT_TESTS) += tests/ diff --git a/drivers/gpu/drm/vkms/vkms_colorop.c b/drivers/gpu/drm/vkms/vkms_colorop.c new file mode 100644 index 000000000000..aebd467c4e61 --- /dev/null +++ b/drivers/gpu/drm/vkms/vkms_colorop.c @@ -0,0 +1,81 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#include +#include +#include +#include +#include + +#include "vkms_drv.h" + +static const u64 supported_tfs = + BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF) | + BIT(DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF); + +#define MAX_COLOR_PIPELINE_OPS 2 + +static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_prop_enum_list *list) +{ + struct drm_colorop *ops[MAX_COLOR_PIPELINE_OPS]; + struct drm_device *dev = plane->dev; + int ret; + int i = 0; + + memset(ops, 0, sizeof(ops)); + + /* 1st op: 1d curve */ + ops[i] = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL); + if (!ops[i]) { + DRM_ERROR("KMS: Failed to allocate colorop\n"); + ret = -ENOMEM; + goto cleanup; + } + + ret = drm_colorop_curve_1d_init(dev, ops[i], plane, supported_tfs); + if (ret) + goto cleanup; + + list->type = ops[i]->base.id; + list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", ops[i]->base.id); + + i++; + + /* 2nd op: 1d curve */ + ops[i] = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL); + if (!ops[i]) { + DRM_ERROR("KMS: Failed to allocate colorop\n"); + ret = -ENOMEM; + goto cleanup; + } + + ret = drm_colorop_curve_1d_init(dev, ops[i], plane, supported_tfs); + if (ret) + goto cleanup; + + drm_colorop_set_next_property(ops[i-1], ops[i]); + + return 0; + +cleanup: + for (; i >= 0; i--) + if (ops[i]) + kfree(ops[i]); + + return ret; +} + +int vkms_initialize_colorops(struct drm_plane *plane) +{ + struct drm_prop_enum_list pipeline; + int ret; + + /* Add color pipeline */ + ret = vkms_initialize_color_pipeline(plane, &pipeline); + if (ret) + return ret; + + /* Create COLOR_PIPELINE property and attach */ + drm_plane_create_color_pipeline_property(plane, &pipeline, 1); + + return 0; +} diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index 93f4ed5ea52f..a35466e68237 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -14,6 +14,7 @@ #include "vkms_drv.h" #include #include "vkms_composer.h" +#include "vkms_luts.h" static u16 pre_mul_blend_channel(u16 src, u16 dst, u16 alpha) { @@ -167,6 +168,51 @@ static void apply_lut(const struct vkms_crtc_state *crtc_state, struct line_buff } } +static void apply_colorop(struct pixel_argb_u16 *pixel, struct drm_colorop *colorop) +{ + struct drm_colorop_state *colorop_state = colorop->state; + + if (colorop->type == DRM_COLOROP_1D_CURVE) { + switch (colorop_state->curve_1d_type) { + case DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF: + pixel->r = apply_lut_to_channel_value(&srgb_inv_eotf, pixel->r, LUT_RED); + pixel->g = apply_lut_to_channel_value(&srgb_inv_eotf, pixel->g, LUT_GREEN); + pixel->b = apply_lut_to_channel_value(&srgb_inv_eotf, pixel->b, LUT_BLUE); + break; + case DRM_COLOROP_1D_CURVE_SRGB_EOTF: + pixel->r = apply_lut_to_channel_value(&srgb_eotf, pixel->r, LUT_RED); + pixel->g = apply_lut_to_channel_value(&srgb_eotf, pixel->g, LUT_GREEN); + pixel->b = apply_lut_to_channel_value(&srgb_eotf, pixel->b, LUT_BLUE); + break; + default: + DRM_DEBUG_DRIVER("unkown colorop 1D curve type %d\n", colorop_state->curve_1d_type); + break; + } + } + +} + +static void pre_blend_color_transform(const struct vkms_plane_state *plane_state, struct line_buffer *output_buffer) +{ + for (size_t x = 0; x < output_buffer->n_pixels; x++) { + struct drm_colorop *colorop = plane_state->base.base.color_pipeline; + + while (colorop) { + struct drm_colorop_state *colorop_state; + + colorop_state = colorop->state; + + if (!colorop_state) + return; + + if (!colorop_state->bypass) + apply_colorop(&output_buffer->pixels[x], colorop); + + colorop = colorop->next; + } + } +} + /** * blend - blend the pixels from all planes and compute crc * @wb: The writeback frame buffer metadata @@ -204,6 +250,9 @@ static void blend(struct vkms_writeback_job *wb, continue; vkms_compose_row(stage_buffer, plane[i], y_pos); + + pre_blend_color_transform(plane[i], stage_buffer); + pre_mul_alpha_blend(plane[i]->frame_info, stage_buffer, output_buffer); } diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 5e46ea5b96dc..278cf3533f58 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -169,4 +169,8 @@ void vkms_writeback_row(struct vkms_writeback_job *wb, const struct line_buffer /* Writeback */ int vkms_enable_writeback_connector(struct vkms_device *vkmsdev); +/* Colorops */ +int vkms_initialize_colorops(struct drm_plane *plane); + + #endif /* _VKMS_DRV_H_ */ diff --git a/drivers/gpu/drm/vkms/vkms_luts.c b/drivers/gpu/drm/vkms/vkms_luts.c new file mode 100644 index 000000000000..6553d6d442b4 --- /dev/null +++ b/drivers/gpu/drm/vkms/vkms_luts.c @@ -0,0 +1,802 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#include + +#include "vkms_drv.h" +#include "vkms_luts.h" + +static struct drm_color_lut linear_array[LUT_SIZE] = { + { 0x0, 0x0, 0x0, 0 }, + { 0x101, 0x101, 0x101, 0 }, + { 0x202, 0x202, 0x202, 0 }, + { 0x303, 0x303, 0x303, 0 }, + { 0x404, 0x404, 0x404, 0 }, + { 0x505, 0x505, 0x505, 0 }, + { 0x606, 0x606, 0x606, 0 }, + { 0x707, 0x707, 0x707, 0 }, + { 0x808, 0x808, 0x808, 0 }, + { 0x909, 0x909, 0x909, 0 }, + { 0xa0a, 0xa0a, 0xa0a, 0 }, + { 0xb0b, 0xb0b, 0xb0b, 0 }, + { 0xc0c, 0xc0c, 0xc0c, 0 }, + { 0xd0d, 0xd0d, 0xd0d, 0 }, + { 0xe0e, 0xe0e, 0xe0e, 0 }, + { 0xf0f, 0xf0f, 0xf0f, 0 }, + { 0x1010, 0x1010, 0x1010, 0 }, + { 0x1111, 0x1111, 0x1111, 0 }, + { 0x1212, 0x1212, 0x1212, 0 }, + { 0x1313, 0x1313, 0x1313, 0 }, + { 0x1414, 0x1414, 0x1414, 0 }, + { 0x1515, 0x1515, 0x1515, 0 }, + { 0x1616, 0x1616, 0x1616, 0 }, + { 0x1717, 0x1717, 0x1717, 0 }, + { 0x1818, 0x1818, 0x1818, 0 }, + { 0x1919, 0x1919, 0x1919, 0 }, + { 0x1a1a, 0x1a1a, 0x1a1a, 0 }, + { 0x1b1b, 0x1b1b, 0x1b1b, 0 }, + { 0x1c1c, 0x1c1c, 0x1c1c, 0 }, + { 0x1d1d, 0x1d1d, 0x1d1d, 0 }, + { 0x1e1e, 0x1e1e, 0x1e1e, 0 }, + { 0x1f1f, 0x1f1f, 0x1f1f, 0 }, + { 0x2020, 0x2020, 0x2020, 0 }, + { 0x2121, 0x2121, 0x2121, 0 }, + { 0x2222, 0x2222, 0x2222, 0 }, + { 0x2323, 0x2323, 0x2323, 0 }, + { 0x2424, 0x2424, 0x2424, 0 }, + { 0x2525, 0x2525, 0x2525, 0 }, + { 0x2626, 0x2626, 0x2626, 0 }, + { 0x2727, 0x2727, 0x2727, 0 }, + { 0x2828, 0x2828, 0x2828, 0 }, + { 0x2929, 0x2929, 0x2929, 0 }, + { 0x2a2a, 0x2a2a, 0x2a2a, 0 }, + { 0x2b2b, 0x2b2b, 0x2b2b, 0 }, + { 0x2c2c, 0x2c2c, 0x2c2c, 0 }, + { 0x2d2d, 0x2d2d, 0x2d2d, 0 }, + { 0x2e2e, 0x2e2e, 0x2e2e, 0 }, + { 0x2f2f, 0x2f2f, 0x2f2f, 0 }, + { 0x3030, 0x3030, 0x3030, 0 }, + { 0x3131, 0x3131, 0x3131, 0 }, + { 0x3232, 0x3232, 0x3232, 0 }, + { 0x3333, 0x3333, 0x3333, 0 }, + { 0x3434, 0x3434, 0x3434, 0 }, + { 0x3535, 0x3535, 0x3535, 0 }, + { 0x3636, 0x3636, 0x3636, 0 }, + { 0x3737, 0x3737, 0x3737, 0 }, + { 0x3838, 0x3838, 0x3838, 0 }, + { 0x3939, 0x3939, 0x3939, 0 }, + { 0x3a3a, 0x3a3a, 0x3a3a, 0 }, + { 0x3b3b, 0x3b3b, 0x3b3b, 0 }, + { 0x3c3c, 0x3c3c, 0x3c3c, 0 }, + { 0x3d3d, 0x3d3d, 0x3d3d, 0 }, + { 0x3e3e, 0x3e3e, 0x3e3e, 0 }, + { 0x3f3f, 0x3f3f, 0x3f3f, 0 }, + { 0x4040, 0x4040, 0x4040, 0 }, + { 0x4141, 0x4141, 0x4141, 0 }, + { 0x4242, 0x4242, 0x4242, 0 }, + { 0x4343, 0x4343, 0x4343, 0 }, + { 0x4444, 0x4444, 0x4444, 0 }, + { 0x4545, 0x4545, 0x4545, 0 }, + { 0x4646, 0x4646, 0x4646, 0 }, + { 0x4747, 0x4747, 0x4747, 0 }, + { 0x4848, 0x4848, 0x4848, 0 }, + { 0x4949, 0x4949, 0x4949, 0 }, + { 0x4a4a, 0x4a4a, 0x4a4a, 0 }, + { 0x4b4b, 0x4b4b, 0x4b4b, 0 }, + { 0x4c4c, 0x4c4c, 0x4c4c, 0 }, + { 0x4d4d, 0x4d4d, 0x4d4d, 0 }, + { 0x4e4e, 0x4e4e, 0x4e4e, 0 }, + { 0x4f4f, 0x4f4f, 0x4f4f, 0 }, + { 0x5050, 0x5050, 0x5050, 0 }, + { 0x5151, 0x5151, 0x5151, 0 }, + { 0x5252, 0x5252, 0x5252, 0 }, + { 0x5353, 0x5353, 0x5353, 0 }, + { 0x5454, 0x5454, 0x5454, 0 }, + { 0x5555, 0x5555, 0x5555, 0 }, + { 0x5656, 0x5656, 0x5656, 0 }, + { 0x5757, 0x5757, 0x5757, 0 }, + { 0x5858, 0x5858, 0x5858, 0 }, + { 0x5959, 0x5959, 0x5959, 0 }, + { 0x5a5a, 0x5a5a, 0x5a5a, 0 }, + { 0x5b5b, 0x5b5b, 0x5b5b, 0 }, + { 0x5c5c, 0x5c5c, 0x5c5c, 0 }, + { 0x5d5d, 0x5d5d, 0x5d5d, 0 }, + { 0x5e5e, 0x5e5e, 0x5e5e, 0 }, + { 0x5f5f, 0x5f5f, 0x5f5f, 0 }, + { 0x6060, 0x6060, 0x6060, 0 }, + { 0x6161, 0x6161, 0x6161, 0 }, + { 0x6262, 0x6262, 0x6262, 0 }, + { 0x6363, 0x6363, 0x6363, 0 }, + { 0x6464, 0x6464, 0x6464, 0 }, + { 0x6565, 0x6565, 0x6565, 0 }, + { 0x6666, 0x6666, 0x6666, 0 }, + { 0x6767, 0x6767, 0x6767, 0 }, + { 0x6868, 0x6868, 0x6868, 0 }, + { 0x6969, 0x6969, 0x6969, 0 }, + { 0x6a6a, 0x6a6a, 0x6a6a, 0 }, + { 0x6b6b, 0x6b6b, 0x6b6b, 0 }, + { 0x6c6c, 0x6c6c, 0x6c6c, 0 }, + { 0x6d6d, 0x6d6d, 0x6d6d, 0 }, + { 0x6e6e, 0x6e6e, 0x6e6e, 0 }, + { 0x6f6f, 0x6f6f, 0x6f6f, 0 }, + { 0x7070, 0x7070, 0x7070, 0 }, + { 0x7171, 0x7171, 0x7171, 0 }, + { 0x7272, 0x7272, 0x7272, 0 }, + { 0x7373, 0x7373, 0x7373, 0 }, + { 0x7474, 0x7474, 0x7474, 0 }, + { 0x7575, 0x7575, 0x7575, 0 }, + { 0x7676, 0x7676, 0x7676, 0 }, + { 0x7777, 0x7777, 0x7777, 0 }, + { 0x7878, 0x7878, 0x7878, 0 }, + { 0x7979, 0x7979, 0x7979, 0 }, + { 0x7a7a, 0x7a7a, 0x7a7a, 0 }, + { 0x7b7b, 0x7b7b, 0x7b7b, 0 }, + { 0x7c7c, 0x7c7c, 0x7c7c, 0 }, + { 0x7d7d, 0x7d7d, 0x7d7d, 0 }, + { 0x7e7e, 0x7e7e, 0x7e7e, 0 }, + { 0x7f7f, 0x7f7f, 0x7f7f, 0 }, + { 0x8080, 0x8080, 0x8080, 0 }, + { 0x8181, 0x8181, 0x8181, 0 }, + { 0x8282, 0x8282, 0x8282, 0 }, + { 0x8383, 0x8383, 0x8383, 0 }, + { 0x8484, 0x8484, 0x8484, 0 }, + { 0x8585, 0x8585, 0x8585, 0 }, + { 0x8686, 0x8686, 0x8686, 0 }, + { 0x8787, 0x8787, 0x8787, 0 }, + { 0x8888, 0x8888, 0x8888, 0 }, + { 0x8989, 0x8989, 0x8989, 0 }, + { 0x8a8a, 0x8a8a, 0x8a8a, 0 }, + { 0x8b8b, 0x8b8b, 0x8b8b, 0 }, + { 0x8c8c, 0x8c8c, 0x8c8c, 0 }, + { 0x8d8d, 0x8d8d, 0x8d8d, 0 }, + { 0x8e8e, 0x8e8e, 0x8e8e, 0 }, + { 0x8f8f, 0x8f8f, 0x8f8f, 0 }, + { 0x9090, 0x9090, 0x9090, 0 }, + { 0x9191, 0x9191, 0x9191, 0 }, + { 0x9292, 0x9292, 0x9292, 0 }, + { 0x9393, 0x9393, 0x9393, 0 }, + { 0x9494, 0x9494, 0x9494, 0 }, + { 0x9595, 0x9595, 0x9595, 0 }, + { 0x9696, 0x9696, 0x9696, 0 }, + { 0x9797, 0x9797, 0x9797, 0 }, + { 0x9898, 0x9898, 0x9898, 0 }, + { 0x9999, 0x9999, 0x9999, 0 }, + { 0x9a9a, 0x9a9a, 0x9a9a, 0 }, + { 0x9b9b, 0x9b9b, 0x9b9b, 0 }, + { 0x9c9c, 0x9c9c, 0x9c9c, 0 }, + { 0x9d9d, 0x9d9d, 0x9d9d, 0 }, + { 0x9e9e, 0x9e9e, 0x9e9e, 0 }, + { 0x9f9f, 0x9f9f, 0x9f9f, 0 }, + { 0xa0a0, 0xa0a0, 0xa0a0, 0 }, + { 0xa1a1, 0xa1a1, 0xa1a1, 0 }, + { 0xa2a2, 0xa2a2, 0xa2a2, 0 }, + { 0xa3a3, 0xa3a3, 0xa3a3, 0 }, + { 0xa4a4, 0xa4a4, 0xa4a4, 0 }, + { 0xa5a5, 0xa5a5, 0xa5a5, 0 }, + { 0xa6a6, 0xa6a6, 0xa6a6, 0 }, + { 0xa7a7, 0xa7a7, 0xa7a7, 0 }, + { 0xa8a8, 0xa8a8, 0xa8a8, 0 }, + { 0xa9a9, 0xa9a9, 0xa9a9, 0 }, + { 0xaaaa, 0xaaaa, 0xaaaa, 0 }, + { 0xabab, 0xabab, 0xabab, 0 }, + { 0xacac, 0xacac, 0xacac, 0 }, + { 0xadad, 0xadad, 0xadad, 0 }, + { 0xaeae, 0xaeae, 0xaeae, 0 }, + { 0xafaf, 0xafaf, 0xafaf, 0 }, + { 0xb0b0, 0xb0b0, 0xb0b0, 0 }, + { 0xb1b1, 0xb1b1, 0xb1b1, 0 }, + { 0xb2b2, 0xb2b2, 0xb2b2, 0 }, + { 0xb3b3, 0xb3b3, 0xb3b3, 0 }, + { 0xb4b4, 0xb4b4, 0xb4b4, 0 }, + { 0xb5b5, 0xb5b5, 0xb5b5, 0 }, + { 0xb6b6, 0xb6b6, 0xb6b6, 0 }, + { 0xb7b7, 0xb7b7, 0xb7b7, 0 }, + { 0xb8b8, 0xb8b8, 0xb8b8, 0 }, + { 0xb9b9, 0xb9b9, 0xb9b9, 0 }, + { 0xbaba, 0xbaba, 0xbaba, 0 }, + { 0xbbbb, 0xbbbb, 0xbbbb, 0 }, + { 0xbcbc, 0xbcbc, 0xbcbc, 0 }, + { 0xbdbd, 0xbdbd, 0xbdbd, 0 }, + { 0xbebe, 0xbebe, 0xbebe, 0 }, + { 0xbfbf, 0xbfbf, 0xbfbf, 0 }, + { 0xc0c0, 0xc0c0, 0xc0c0, 0 }, + { 0xc1c1, 0xc1c1, 0xc1c1, 0 }, + { 0xc2c2, 0xc2c2, 0xc2c2, 0 }, + { 0xc3c3, 0xc3c3, 0xc3c3, 0 }, + { 0xc4c4, 0xc4c4, 0xc4c4, 0 }, + { 0xc5c5, 0xc5c5, 0xc5c5, 0 }, + { 0xc6c6, 0xc6c6, 0xc6c6, 0 }, + { 0xc7c7, 0xc7c7, 0xc7c7, 0 }, + { 0xc8c8, 0xc8c8, 0xc8c8, 0 }, + { 0xc9c9, 0xc9c9, 0xc9c9, 0 }, + { 0xcaca, 0xcaca, 0xcaca, 0 }, + { 0xcbcb, 0xcbcb, 0xcbcb, 0 }, + { 0xcccc, 0xcccc, 0xcccc, 0 }, + { 0xcdcd, 0xcdcd, 0xcdcd, 0 }, + { 0xcece, 0xcece, 0xcece, 0 }, + { 0xcfcf, 0xcfcf, 0xcfcf, 0 }, + { 0xd0d0, 0xd0d0, 0xd0d0, 0 }, + { 0xd1d1, 0xd1d1, 0xd1d1, 0 }, + { 0xd2d2, 0xd2d2, 0xd2d2, 0 }, + { 0xd3d3, 0xd3d3, 0xd3d3, 0 }, + { 0xd4d4, 0xd4d4, 0xd4d4, 0 }, + { 0xd5d5, 0xd5d5, 0xd5d5, 0 }, + { 0xd6d6, 0xd6d6, 0xd6d6, 0 }, + { 0xd7d7, 0xd7d7, 0xd7d7, 0 }, + { 0xd8d8, 0xd8d8, 0xd8d8, 0 }, + { 0xd9d9, 0xd9d9, 0xd9d9, 0 }, + { 0xdada, 0xdada, 0xdada, 0 }, + { 0xdbdb, 0xdbdb, 0xdbdb, 0 }, + { 0xdcdc, 0xdcdc, 0xdcdc, 0 }, + { 0xdddd, 0xdddd, 0xdddd, 0 }, + { 0xdede, 0xdede, 0xdede, 0 }, + { 0xdfdf, 0xdfdf, 0xdfdf, 0 }, + { 0xe0e0, 0xe0e0, 0xe0e0, 0 }, + { 0xe1e1, 0xe1e1, 0xe1e1, 0 }, + { 0xe2e2, 0xe2e2, 0xe2e2, 0 }, + { 0xe3e3, 0xe3e3, 0xe3e3, 0 }, + { 0xe4e4, 0xe4e4, 0xe4e4, 0 }, + { 0xe5e5, 0xe5e5, 0xe5e5, 0 }, + { 0xe6e6, 0xe6e6, 0xe6e6, 0 }, + { 0xe7e7, 0xe7e7, 0xe7e7, 0 }, + { 0xe8e8, 0xe8e8, 0xe8e8, 0 }, + { 0xe9e9, 0xe9e9, 0xe9e9, 0 }, + { 0xeaea, 0xeaea, 0xeaea, 0 }, + { 0xebeb, 0xebeb, 0xebeb, 0 }, + { 0xecec, 0xecec, 0xecec, 0 }, + { 0xeded, 0xeded, 0xeded, 0 }, + { 0xeeee, 0xeeee, 0xeeee, 0 }, + { 0xefef, 0xefef, 0xefef, 0 }, + { 0xf0f0, 0xf0f0, 0xf0f0, 0 }, + { 0xf1f1, 0xf1f1, 0xf1f1, 0 }, + { 0xf2f2, 0xf2f2, 0xf2f2, 0 }, + { 0xf3f3, 0xf3f3, 0xf3f3, 0 }, + { 0xf4f4, 0xf4f4, 0xf4f4, 0 }, + { 0xf5f5, 0xf5f5, 0xf5f5, 0 }, + { 0xf6f6, 0xf6f6, 0xf6f6, 0 }, + { 0xf7f7, 0xf7f7, 0xf7f7, 0 }, + { 0xf8f8, 0xf8f8, 0xf8f8, 0 }, + { 0xf9f9, 0xf9f9, 0xf9f9, 0 }, + { 0xfafa, 0xfafa, 0xfafa, 0 }, + { 0xfbfb, 0xfbfb, 0xfbfb, 0 }, + { 0xfcfc, 0xfcfc, 0xfcfc, 0 }, + { 0xfdfd, 0xfdfd, 0xfdfd, 0 }, + { 0xfefe, 0xfefe, 0xfefe, 0 }, + { 0xffff, 0xffff, 0xffff, 0 }, +}; + +const struct vkms_color_lut linear_eotf = { + .base = linear_array, + .lut_length = LUT_SIZE, + .channel_value2index_ratio = 0xff00ffll +}; + + +static struct drm_color_lut srgb_array[LUT_SIZE] = { + { 0x0, 0x0, 0x0, 0 }, + { 0x13, 0x13, 0x13, 0 }, + { 0x27, 0x27, 0x27, 0 }, + { 0x3b, 0x3b, 0x3b, 0 }, + { 0x4f, 0x4f, 0x4f, 0 }, + { 0x63, 0x63, 0x63, 0 }, + { 0x77, 0x77, 0x77, 0 }, + { 0x8b, 0x8b, 0x8b, 0 }, + { 0x9f, 0x9f, 0x9f, 0 }, + { 0xb3, 0xb3, 0xb3, 0 }, + { 0xc6, 0xc6, 0xc6, 0 }, + { 0xdb, 0xdb, 0xdb, 0 }, + { 0xf0, 0xf0, 0xf0, 0 }, + { 0x107, 0x107, 0x107, 0 }, + { 0x11f, 0x11f, 0x11f, 0 }, + { 0x139, 0x139, 0x139, 0 }, + { 0x153, 0x153, 0x153, 0 }, + { 0x16f, 0x16f, 0x16f, 0 }, + { 0x18c, 0x18c, 0x18c, 0 }, + { 0x1aa, 0x1aa, 0x1aa, 0 }, + { 0x1ca, 0x1ca, 0x1ca, 0 }, + { 0x1eb, 0x1eb, 0x1eb, 0 }, + { 0x20d, 0x20d, 0x20d, 0 }, + { 0x231, 0x231, 0x231, 0 }, + { 0x256, 0x256, 0x256, 0 }, + { 0x27d, 0x27d, 0x27d, 0 }, + { 0x2a4, 0x2a4, 0x2a4, 0 }, + { 0x2ce, 0x2ce, 0x2ce, 0 }, + { 0x2f9, 0x2f9, 0x2f9, 0 }, + { 0x325, 0x325, 0x325, 0 }, + { 0x352, 0x352, 0x352, 0 }, + { 0x381, 0x381, 0x381, 0 }, + { 0x3b2, 0x3b2, 0x3b2, 0 }, + { 0x3e4, 0x3e4, 0x3e4, 0 }, + { 0x418, 0x418, 0x418, 0 }, + { 0x44d, 0x44d, 0x44d, 0 }, + { 0x484, 0x484, 0x484, 0 }, + { 0x4bc, 0x4bc, 0x4bc, 0 }, + { 0x4f6, 0x4f6, 0x4f6, 0 }, + { 0x531, 0x531, 0x531, 0 }, + { 0x56e, 0x56e, 0x56e, 0 }, + { 0x5ad, 0x5ad, 0x5ad, 0 }, + { 0x5ed, 0x5ed, 0x5ed, 0 }, + { 0x62f, 0x62f, 0x62f, 0 }, + { 0x672, 0x672, 0x672, 0 }, + { 0x6b7, 0x6b7, 0x6b7, 0 }, + { 0x6fe, 0x6fe, 0x6fe, 0 }, + { 0x746, 0x746, 0x746, 0 }, + { 0x791, 0x791, 0x791, 0 }, + { 0x7dc, 0x7dc, 0x7dc, 0 }, + { 0x82a, 0x82a, 0x82a, 0 }, + { 0x879, 0x879, 0x879, 0 }, + { 0x8ca, 0x8ca, 0x8ca, 0 }, + { 0x91d, 0x91d, 0x91d, 0 }, + { 0x971, 0x971, 0x971, 0 }, + { 0x9c7, 0x9c7, 0x9c7, 0 }, + { 0xa1f, 0xa1f, 0xa1f, 0 }, + { 0xa79, 0xa79, 0xa79, 0 }, + { 0xad4, 0xad4, 0xad4, 0 }, + { 0xb32, 0xb32, 0xb32, 0 }, + { 0xb91, 0xb91, 0xb91, 0 }, + { 0xbf2, 0xbf2, 0xbf2, 0 }, + { 0xc54, 0xc54, 0xc54, 0 }, + { 0xcb9, 0xcb9, 0xcb9, 0 }, + { 0xd1f, 0xd1f, 0xd1f, 0 }, + { 0xd88, 0xd88, 0xd88, 0 }, + { 0xdf2, 0xdf2, 0xdf2, 0 }, + { 0xe5e, 0xe5e, 0xe5e, 0 }, + { 0xecc, 0xecc, 0xecc, 0 }, + { 0xf3c, 0xf3c, 0xf3c, 0 }, + { 0xfad, 0xfad, 0xfad, 0 }, + { 0x1021, 0x1021, 0x1021, 0 }, + { 0x1096, 0x1096, 0x1096, 0 }, + { 0x110e, 0x110e, 0x110e, 0 }, + { 0x1187, 0x1187, 0x1187, 0 }, + { 0x1203, 0x1203, 0x1203, 0 }, + { 0x1280, 0x1280, 0x1280, 0 }, + { 0x12ff, 0x12ff, 0x12ff, 0 }, + { 0x1380, 0x1380, 0x1380, 0 }, + { 0x1404, 0x1404, 0x1404, 0 }, + { 0x1489, 0x1489, 0x1489, 0 }, + { 0x1510, 0x1510, 0x1510, 0 }, + { 0x1599, 0x1599, 0x1599, 0 }, + { 0x1624, 0x1624, 0x1624, 0 }, + { 0x16b2, 0x16b2, 0x16b2, 0 }, + { 0x1741, 0x1741, 0x1741, 0 }, + { 0x17d2, 0x17d2, 0x17d2, 0 }, + { 0x1865, 0x1865, 0x1865, 0 }, + { 0x18fb, 0x18fb, 0x18fb, 0 }, + { 0x1992, 0x1992, 0x1992, 0 }, + { 0x1a2c, 0x1a2c, 0x1a2c, 0 }, + { 0x1ac8, 0x1ac8, 0x1ac8, 0 }, + { 0x1b65, 0x1b65, 0x1b65, 0 }, + { 0x1c05, 0x1c05, 0x1c05, 0 }, + { 0x1ca7, 0x1ca7, 0x1ca7, 0 }, + { 0x1d4b, 0x1d4b, 0x1d4b, 0 }, + { 0x1df1, 0x1df1, 0x1df1, 0 }, + { 0x1e99, 0x1e99, 0x1e99, 0 }, + { 0x1f44, 0x1f44, 0x1f44, 0 }, + { 0x1ff0, 0x1ff0, 0x1ff0, 0 }, + { 0x209f, 0x209f, 0x209f, 0 }, + { 0x2150, 0x2150, 0x2150, 0 }, + { 0x2203, 0x2203, 0x2203, 0 }, + { 0x22b8, 0x22b8, 0x22b8, 0 }, + { 0x2370, 0x2370, 0x2370, 0 }, + { 0x2429, 0x2429, 0x2429, 0 }, + { 0x24e5, 0x24e5, 0x24e5, 0 }, + { 0x25a3, 0x25a3, 0x25a3, 0 }, + { 0x2663, 0x2663, 0x2663, 0 }, + { 0x2726, 0x2726, 0x2726, 0 }, + { 0x27ea, 0x27ea, 0x27ea, 0 }, + { 0x28b1, 0x28b1, 0x28b1, 0 }, + { 0x297a, 0x297a, 0x297a, 0 }, + { 0x2a45, 0x2a45, 0x2a45, 0 }, + { 0x2b13, 0x2b13, 0x2b13, 0 }, + { 0x2be3, 0x2be3, 0x2be3, 0 }, + { 0x2cb5, 0x2cb5, 0x2cb5, 0 }, + { 0x2d89, 0x2d89, 0x2d89, 0 }, + { 0x2e60, 0x2e60, 0x2e60, 0 }, + { 0x2f39, 0x2f39, 0x2f39, 0 }, + { 0x3014, 0x3014, 0x3014, 0 }, + { 0x30f2, 0x30f2, 0x30f2, 0 }, + { 0x31d2, 0x31d2, 0x31d2, 0 }, + { 0x32b4, 0x32b4, 0x32b4, 0 }, + { 0x3398, 0x3398, 0x3398, 0 }, + { 0x347f, 0x347f, 0x347f, 0 }, + { 0x3569, 0x3569, 0x3569, 0 }, + { 0x3654, 0x3654, 0x3654, 0 }, + { 0x3742, 0x3742, 0x3742, 0 }, + { 0x3832, 0x3832, 0x3832, 0 }, + { 0x3925, 0x3925, 0x3925, 0 }, + { 0x3a1a, 0x3a1a, 0x3a1a, 0 }, + { 0x3b11, 0x3b11, 0x3b11, 0 }, + { 0x3c0b, 0x3c0b, 0x3c0b, 0 }, + { 0x3d07, 0x3d07, 0x3d07, 0 }, + { 0x3e05, 0x3e05, 0x3e05, 0 }, + { 0x3f06, 0x3f06, 0x3f06, 0 }, + { 0x400a, 0x400a, 0x400a, 0 }, + { 0x410f, 0x410f, 0x410f, 0 }, + { 0x4218, 0x4218, 0x4218, 0 }, + { 0x4322, 0x4322, 0x4322, 0 }, + { 0x442f, 0x442f, 0x442f, 0 }, + { 0x453f, 0x453f, 0x453f, 0 }, + { 0x4650, 0x4650, 0x4650, 0 }, + { 0x4765, 0x4765, 0x4765, 0 }, + { 0x487c, 0x487c, 0x487c, 0 }, + { 0x4995, 0x4995, 0x4995, 0 }, + { 0x4ab1, 0x4ab1, 0x4ab1, 0 }, + { 0x4bcf, 0x4bcf, 0x4bcf, 0 }, + { 0x4cf0, 0x4cf0, 0x4cf0, 0 }, + { 0x4e13, 0x4e13, 0x4e13, 0 }, + { 0x4f39, 0x4f39, 0x4f39, 0 }, + { 0x5061, 0x5061, 0x5061, 0 }, + { 0x518b, 0x518b, 0x518b, 0 }, + { 0x52b9, 0x52b9, 0x52b9, 0 }, + { 0x53e8, 0x53e8, 0x53e8, 0 }, + { 0x551b, 0x551b, 0x551b, 0 }, + { 0x5650, 0x5650, 0x5650, 0 }, + { 0x5787, 0x5787, 0x5787, 0 }, + { 0x58c1, 0x58c1, 0x58c1, 0 }, + { 0x59fd, 0x59fd, 0x59fd, 0 }, + { 0x5b3c, 0x5b3c, 0x5b3c, 0 }, + { 0x5c7e, 0x5c7e, 0x5c7e, 0 }, + { 0x5dc2, 0x5dc2, 0x5dc2, 0 }, + { 0x5f09, 0x5f09, 0x5f09, 0 }, + { 0x6052, 0x6052, 0x6052, 0 }, + { 0x619e, 0x619e, 0x619e, 0 }, + { 0x62ec, 0x62ec, 0x62ec, 0 }, + { 0x643d, 0x643d, 0x643d, 0 }, + { 0x6591, 0x6591, 0x6591, 0 }, + { 0x66e7, 0x66e7, 0x66e7, 0 }, + { 0x6840, 0x6840, 0x6840, 0 }, + { 0x699b, 0x699b, 0x699b, 0 }, + { 0x6afa, 0x6afa, 0x6afa, 0 }, + { 0x6c5a, 0x6c5a, 0x6c5a, 0 }, + { 0x6dbe, 0x6dbe, 0x6dbe, 0 }, + { 0x6f24, 0x6f24, 0x6f24, 0 }, + { 0x708c, 0x708c, 0x708c, 0 }, + { 0x71f8, 0x71f8, 0x71f8, 0 }, + { 0x7366, 0x7366, 0x7366, 0 }, + { 0x74d6, 0x74d6, 0x74d6, 0 }, + { 0x764a, 0x764a, 0x764a, 0 }, + { 0x77c0, 0x77c0, 0x77c0, 0 }, + { 0x7938, 0x7938, 0x7938, 0 }, + { 0x7ab4, 0x7ab4, 0x7ab4, 0 }, + { 0x7c32, 0x7c32, 0x7c32, 0 }, + { 0x7db3, 0x7db3, 0x7db3, 0 }, + { 0x7f36, 0x7f36, 0x7f36, 0 }, + { 0x80bc, 0x80bc, 0x80bc, 0 }, + { 0x8245, 0x8245, 0x8245, 0 }, + { 0x83d1, 0x83d1, 0x83d1, 0 }, + { 0x855f, 0x855f, 0x855f, 0 }, + { 0x86f0, 0x86f0, 0x86f0, 0 }, + { 0x8884, 0x8884, 0x8884, 0 }, + { 0x8a1a, 0x8a1a, 0x8a1a, 0 }, + { 0x8bb4, 0x8bb4, 0x8bb4, 0 }, + { 0x8d50, 0x8d50, 0x8d50, 0 }, + { 0x8eee, 0x8eee, 0x8eee, 0 }, + { 0x9090, 0x9090, 0x9090, 0 }, + { 0x9234, 0x9234, 0x9234, 0 }, + { 0x93db, 0x93db, 0x93db, 0 }, + { 0x9585, 0x9585, 0x9585, 0 }, + { 0x9732, 0x9732, 0x9732, 0 }, + { 0x98e1, 0x98e1, 0x98e1, 0 }, + { 0x9a93, 0x9a93, 0x9a93, 0 }, + { 0x9c48, 0x9c48, 0x9c48, 0 }, + { 0x9e00, 0x9e00, 0x9e00, 0 }, + { 0x9fbb, 0x9fbb, 0x9fbb, 0 }, + { 0xa178, 0xa178, 0xa178, 0 }, + { 0xa338, 0xa338, 0xa338, 0 }, + { 0xa4fb, 0xa4fb, 0xa4fb, 0 }, + { 0xa6c1, 0xa6c1, 0xa6c1, 0 }, + { 0xa88a, 0xa88a, 0xa88a, 0 }, + { 0xaa56, 0xaa56, 0xaa56, 0 }, + { 0xac24, 0xac24, 0xac24, 0 }, + { 0xadf5, 0xadf5, 0xadf5, 0 }, + { 0xafc9, 0xafc9, 0xafc9, 0 }, + { 0xb1a0, 0xb1a0, 0xb1a0, 0 }, + { 0xb37a, 0xb37a, 0xb37a, 0 }, + { 0xb557, 0xb557, 0xb557, 0 }, + { 0xb736, 0xb736, 0xb736, 0 }, + { 0xb919, 0xb919, 0xb919, 0 }, + { 0xbafe, 0xbafe, 0xbafe, 0 }, + { 0xbce6, 0xbce6, 0xbce6, 0 }, + { 0xbed2, 0xbed2, 0xbed2, 0 }, + { 0xc0c0, 0xc0c0, 0xc0c0, 0 }, + { 0xc2b0, 0xc2b0, 0xc2b0, 0 }, + { 0xc4a4, 0xc4a4, 0xc4a4, 0 }, + { 0xc69b, 0xc69b, 0xc69b, 0 }, + { 0xc895, 0xc895, 0xc895, 0 }, + { 0xca91, 0xca91, 0xca91, 0 }, + { 0xcc91, 0xcc91, 0xcc91, 0 }, + { 0xce93, 0xce93, 0xce93, 0 }, + { 0xd098, 0xd098, 0xd098, 0 }, + { 0xd2a1, 0xd2a1, 0xd2a1, 0 }, + { 0xd4ac, 0xd4ac, 0xd4ac, 0 }, + { 0xd6ba, 0xd6ba, 0xd6ba, 0 }, + { 0xd8cb, 0xd8cb, 0xd8cb, 0 }, + { 0xdadf, 0xdadf, 0xdadf, 0 }, + { 0xdcf7, 0xdcf7, 0xdcf7, 0 }, + { 0xdf11, 0xdf11, 0xdf11, 0 }, + { 0xe12e, 0xe12e, 0xe12e, 0 }, + { 0xe34e, 0xe34e, 0xe34e, 0 }, + { 0xe571, 0xe571, 0xe571, 0 }, + { 0xe796, 0xe796, 0xe796, 0 }, + { 0xe9bf, 0xe9bf, 0xe9bf, 0 }, + { 0xebeb, 0xebeb, 0xebeb, 0 }, + { 0xee1a, 0xee1a, 0xee1a, 0 }, + { 0xf04c, 0xf04c, 0xf04c, 0 }, + { 0xf281, 0xf281, 0xf281, 0 }, + { 0xf4b9, 0xf4b9, 0xf4b9, 0 }, + { 0xf6f4, 0xf6f4, 0xf6f4, 0 }, + { 0xf932, 0xf932, 0xf932, 0 }, + { 0xfb73, 0xfb73, 0xfb73, 0 }, + { 0xfdb7, 0xfdb7, 0xfdb7, 0 }, + { 0xffff, 0xffff, 0xffff, 0 }, +}; + +const struct vkms_color_lut srgb_eotf = { + .base = srgb_array, + .lut_length = LUT_SIZE, + .channel_value2index_ratio = 0xff00ffll +}; + +static struct drm_color_lut srgb_inv_array[LUT_SIZE] = { + { 0x0, 0x0, 0x0, 0 }, + { 0xcc2, 0xcc2, 0xcc2, 0 }, + { 0x15be, 0x15be, 0x15be, 0 }, + { 0x1c56, 0x1c56, 0x1c56, 0 }, + { 0x21bd, 0x21bd, 0x21bd, 0 }, + { 0x2666, 0x2666, 0x2666, 0 }, + { 0x2a8a, 0x2a8a, 0x2a8a, 0 }, + { 0x2e4c, 0x2e4c, 0x2e4c, 0 }, + { 0x31c0, 0x31c0, 0x31c0, 0 }, + { 0x34f6, 0x34f6, 0x34f6, 0 }, + { 0x37f9, 0x37f9, 0x37f9, 0 }, + { 0x3acf, 0x3acf, 0x3acf, 0 }, + { 0x3d80, 0x3d80, 0x3d80, 0 }, + { 0x4010, 0x4010, 0x4010, 0 }, + { 0x4284, 0x4284, 0x4284, 0 }, + { 0x44dd, 0x44dd, 0x44dd, 0 }, + { 0x4720, 0x4720, 0x4720, 0 }, + { 0x494e, 0x494e, 0x494e, 0 }, + { 0x4b69, 0x4b69, 0x4b69, 0 }, + { 0x4d73, 0x4d73, 0x4d73, 0 }, + { 0x4f6e, 0x4f6e, 0x4f6e, 0 }, + { 0x5159, 0x5159, 0x5159, 0 }, + { 0x5337, 0x5337, 0x5337, 0 }, + { 0x5509, 0x5509, 0x5509, 0 }, + { 0x56cf, 0x56cf, 0x56cf, 0 }, + { 0x588a, 0x588a, 0x588a, 0 }, + { 0x5a3b, 0x5a3b, 0x5a3b, 0 }, + { 0x5be2, 0x5be2, 0x5be2, 0 }, + { 0x5d80, 0x5d80, 0x5d80, 0 }, + { 0x5f16, 0x5f16, 0x5f16, 0 }, + { 0x60a4, 0x60a4, 0x60a4, 0 }, + { 0x6229, 0x6229, 0x6229, 0 }, + { 0x63a8, 0x63a8, 0x63a8, 0 }, + { 0x6520, 0x6520, 0x6520, 0 }, + { 0x6691, 0x6691, 0x6691, 0 }, + { 0x67fc, 0x67fc, 0x67fc, 0 }, + { 0x6961, 0x6961, 0x6961, 0 }, + { 0x6ac0, 0x6ac0, 0x6ac0, 0 }, + { 0x6c19, 0x6c19, 0x6c19, 0 }, + { 0x6d6e, 0x6d6e, 0x6d6e, 0 }, + { 0x6ebd, 0x6ebd, 0x6ebd, 0 }, + { 0x7008, 0x7008, 0x7008, 0 }, + { 0x714d, 0x714d, 0x714d, 0 }, + { 0x728f, 0x728f, 0x728f, 0 }, + { 0x73cc, 0x73cc, 0x73cc, 0 }, + { 0x7504, 0x7504, 0x7504, 0 }, + { 0x7639, 0x7639, 0x7639, 0 }, + { 0x776a, 0x776a, 0x776a, 0 }, + { 0x7897, 0x7897, 0x7897, 0 }, + { 0x79c1, 0x79c1, 0x79c1, 0 }, + { 0x7ae7, 0x7ae7, 0x7ae7, 0 }, + { 0x7c09, 0x7c09, 0x7c09, 0 }, + { 0x7d28, 0x7d28, 0x7d28, 0 }, + { 0x7e44, 0x7e44, 0x7e44, 0 }, + { 0x7f5d, 0x7f5d, 0x7f5d, 0 }, + { 0x8073, 0x8073, 0x8073, 0 }, + { 0x8186, 0x8186, 0x8186, 0 }, + { 0x8296, 0x8296, 0x8296, 0 }, + { 0x83a4, 0x83a4, 0x83a4, 0 }, + { 0x84ae, 0x84ae, 0x84ae, 0 }, + { 0x85b6, 0x85b6, 0x85b6, 0 }, + { 0x86bc, 0x86bc, 0x86bc, 0 }, + { 0x87bf, 0x87bf, 0x87bf, 0 }, + { 0x88bf, 0x88bf, 0x88bf, 0 }, + { 0x89be, 0x89be, 0x89be, 0 }, + { 0x8ab9, 0x8ab9, 0x8ab9, 0 }, + { 0x8bb3, 0x8bb3, 0x8bb3, 0 }, + { 0x8cab, 0x8cab, 0x8cab, 0 }, + { 0x8da0, 0x8da0, 0x8da0, 0 }, + { 0x8e93, 0x8e93, 0x8e93, 0 }, + { 0x8f84, 0x8f84, 0x8f84, 0 }, + { 0x9073, 0x9073, 0x9073, 0 }, + { 0x9161, 0x9161, 0x9161, 0 }, + { 0x924c, 0x924c, 0x924c, 0 }, + { 0x9335, 0x9335, 0x9335, 0 }, + { 0x941d, 0x941d, 0x941d, 0 }, + { 0x9503, 0x9503, 0x9503, 0 }, + { 0x95e7, 0x95e7, 0x95e7, 0 }, + { 0x96c9, 0x96c9, 0x96c9, 0 }, + { 0x97aa, 0x97aa, 0x97aa, 0 }, + { 0x9889, 0x9889, 0x9889, 0 }, + { 0x9966, 0x9966, 0x9966, 0 }, + { 0x9a42, 0x9a42, 0x9a42, 0 }, + { 0x9b1c, 0x9b1c, 0x9b1c, 0 }, + { 0x9bf5, 0x9bf5, 0x9bf5, 0 }, + { 0x9ccc, 0x9ccc, 0x9ccc, 0 }, + { 0x9da1, 0x9da1, 0x9da1, 0 }, + { 0x9e76, 0x9e76, 0x9e76, 0 }, + { 0x9f49, 0x9f49, 0x9f49, 0 }, + { 0xa01a, 0xa01a, 0xa01a, 0 }, + { 0xa0ea, 0xa0ea, 0xa0ea, 0 }, + { 0xa1b9, 0xa1b9, 0xa1b9, 0 }, + { 0xa286, 0xa286, 0xa286, 0 }, + { 0xa352, 0xa352, 0xa352, 0 }, + { 0xa41d, 0xa41d, 0xa41d, 0 }, + { 0xa4e7, 0xa4e7, 0xa4e7, 0 }, + { 0xa5af, 0xa5af, 0xa5af, 0 }, + { 0xa676, 0xa676, 0xa676, 0 }, + { 0xa73c, 0xa73c, 0xa73c, 0 }, + { 0xa801, 0xa801, 0xa801, 0 }, + { 0xa8c5, 0xa8c5, 0xa8c5, 0 }, + { 0xa987, 0xa987, 0xa987, 0 }, + { 0xaa48, 0xaa48, 0xaa48, 0 }, + { 0xab09, 0xab09, 0xab09, 0 }, + { 0xabc8, 0xabc8, 0xabc8, 0 }, + { 0xac86, 0xac86, 0xac86, 0 }, + { 0xad43, 0xad43, 0xad43, 0 }, + { 0xadff, 0xadff, 0xadff, 0 }, + { 0xaeba, 0xaeba, 0xaeba, 0 }, + { 0xaf74, 0xaf74, 0xaf74, 0 }, + { 0xb02d, 0xb02d, 0xb02d, 0 }, + { 0xb0e5, 0xb0e5, 0xb0e5, 0 }, + { 0xb19c, 0xb19c, 0xb19c, 0 }, + { 0xb252, 0xb252, 0xb252, 0 }, + { 0xb307, 0xb307, 0xb307, 0 }, + { 0xb3bb, 0xb3bb, 0xb3bb, 0 }, + { 0xb46f, 0xb46f, 0xb46f, 0 }, + { 0xb521, 0xb521, 0xb521, 0 }, + { 0xb5d3, 0xb5d3, 0xb5d3, 0 }, + { 0xb683, 0xb683, 0xb683, 0 }, + { 0xb733, 0xb733, 0xb733, 0 }, + { 0xb7e2, 0xb7e2, 0xb7e2, 0 }, + { 0xb890, 0xb890, 0xb890, 0 }, + { 0xb93d, 0xb93d, 0xb93d, 0 }, + { 0xb9ea, 0xb9ea, 0xb9ea, 0 }, + { 0xba96, 0xba96, 0xba96, 0 }, + { 0xbb40, 0xbb40, 0xbb40, 0 }, + { 0xbbea, 0xbbea, 0xbbea, 0 }, + { 0xbc94, 0xbc94, 0xbc94, 0 }, + { 0xbd3c, 0xbd3c, 0xbd3c, 0 }, + { 0xbde4, 0xbde4, 0xbde4, 0 }, + { 0xbe8b, 0xbe8b, 0xbe8b, 0 }, + { 0xbf31, 0xbf31, 0xbf31, 0 }, + { 0xbfd7, 0xbfd7, 0xbfd7, 0 }, + { 0xc07b, 0xc07b, 0xc07b, 0 }, + { 0xc120, 0xc120, 0xc120, 0 }, + { 0xc1c3, 0xc1c3, 0xc1c3, 0 }, + { 0xc266, 0xc266, 0xc266, 0 }, + { 0xc308, 0xc308, 0xc308, 0 }, + { 0xc3a9, 0xc3a9, 0xc3a9, 0 }, + { 0xc449, 0xc449, 0xc449, 0 }, + { 0xc4e9, 0xc4e9, 0xc4e9, 0 }, + { 0xc589, 0xc589, 0xc589, 0 }, + { 0xc627, 0xc627, 0xc627, 0 }, + { 0xc6c5, 0xc6c5, 0xc6c5, 0 }, + { 0xc763, 0xc763, 0xc763, 0 }, + { 0xc7ff, 0xc7ff, 0xc7ff, 0 }, + { 0xc89b, 0xc89b, 0xc89b, 0 }, + { 0xc937, 0xc937, 0xc937, 0 }, + { 0xc9d2, 0xc9d2, 0xc9d2, 0 }, + { 0xca6c, 0xca6c, 0xca6c, 0 }, + { 0xcb06, 0xcb06, 0xcb06, 0 }, + { 0xcb9f, 0xcb9f, 0xcb9f, 0 }, + { 0xcc37, 0xcc37, 0xcc37, 0 }, + { 0xcccf, 0xcccf, 0xcccf, 0 }, + { 0xcd66, 0xcd66, 0xcd66, 0 }, + { 0xcdfd, 0xcdfd, 0xcdfd, 0 }, + { 0xce93, 0xce93, 0xce93, 0 }, + { 0xcf29, 0xcf29, 0xcf29, 0 }, + { 0xcfbe, 0xcfbe, 0xcfbe, 0 }, + { 0xd053, 0xd053, 0xd053, 0 }, + { 0xd0e7, 0xd0e7, 0xd0e7, 0 }, + { 0xd17a, 0xd17a, 0xd17a, 0 }, + { 0xd20d, 0xd20d, 0xd20d, 0 }, + { 0xd2a0, 0xd2a0, 0xd2a0, 0 }, + { 0xd331, 0xd331, 0xd331, 0 }, + { 0xd3c3, 0xd3c3, 0xd3c3, 0 }, + { 0xd454, 0xd454, 0xd454, 0 }, + { 0xd4e4, 0xd4e4, 0xd4e4, 0 }, + { 0xd574, 0xd574, 0xd574, 0 }, + { 0xd603, 0xd603, 0xd603, 0 }, + { 0xd692, 0xd692, 0xd692, 0 }, + { 0xd720, 0xd720, 0xd720, 0 }, + { 0xd7ae, 0xd7ae, 0xd7ae, 0 }, + { 0xd83c, 0xd83c, 0xd83c, 0 }, + { 0xd8c9, 0xd8c9, 0xd8c9, 0 }, + { 0xd955, 0xd955, 0xd955, 0 }, + { 0xd9e1, 0xd9e1, 0xd9e1, 0 }, + { 0xda6d, 0xda6d, 0xda6d, 0 }, + { 0xdaf8, 0xdaf8, 0xdaf8, 0 }, + { 0xdb83, 0xdb83, 0xdb83, 0 }, + { 0xdc0d, 0xdc0d, 0xdc0d, 0 }, + { 0xdc97, 0xdc97, 0xdc97, 0 }, + { 0xdd20, 0xdd20, 0xdd20, 0 }, + { 0xdda9, 0xdda9, 0xdda9, 0 }, + { 0xde31, 0xde31, 0xde31, 0 }, + { 0xdeb9, 0xdeb9, 0xdeb9, 0 }, + { 0xdf41, 0xdf41, 0xdf41, 0 }, + { 0xdfc8, 0xdfc8, 0xdfc8, 0 }, + { 0xe04f, 0xe04f, 0xe04f, 0 }, + { 0xe0d5, 0xe0d5, 0xe0d5, 0 }, + { 0xe15b, 0xe15b, 0xe15b, 0 }, + { 0xe1e0, 0xe1e0, 0xe1e0, 0 }, + { 0xe266, 0xe266, 0xe266, 0 }, + { 0xe2ea, 0xe2ea, 0xe2ea, 0 }, + { 0xe36f, 0xe36f, 0xe36f, 0 }, + { 0xe3f3, 0xe3f3, 0xe3f3, 0 }, + { 0xe476, 0xe476, 0xe476, 0 }, + { 0xe4f9, 0xe4f9, 0xe4f9, 0 }, + { 0xe57c, 0xe57c, 0xe57c, 0 }, + { 0xe5fe, 0xe5fe, 0xe5fe, 0 }, + { 0xe680, 0xe680, 0xe680, 0 }, + { 0xe702, 0xe702, 0xe702, 0 }, + { 0xe783, 0xe783, 0xe783, 0 }, + { 0xe804, 0xe804, 0xe804, 0 }, + { 0xe884, 0xe884, 0xe884, 0 }, + { 0xe905, 0xe905, 0xe905, 0 }, + { 0xe984, 0xe984, 0xe984, 0 }, + { 0xea04, 0xea04, 0xea04, 0 }, + { 0xea83, 0xea83, 0xea83, 0 }, + { 0xeb02, 0xeb02, 0xeb02, 0 }, + { 0xeb80, 0xeb80, 0xeb80, 0 }, + { 0xebfe, 0xebfe, 0xebfe, 0 }, + { 0xec7b, 0xec7b, 0xec7b, 0 }, + { 0xecf9, 0xecf9, 0xecf9, 0 }, + { 0xed76, 0xed76, 0xed76, 0 }, + { 0xedf2, 0xedf2, 0xedf2, 0 }, + { 0xee6f, 0xee6f, 0xee6f, 0 }, + { 0xeeeb, 0xeeeb, 0xeeeb, 0 }, + { 0xef66, 0xef66, 0xef66, 0 }, + { 0xefe2, 0xefe2, 0xefe2, 0 }, + { 0xf05d, 0xf05d, 0xf05d, 0 }, + { 0xf0d7, 0xf0d7, 0xf0d7, 0 }, + { 0xf152, 0xf152, 0xf152, 0 }, + { 0xf1cc, 0xf1cc, 0xf1cc, 0 }, + { 0xf245, 0xf245, 0xf245, 0 }, + { 0xf2bf, 0xf2bf, 0xf2bf, 0 }, + { 0xf338, 0xf338, 0xf338, 0 }, + { 0xf3b0, 0xf3b0, 0xf3b0, 0 }, + { 0xf429, 0xf429, 0xf429, 0 }, + { 0xf4a1, 0xf4a1, 0xf4a1, 0 }, + { 0xf519, 0xf519, 0xf519, 0 }, + { 0xf590, 0xf590, 0xf590, 0 }, + { 0xf608, 0xf608, 0xf608, 0 }, + { 0xf67e, 0xf67e, 0xf67e, 0 }, + { 0xf6f5, 0xf6f5, 0xf6f5, 0 }, + { 0xf76b, 0xf76b, 0xf76b, 0 }, + { 0xf7e1, 0xf7e1, 0xf7e1, 0 }, + { 0xf857, 0xf857, 0xf857, 0 }, + { 0xf8cd, 0xf8cd, 0xf8cd, 0 }, + { 0xf942, 0xf942, 0xf942, 0 }, + { 0xf9b7, 0xf9b7, 0xf9b7, 0 }, + { 0xfa2b, 0xfa2b, 0xfa2b, 0 }, + { 0xfaa0, 0xfaa0, 0xfaa0, 0 }, + { 0xfb14, 0xfb14, 0xfb14, 0 }, + { 0xfb88, 0xfb88, 0xfb88, 0 }, + { 0xfbfb, 0xfbfb, 0xfbfb, 0 }, + { 0xfc6e, 0xfc6e, 0xfc6e, 0 }, + { 0xfce1, 0xfce1, 0xfce1, 0 }, + { 0xfd54, 0xfd54, 0xfd54, 0 }, + { 0xfdc6, 0xfdc6, 0xfdc6, 0 }, + { 0xfe39, 0xfe39, 0xfe39, 0 }, + { 0xfeaa, 0xfeaa, 0xfeaa, 0 }, + { 0xff1c, 0xff1c, 0xff1c, 0 }, + { 0xff8d, 0xff8d, 0xff8d, 0 }, + { 0xffff, 0xffff, 0xffff, 0 }, +}; + +const struct vkms_color_lut srgb_inv_eotf = { + .base = srgb_inv_array, + .lut_length = LUT_SIZE, + .channel_value2index_ratio = 0xff00ffll +}; diff --git a/drivers/gpu/drm/vkms/vkms_luts.h b/drivers/gpu/drm/vkms/vkms_luts.h new file mode 100644 index 000000000000..053512a643f7 --- /dev/null +++ b/drivers/gpu/drm/vkms/vkms_luts.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef _VKMS_LUTS_H_ +#define _VKMS_LUTS_H_ + +#define LUT_SIZE 256 + +extern const struct vkms_color_lut linear_eotf; +extern const struct vkms_color_lut srgb_eotf; +extern const struct vkms_color_lut srgb_inv_eotf; + +#endif /* _VKMS_LUTS_H_ */ \ No newline at end of file diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index e5c625ab8e3e..8520ee0534d1 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -215,5 +215,7 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, drm_plane_create_rotation_property(&plane->base, DRM_MODE_ROTATE_0, DRM_MODE_ROTATE_MASK | DRM_MODE_REFLECT_MASK); + vkms_initialize_colorops(&plane->base); + return plane; } From patchwork Thu Oct 3 20:00:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821520 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 D15D7CF34C5 for ; Thu, 3 Oct 2024 20:03:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 625EF10E95C; Thu, 3 Oct 2024 20:01:59 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="X/gaTdrP"; dkim-atps=neutral Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2045.outbound.protection.outlook.com [40.107.244.45]) by gabe.freedesktop.org (Postfix) with ESMTPS id 541C410E90F; Thu, 3 Oct 2024 20:01:48 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gSsRSLCPaYE42H2qo4zySNS9MIvWUxghbs4oR6WPNdp0BEbp5ZHoOfgtKkJFDC1gHndkdTYxZVkCnNSO3f6UTuk1MeLgvkErGtgqtyClo7uFU8o9cIrPW/OipPhR5WFcngSkUjkfME5ziNZLvyKOZBpaiJmcSWBjCf3YCXwLR6HbIgkftE/4F4PcHVlMEzpQkPNTILv9sFasNq1W8PDjJNzEOEC+IJhCU8nPFXZgXPVSWGwcAOft4chM2PCDIdwQrOhTbfxTmck7ZyyRUUu1shZWTkJKrPja5zFEgVPxTiC1LYoSBdAi5yPnu+TUtf2T/7HPp2j25QFJlWA8CM4bug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=ulwO6BuqA7uaquG9sNAY2j3dUQlN10GCkgkxIwjFSlc=; b=fCtaWec/yBOTNEETSC2t+7Ve5PXNDerb/umcjT0XHsBKH/MoY0thVXURr6XnbMmtDdRne4Cz5qx1tw0/4rO7R0aJoSLHh9L3Bb1+LxbVaBO19/nMP+8RulGd7B8Cnm8NPz5gUz6+GOCEH8PgKCS+s2MKvX3UfpETE5Mily7EzW7uLU2MT0SZyh2kHYWzYWrdk33BlD21NcJKbuo19QHeCLPpvZRx8kp2CoQ25FJCH8D0APhaYle/jNJi2R7LKnG3PZdnrNYapZZP8buLDl/t/2HT6cO3Xs2G4R/mCkKqMnld0tbvLd1Yc/EvsIjdh84AR4+Zd/MHwiIzbM4N/u99Zw== 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=ulwO6BuqA7uaquG9sNAY2j3dUQlN10GCkgkxIwjFSlc=; b=X/gaTdrP3XNFjF/yF6l60q0Jkb/E94noqzGduUy06q0MY88sot2yGTL2Q/hyM5VR/geJ0WzK9WbYdcIPnR0vghGE6wSgu5ZyjUN48UMz2SPcabefrHBviyAjgShHeMK4aqgy37trr4OncnpkqPaFEntBtDXolqwM3xPKAFtAltE= Received: from CH0PR03CA0243.namprd03.prod.outlook.com (2603:10b6:610:e5::8) by DS0PR12MB7559.namprd12.prod.outlook.com (2603:10b6:8:134::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Thu, 3 Oct 2024 20:01:46 +0000 Received: from CH2PEPF00000142.namprd02.prod.outlook.com (2603:10b6:610:e5:cafe::5) by CH0PR03CA0243.outlook.office365.com (2603:10b6:610:e5::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:01:46 +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 CH2PEPF00000142.mail.protection.outlook.com (10.167.244.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:46 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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.39; Thu, 3 Oct 2024 15:01:41 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:41 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:41 -0500 From: Harry Wentland To: , CC: , Harry Wentland Subject: [PATCH v6 15/44] drm/vkms: Add kunit tests for linear and sRGB LUTs Date: Thu, 3 Oct 2024 16:00:57 -0400 Message-ID: <20241003200129.1732122-16-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB05.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000142:EE_|DS0PR12MB7559:EE_ X-MS-Office365-Filtering-Correlation-Id: f97ecc63-ee2d-4998-3fbe-08dce3e635b9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: CSE+B6COor4u8EPXYmFoySVlkouVM1wxDftklq38eyruvbFAuFcSyCziEJXKNKNvGo9nFjHC1CEsjsr/k8RUl9wygHe0DCbkBqPaJEDg138aVxbhd2eVfXc1ayx7Rt27wgVJTKHhskIM7DmfQRKROFNYEBQL0BqW56tTFY1svvSAUqV57+ALDj3QcSt8zH82B2OHA8ZoHYh+ungWPNtSxKigbNlyIPfkPfcGhwtNXdhBrzxjauCFFJz5aMEU2Uf3E1ydRwDkUInEkhU9CFdNgFxzXs5RCfI1DF2BuOvQwLzUDF75PLneQ/lGTh9JgcwHAfeX9GnDHAHoXyQoPW9HJcdpkKI9xN9AYJYknT6rNvDPrSV/Gw7FcH8fEFbbu9Mjtl6a5cVDP7gwRp32TkITkaQaLjVThBZya0h6rs2VrmfTEqx/fpHMrBH1x5UH9E4GW0LsgEjnU/wH8IXeuRneeGB1gRCu/Te2dCgLNKhk0tdvwa/3QEnGMMpImYhTini+p6vlZmyQbyUXux9OmET5axUwFFdWNeK18pw8QPo/dU6SZq1e2DhYiRBsV5dCKCAZrk0jXbYCVsJeh39CSLmFGNo77tBUCI4fQfg9ZmaNmf51kSAfF6NPJzXvgoJRuhLnWHzrzXpRIBHu7axAWgtZKBqepUkeVFBivfmLaVH2c2cJQyTAWJZea5G376dW6/4UYbc1ocKw8juemHZHl11QtwWFTJFHhnaBhyMKJoACDA2HD4F2i+CGkC2mbUSTAd7SU/XWre1wGZ8O7h+WCmDnH08PifWC2u76aQJMhsXxzhzgeqpeoIgVpqc3cgupr8uIUGs+TL1lGTgPYKdcWqLoVOI3WEhcfDkcN2/ROmGBzWMo8bY9x0DhLPPOI2P+IECDVFXQS4MdSLXe2jXdC6dwWsSM2ED+DIVakvqtPEsZRWsDKzDOXeCMsasSwnHjHFPEWVDWxmHdkIntGgSWqCh3SWLHvVVxLJu0BXXm6IFBYJp5XWyvWPvoODC8EYe0jvpep2cNcpJN66Rqxz9gHf5CdIb9qAlyxYZ4s7YF7RXxubjNiYxmqJSDg/d7KD+xVw9vdod5oi8Q9k9L8v6Jwey37Ykkijv3zZopUC81KtY3VjQ2KMtL0VxF1yiz0MwhKmPXMxGyt0D3rdEs9+lgd1o9ak7k5CqWd2UDq7iyqbncPMrCqJWseAoV0hzRPY+ElQ/4gV6QMdeFCREnIWufcdSLmmIGkmnShFpsVjD6vuyAV2sOl/P73w7ieLuJYG5VZjpToh4g5mMXuNpJKCi/iRp2Fqggnk3BKIon9UFkUBkzjyTmUDfT4DF/S9hwf5dUwjqDK2fBP1vpbEnr2zc7vkHxjEqQUEq3hMd/Dgh6cTJ7wl832aXlFBBLD4H1sfh4DYo0 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:(13230040)(376014)(36860700013)(1800799024)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:46.1677 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f97ecc63-ee2d-4998-3fbe-08dce3e635b9 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: CH2PEPF00000142.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7559 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" Signed-off-by: Harry Wentland Reviewed-by: Louis Chauvet --- drivers/gpu/drm/vkms/tests/vkms_color_test.c | 38 +++++++++++++++++++- drivers/gpu/drm/vkms/vkms_composer.c | 15 ++------ drivers/gpu/drm/vkms/vkms_composer.h | 13 +++++++ 3 files changed, 53 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/vkms/tests/vkms_color_test.c b/drivers/gpu/drm/vkms/tests/vkms_color_test.c index efe139978860..c36e67c7909e 100644 --- a/drivers/gpu/drm/vkms/tests/vkms_color_test.c +++ b/drivers/gpu/drm/vkms/tests/vkms_color_test.c @@ -6,6 +6,7 @@ #include #include "../vkms_drv.h" #include "../vkms_composer.h" +#include "../vkms_luts.h" #define TEST_LUT_SIZE 16 @@ -36,7 +37,6 @@ const struct vkms_color_lut test_linear_lut = { .channel_value2index_ratio = 0xf000fll }; - static void vkms_color_test_get_lut_index(struct kunit *test) { int i; @@ -45,6 +45,19 @@ static void vkms_color_test_get_lut_index(struct kunit *test) for (i = 0; i < TEST_LUT_SIZE; i++) KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&test_linear_lut, test_linear_array[i].red)), i); + + KUNIT_EXPECT_EQ(test, drm_fixp2int(get_lut_index(&srgb_eotf, 0x0)), 0x0); + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_eotf, 0x0)), 0x0); + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_eotf, 0x101)), 0x1); + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_eotf, 0x202)), 0x2); + + KUNIT_EXPECT_EQ(test, drm_fixp2int(get_lut_index(&srgb_inv_eotf, 0x0)), 0x0); + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_inv_eotf, 0x0)), 0x0); + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_inv_eotf, 0x101)), 0x1); + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_inv_eotf, 0x202)), 0x2); + + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_eotf, 0xfefe)), 0xfe); + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_eotf, 0xffff)), 0xff); } static void vkms_color_test_lerp(struct kunit *test) @@ -153,9 +166,32 @@ static void vkms_color_test_lerp(struct kunit *test) KUNIT_EXPECT_EQ(test, lerp_u16(0x0, 0x1, 0x80000000), 0x1); } +static void vkms_color_test_linear(struct kunit *test) +{ + for (int i = 0; i < LUT_SIZE; i++) { + int linear = apply_lut_to_channel_value(&linear_eotf, i * 0x101, LUT_RED); + KUNIT_EXPECT_EQ(test, DIV_ROUND_CLOSEST(linear, 0x101), i); + } +} + +static void vkms_color_srgb_inv_srgb(struct kunit *test) +{ + u16 srgb, final; + + for (int i = 0; i < LUT_SIZE; i++) { + srgb = apply_lut_to_channel_value(&srgb_eotf, i * 0x101, LUT_RED); + final = apply_lut_to_channel_value(&srgb_inv_eotf, srgb, LUT_RED); + + KUNIT_EXPECT_GE(test, final / 0x101, i-1); + KUNIT_EXPECT_LE(test, final / 0x101, i+1); + } +} + static struct kunit_case vkms_color_test_cases[] = { KUNIT_CASE(vkms_color_test_get_lut_index), KUNIT_CASE(vkms_color_test_lerp), + KUNIT_CASE(vkms_color_test_linear), + KUNIT_CASE(vkms_color_srgb_inv_srgb), {} }; diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index a35466e68237..b4aaad2bf45f 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -113,18 +113,7 @@ VISIBLE_IF_KUNIT s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel } EXPORT_SYMBOL_IF_KUNIT(get_lut_index); -/* - * This enum is related to the positions of the variables inside - * `struct drm_color_lut`, so the order of both needs to be the same. - */ -enum lut_channel { - LUT_RED = 0, - LUT_GREEN, - LUT_BLUE, - LUT_RESERVED -}; - -static u16 apply_lut_to_channel_value(const struct vkms_color_lut *lut, u16 channel_value, +VISIBLE_IF_KUNIT u16 apply_lut_to_channel_value(const struct vkms_color_lut *lut, u16 channel_value, enum lut_channel channel) { s64 lut_index = get_lut_index(lut, channel_value); @@ -150,6 +139,8 @@ static u16 apply_lut_to_channel_value(const struct vkms_color_lut *lut, u16 chan return lerp_u16(floor_channel_value, ceil_channel_value, lut_index & DRM_FIXED_DECIMAL_MASK); } +EXPORT_SYMBOL_IF_KUNIT(apply_lut_to_channel_value); + static void apply_lut(const struct vkms_crtc_state *crtc_state, struct line_buffer *output_buffer) { diff --git a/drivers/gpu/drm/vkms/vkms_composer.h b/drivers/gpu/drm/vkms/vkms_composer.h index 9316a053e7d7..67ae09913460 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.h +++ b/drivers/gpu/drm/vkms/vkms_composer.h @@ -5,9 +5,22 @@ #include +/* + * This enum is related to the positions of the variables inside + * `struct drm_color_lut`, so the order of both needs to be the same. + */ +enum lut_channel { + LUT_RED = 0, + LUT_GREEN, + LUT_BLUE, + LUT_RESERVED +}; + #if IS_ENABLED(CONFIG_KUNIT) u16 lerp_u16(u16 a, u16 b, s64 t); s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel_value); +u16 apply_lut_to_channel_value(const struct vkms_color_lut *lut, u16 channel_value, + enum lut_channel channel); #endif #endif /* _VKMS_COMPOSER_H_ */ From patchwork Thu Oct 3 20:00:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821503 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 1A0BACF34C3 for ; Thu, 3 Oct 2024 20:02:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 98C2F10E90D; Thu, 3 Oct 2024 20:01:49 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="WIn1ma+1"; dkim-atps=neutral Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2079.outbound.protection.outlook.com [40.107.223.79]) by gabe.freedesktop.org (Postfix) with ESMTPS id AC93F10E926; Thu, 3 Oct 2024 20:01:48 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=J7LiLUOBJf4254YcYJjPSj87ms2oPdUE/dBqieo/J+nbEoVKGvpU0dn0NSvORIJ/xdB5eZthg70NCJ8lf7ncGuKXhQJbfnp2kclLBLJCMJqBGU/HDfS54tFCWF5mp2lG7suRfOx88+147OnnndQh8suMMf4wYPKpSv4AY26Fc4byIiUxXytzOZDcB/8Z52Mvx/rfpaXof1eTEZ+5RrAqE10pj3iyjAw1lJe5O4fopEbcgI7PTxiAtqw6GUnqqj1nEsTgZF0s8b6UFtRJZrdOL3zLXLoYEVBz1agcmlniJV6Hm1fB0GXxDmIIapjraiVvU8jCjG2WuCG8/9UjTxSecw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=LM9COioS+jk5xCSfeg/XvtNzNkQ1CrWMeHhNWPN+39M=; b=EHyPDXb3Wy9YxXfENNFnshr8kr3mtbyifN9/eXN0J5eNkEW57MpR5OVAXA9xbNaTPfrWSBIG9djiLjUUR/G7Zwm9+zSjXV+yk4ZC3ZNwk8teTiONLwGHRZc1BI9aGLPEEfnpURu6aKTIBygJxCZv2+bmoOjxvMdHZJcZi064vYC494mORCQRYa9YS8uiSeUKE6H3IzeHKI+vg+464o8ZwpVlibSlK6HQ4YNFNfQ36Uos71VjqQqCwfRX9IKpGEmQPsBAOzFqXgCXhSCZzEDjYqw2b1/bzgqp0197RE65x7j7AoEiwBDA26LC1BTdo2cAAUivqgC+kX7JnvYwJVgx6A== 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=LM9COioS+jk5xCSfeg/XvtNzNkQ1CrWMeHhNWPN+39M=; b=WIn1ma+1MHEv0vlE3Se2lV2k9JBYbvcl3MQvnagXpAwajOqeHGXl5CJKI3oUNitdGGS4GO5CJ5QHGBAdhCcDdeK0FiWKwTg5ziCG2yOxVAIeYISxVs/W/oTcS/efqRPSa9hcZL23AN1cz2wi91x13wc85FnKlhfTnWiUON3brVY= Received: from CH2PR14CA0032.namprd14.prod.outlook.com (2603:10b6:610:56::12) by SN7PR12MB7883.namprd12.prod.outlook.com (2603:10b6:806:32b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Thu, 3 Oct 2024 20:01:44 +0000 Received: from DS2PEPF0000343E.namprd02.prod.outlook.com (2603:10b6:610:56:cafe::e9) by CH2PR14CA0032.outlook.office365.com (2603:10b6:610:56::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:01:44 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS2PEPF0000343E.mail.protection.outlook.com (10.167.18.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:43 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:41 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:41 -0500 From: Harry Wentland To: , CC: , Harry Wentland Subject: [PATCH v6 16/44] drm/colorop: Introduce DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE Date: Thu, 3 Oct 2024 16:00:58 -0400 Message-ID: <20241003200129.1732122-17-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343E:EE_|SN7PR12MB7883:EE_ X-MS-Office365-Filtering-Correlation-Id: acfaedce-fd4b-4fe3-d033-08dce3e63454 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: DoDrfNAJvGnzws9Gcu1Vy7l47i+SBNEWywK2BkIw8snx4n/LOMaH6r0HVnwDXavdwoxfjrhIeq0r2PkJVaOIxsTm3IW1EGAgLBAh7jGhL+fAWWY+dzh5PoT5Uo811nHt5oN5uoz/5IR4Ac+7iYo76I2+0s0IigcokYfIjrXY2iiEjyKoJyU+G3ZIZletn0D7eXXxunc+kIKk9+zQGcVeKyipn6cHOfdgtllePdLc8qBxetbBP5RwajsQF7QHqzRxE74T1Ma0R+QxyFuqc0CNv8wzTtJdyoXRTqkjBgTI0nMlKMI2kp57cT4ZzpoOg4IUgXkjooAAZICoxeGM8zXDjvbrMPMHQF86TGIQMntL3SpX/GF5SVo7Ye+2Hx/KHVFbYbWg/0zwoi2hA2Kngol0DUiQg4eQqeAGzavPxD9+7ub4gA1nwY5T6K5O5h4UlqUKNql1QdILJl0aNEZiWnH69ilGKbenPYDEcrxPgwcOC7mli2nn1k/pTUCqzC8Uy+x6qyCWmS4TZXIJYA9Q2s0l/uxOjt5/ViVm0X7RT3235+ybdLNUHRyHPKhho7mWxjHISVSVVl/Zm/K2KjQJR+wYATqOBZ2Z3C2+yzAQceHaKnhyy8FYGkvyUXDgo0EOVJVr4Zr2fbu/sFoFp5m1hXc4O4pvJU3w2fF0Gf2biSURiGpghCQ/Ynb+2SPR8iw/GYzw7OTE2jLv8FONi/1mx3FitOpAu/qaTKKwwy7A3lBzXaLDGsx4YkO506uw16BPukVAzmj2tS/VeFuYL2INJCfAtOdqP1uyHP6Fq/i4AgKEw4tp8+i08iGcLXeU2RIEQcqGPA3pzuYIidhyxnEx+4PaijYDfYOv5ZeREPRuyf2FcytcNNmEvdp3/wrupkVa3ic83GTB/DjlJrZDW4u0N4eJZVyWKmeapoJbqkmo3ovBQEzct+762didBub+/d/HgbWqDWxDGP10xkY7iCuoP65Ky/PaWFVqLtH2tn3XjMnb/AQ2awlly4Y3WNPxO9P1/rPOtSZ4uNgjVdZmc37mz+DsC7n9dZVOYNtgGKZNrgpcQAdUdrDXq5RSOi9kHuk+MJ1t0seBgMZjAp9DN+wz2z3EM7xkvNvNdVaU8s5xr7rkOUcpBbtF4aZO695uY+WSHaUKLNAsJXR+FH0gmTDqzVlp3t5/2e6ZAVCmuT7BwHStrsmZnlffGL0ZKoFSJQIW4W/law97p7Yn8osAA/U7cVxxVyWt1q3tc9WAa4r/1d6O8dgc8fuNkq0wcBvxSPqCw7wK73OuvZQqOeVn8iTHpaBCHBkj6vWlUm0bHLfPzkzhs5gHwQ9xYJ9asMzqsPrVR+ZZ2taaBTiT6FeA7srwYOPzRmS4H+Wwus3U2/BINuikDjJjzoKceHYzgebkVdDWdoP+ X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(36860700013)(1800799024)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:43.8474 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: acfaedce-fd4b-4fe3-d033-08dce3e63454 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF0000343E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7883 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" With the introduction of the pre-blending color pipeline we can no longer have color operations that don't have a clear position in the color pipeline. We deprecate all existing plane properties. For upstream drivers those are: - COLOR_ENCODING - COLOR_RANGE Drivers are expected to ignore these properties when programming the HW. Setting of the COLOR_PIPELINE plane property or drm_colorop properties is only allowed for userspace that sets this client cap. Signed-off-by: Harry Wentland --- v5: - Fix kernel docs v4: - Don't block setting of COLOR_RANGE and COLOR_ENCODING when client cap is set drivers/gpu/drm/drm_atomic_uapi.c | 13 ++++++++++++- drivers/gpu/drm/drm_ioctl.c | 7 +++++++ include/drm/drm_file.h | 7 +++++++ include/uapi/drm/drm.h | 16 ++++++++++++++++ 4 files changed, 42 insertions(+), 1 deletion(-) -- 2.46.2 diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index c927aa65d286..a9a95431c31f 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -570,6 +570,12 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane, } else if (property == plane->color_range_property) { state->color_range = val; } else if (property == plane->color_pipeline_property) { + if (!file_priv->plane_color_pipeline) { + drm_dbg_atomic(dev, + "Setting COLOR_PIPELINE plane property not permitted unless DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE is set\n"); + return -EINVAL; + } + /* find DRM colorop object */ struct drm_colorop *colorop = NULL; colorop = drm_colorop_find(dev, file_priv, val); @@ -1179,6 +1185,12 @@ int drm_atomic_set_property(struct drm_atomic_state *state, break; } case DRM_MODE_OBJECT_COLOROP: { + if (!file_priv->plane_color_pipeline) { + drm_dbg_atomic(prop->dev, + "[OBJECT:%d] is a colorop but DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE not set\n", + obj->id); + ret = -EINVAL; + } struct drm_colorop *colorop = obj_to_colorop(obj); struct drm_colorop_state *colorop_state; @@ -1191,7 +1203,6 @@ int drm_atomic_set_property(struct drm_atomic_state *state, ret = drm_atomic_colorop_set_property(colorop, colorop_state, file_priv, prop, prop_value); - break; } default: diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index 51f39912866f..6b5021b68e35 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -373,6 +373,13 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv) return -EINVAL; file_priv->supports_virtualized_cursor_plane = req->value; break; + case DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE: + if (!file_priv->atomic) + return -EINVAL; + if (req->value > 1) + return -EINVAL; + file_priv->plane_color_pipeline = req->value; + break; default: return -EINVAL; } diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h index 8c0030c77308..6d9a1578c7dc 100644 --- a/include/drm/drm_file.h +++ b/include/drm/drm_file.h @@ -206,6 +206,13 @@ struct drm_file { */ bool writeback_connectors; + /** + * @plane_color_pipeline: + * + * True if client understands plane color pipelines + */ + bool plane_color_pipeline; + /** * @was_master: * diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h index 16122819edfe..a2fc85ecdea1 100644 --- a/include/uapi/drm/drm.h +++ b/include/uapi/drm/drm.h @@ -875,6 +875,22 @@ struct drm_get_cap { */ #define DRM_CLIENT_CAP_CURSOR_PLANE_HOTSPOT 6 +/** + * DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE + * + * If set to 1 the DRM core will allow setting the COLOR_PIPELINE + * property on a &drm_plane, as well as drm_colorop properties. + * + * Drivers will ignore these drm_plane properties: + * - COLOR_ENCODING + * - COLOR_RANGE + * + * The client must enable &DRM_CLIENT_CAP_ATOMIC first. + * + * This capability is currently in development. + */ +#define DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE 7 + /* DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */ struct drm_set_client_cap { __u64 capability; From patchwork Thu Oct 3 20:00:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821508 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 F32DFCF34C1 for ; Thu, 3 Oct 2024 20:02:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D989C10E93F; Thu, 3 Oct 2024 20:01:51 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="AR4tYd/R"; dkim-atps=neutral Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2073.outbound.protection.outlook.com [40.107.93.73]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9E53810E90E; Thu, 3 Oct 2024 20:01:49 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PcKPhT9PkOufEmD5btZZzDtigVVsiDnSsoBw91fZUNqy+sTglekb7oI+gacwZNTIPkvMK1QTT7j6oMqAJ25HaNte1iEqcBR4kaQWyypEra2jFO0q13jpBzc7S8fcCNA0l5r3KIBrbaxYM7G/ywZMf9kGqH9F890sw56v0HYK8Sc4qdU1T5U4lt+7D+ckvXyMXo56D3vJ5+M40zKRAoeSD/Lp9kuwQGoBwbkSy5MU9l7YCI2tZ3JTCn4/Daibe2Tss+MBxTWnjuiZ1QajILsGbhnBg8cd+up9HWWO98F+mTDs8UWUkU1e9ghdt9IY4rl18OWsSrc1zhPBwmt2+3968A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=pbRvHvFxktLcNpDBArcaqW0Wy6jB9hssMZEFYtK41UY=; b=k7MNHBdt8oVeIemdBEO2K+pMRmizMFF5YP5KFRP3paIh2DuVFbKcTX8pdHcQNB9Q+6whp2BrK3mXNyg2AhhC3rdNj4L5bmZgQzV9LeL4PPY8zQGp+BzvYrDaMzvl0ym/9pLWr+q7OBHggAh/qlVRQmBqtHzLM4UFOp7DrD6b0MjLBWJihjUDuCr4DBU1LPlCoqZmxFZsFsN+fltf3LQb7AOb3+91gtDBeyMwnfgCP/PwqRpb9CZcAOViNrJJ8bR2scEOZprXcH+74BWmCu76snNXG2seNrF85LtKXG/diU2llmYbUxGecw8+uDGW1fMAy5zacrRkyKMItECN52gvPQ== 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=pbRvHvFxktLcNpDBArcaqW0Wy6jB9hssMZEFYtK41UY=; b=AR4tYd/RxVKcbQSD2Ukep3l4bTZ8Q3O9Qdy6SBgWIQshz/Nq8c68crfOu1b5XgYogSjUlzVmXstHBArRDdQfRFYprW1DFf9wFJYnf7Wj+6vMzpoavK74WN4CpAw+Ja/YbNTTZl6FMvzG4C0gGo8J58dIXsDz6PVEcJGFFxv25l4= Received: from CH2PR14CA0040.namprd14.prod.outlook.com (2603:10b6:610:56::20) by CY8PR12MB7706.namprd12.prod.outlook.com (2603:10b6:930:85::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.15; Thu, 3 Oct 2024 20:01:45 +0000 Received: from DS2PEPF0000343E.namprd02.prod.outlook.com (2603:10b6:610:56:cafe::94) by CH2PR14CA0040.outlook.office365.com (2603:10b6:610:56::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:01:44 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS2PEPF0000343E.mail.protection.outlook.com (10.167.18.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:44 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:42 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:42 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:42 -0500 From: Harry Wentland To: , CC: , Harry Wentland Subject: [PATCH v6 17/44] drm/colorop: Add 3x4 CTM type Date: Thu, 3 Oct 2024 16:00:59 -0400 Message-ID: <20241003200129.1732122-18-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343E:EE_|CY8PR12MB7706:EE_ X-MS-Office365-Filtering-Correlation-Id: aca8de4f-b3ff-4de3-18a6-08dce3e634df X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: ZfWdzHhXk9vg/U7JZii8sLmIHciW8Y3ZLCYtpWt2kPyHax2dM/eSlnCk/tSsNNkphmZQr7NYLfosB1PSBMFvvvt2O60mye5DqvmCST1/9LazhxhLWwbn3MkHy0Ldj8cymW/mMhaKOGqc4F22vmQVcbTpEALN29BVkhg9jMN4SnOUQtpd9EDnVpfgEWdI2w9Qh8RTk7JZA1DOsE26qdB4CwQhoy95vRTHFndo5VT118C+p+HVqPn3QNV9L5ppMtU31ZPeLc39riuZp3ib/PFtZ0PnSewoSTrB/4HR7TLRQ6kKz/S4em1ORe0cihceu3xnjmq3nOvPMs5/g+cqgV+LG/tLR9yz0TN+59Rg2GvituiQpmrSMPLC6a8Xt6z/y62fq3RRE4FILxcVapYWyAbcN3R0xelexLs5N1Iw+fahyVMaEuM2gwdP/4zL9nNAQItlPUHIxgNa889nBQ4DwnbrizHYsQYzEr3hRiMyw4/3ZfaGZPUUnRHE7cXE+E1CQ4hG7IP3pcGdKSU7bnu1/DqeEpUqG7kCbpUp1ZYxpHJfyFD5OJB0XA/vW1AA+a8MGRijWS3dwcsJ0veYfuDwbypfZcWOgVTJ6HFG4LP+P6L7BggNP0fbsXcCRmROQg+YWbs0KLUWu9kk3NfbfeoteLoC7Bfq5OlkqfQGq3i7XRvdXSOUEKx0a32Ir4ZtqL05NlLNpdMz357fTORVwOSw8nt+7dHd9VaWTGfrpxQLzix4+v7NPcPkf0GN1G0xj2o5KoiGABIay+lQNlH5GVDXMMvz7nv+49RRjwnDj5wqeS+bPEMtvdLCOx4CtTkuFDL/0NcnGIUf+V45SKcEOv+Kqz8oWut9/HyX/1Nhhs41JMBIVe0kxZ884ie0UyzhBjubrhBwwjVDds9AEda6h/KuOJvT3KfWS2/VL/JkGUP6V0WqDSb9xvihkf5oMJ66W56jzS8Vy8ime05rEjSlqQKKf1UGh6QBZeR7DpRIP/gAB2Co49JRGCRHXSkNwp61a+Uu1ZJNX+6q9HUBmvU1M3arBK9kjCl6FBoWXiGS1k+HGhytf1gtYA6di/zv68mSBeLXuhAfH7AGBTlcytKL6N/AbnthwPKamLAZa2R13QPeFFEzwNaykEtZdClJYMHq8yIuzdor9xBPU8Jt+7mbU0drkSfow2p3IcX9Ak8fJH91B5OOlZB6VStaeusVZRREiCdYw3wezqShBjzC566AGBQ+6chMb8mWxCO4mzKZkHh1XA8qI1t4uH/Si7Ndwcswvxm1bctq7DoctYVcXVlPdVbrGy4YxOTsDEwRbHTZQAVUN74hTg5H1A2zyRPUWWGs3/ojT3jdCWa/OxEiDiBSuZf4RTKAuiq57NJGE+dN6Io8Y2aLZ7J/WfcOzsZMvf8iCD0L0B54 X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(36860700013)(376014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:44.7537 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aca8de4f-b3ff-4de3-18a6-08dce3e634df 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF0000343E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7706 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" This type is used to support a 3x4 matrix in colorops. A 3x4 matrix uses the last column as a "bias" column. Some HW exposes support for 3x4. The calculation looks like: out matrix in |R| |0 1 2 3 | | R | |G| = |4 5 6 7 | x | G | |B| |8 9 10 11| | B | |1.0| This is also the first colorop where we need a blob property to program the property. For that we'll introduce a new DATA property that can be used by all colorop TYPEs requiring a blob. The way a DATA blob is read depends on the TYPE of the colorop. We only create the DATA property for property types that need it. Signed-off-by: Harry Wentland --- v6: - take ref for DATA blob in duplicate_state func (Xaver Hugl) v5: - Add function signature for init (Sebastian) - Fix kernel-doc v4: - Create helper function for creating 3x4 CTM colorop - Fix CTM indexes in comment (Pekka) drivers/gpu/drm/drm_atomic.c | 14 ++++++++++- drivers/gpu/drm/drm_atomic_uapi.c | 29 +++++++++++++++++++++ drivers/gpu/drm/drm_colorop.c | 42 +++++++++++++++++++++++++++++++ include/drm/drm_colorop.h | 21 ++++++++++++++++ include/uapi/drm/amdgpu_drm.h | 9 ------- include/uapi/drm/drm_mode.h | 24 +++++++++++++++++- 6 files changed, 128 insertions(+), 11 deletions(-) -- 2.46.2 diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 35136987d5e8..c58663327e6b 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -787,7 +787,19 @@ static void drm_atomic_colorop_print_state(struct drm_printer *p, drm_printf(p, "colorop[%u]:\n", colorop->base.id); drm_printf(p, "\ttype=%s\n", drm_get_colorop_type_name(colorop->type)); drm_printf(p, "\tbypass=%u\n", state->bypass); - drm_printf(p, "\tcurve_1d_type=%s\n", drm_get_colorop_curve_1d_type_name(state->curve_1d_type)); + + switch (colorop->type) { + case DRM_COLOROP_1D_CURVE: + drm_printf(p, "\tcurve_1d_type=%s\n", + drm_get_colorop_curve_1d_type_name(state->curve_1d_type)); + break; + case DRM_COLOROP_CTM_3X4: + drm_printf(p, "\tdata blob id=%d\n", state->data ? state->data->base.id : 0); + break; + default: + break; + } + drm_printf(p, "\tnext=%d\n", colorop->next ? colorop->next->base.id : 0); } diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index a9a95431c31f..12d9d18c1c78 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -691,6 +691,30 @@ drm_atomic_plane_get_property(struct drm_plane *plane, return 0; } +static int drm_atomic_color_set_data_property(struct drm_colorop *colorop, + struct drm_colorop_state *state, + struct drm_property *property, uint64_t val) +{ + ssize_t elem_size = -1; + ssize_t size = -1; + bool replaced = false; + + switch (colorop->type) { + case DRM_COLOROP_CTM_3X4: + size = sizeof(struct drm_color_ctm_3x4); + break; + default: + /* should never get here */ + return -EINVAL; + } + + return drm_property_replace_blob_from_id(colorop->dev, + &state->data, + val, + size, + elem_size, + &replaced); +} static int drm_atomic_colorop_set_property(struct drm_colorop *colorop, struct drm_colorop_state *state, struct drm_file *file_priv, @@ -700,6 +724,9 @@ static int drm_atomic_colorop_set_property(struct drm_colorop *colorop, state->bypass = val; } else if (property == colorop->curve_1d_type_property) { state->curve_1d_type = val; + } else if (property == colorop->data_property) { + return drm_atomic_color_set_data_property(colorop, + state, property, val); } else { drm_dbg_atomic(colorop->dev, "[COLOROP:%d:%d] unknown property [PROP:%d:%s]]\n", @@ -722,6 +749,8 @@ drm_atomic_colorop_get_property(struct drm_colorop *colorop, *val = state->bypass; } else if (property == colorop->curve_1d_type_property) { *val = state->curve_1d_type; + } else if (property == colorop->data_property) { + *val = (state->data) ? state->data->base.id : 0; } else { return -EINVAL; } diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c index 685dd18126aa..a995a0e25a34 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -63,6 +63,7 @@ static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { { DRM_COLOROP_1D_CURVE, "1D Curve" }, + { DRM_COLOROP_CTM_3X4, "3x4 Matrix"} }; static const char * const colorop_curve_1d_type_names[] = { @@ -201,11 +202,51 @@ int drm_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *coloro } EXPORT_SYMBOL(drm_colorop_curve_1d_init); +static int drm_colorop_create_data_prop(struct drm_device *dev, struct drm_colorop *colorop) +{ + struct drm_property *prop; + + /* data */ + prop = drm_property_create(dev, DRM_MODE_PROP_ATOMIC | DRM_MODE_PROP_BLOB, + "DATA", 0); + if (!prop) + return -ENOMEM; + + colorop->data_property = prop; + drm_object_attach_property(&colorop->base, + colorop->data_property, + 0); + + return 0; +} + +int drm_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop, + struct drm_plane *plane) +{ + int ret; + + ret = drm_colorop_init(dev, colorop, plane, DRM_COLOROP_CTM_3X4); + if (ret) + return ret; + + ret = drm_colorop_create_data_prop(dev, colorop); + if (ret) + return ret; + + drm_colorop_reset(colorop); + + return 0; +} +EXPORT_SYMBOL(drm_colorop_ctm_3x4_init); + static void __drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop, struct drm_colorop_state *state) { memcpy(state, colorop->state, sizeof(*state)); + if (state->data) + drm_property_blob_get(state->data); + state->bypass = true; } @@ -287,6 +328,7 @@ void drm_colorop_reset(struct drm_colorop *colorop) static const char * const colorop_type_name[] = { [DRM_COLOROP_1D_CURVE] = "1D Curve", + [DRM_COLOROP_CTM_3X4] = "3x4 Matrix" }; const char *drm_get_colorop_type_name(enum drm_colorop_type type) diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h index 9721f90bdf90..edad9c579781 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -95,6 +95,14 @@ struct drm_colorop_state { */ enum drm_colorop_curve_1d_type curve_1d_type; + /** + * @data: + * + * Data blob for any TYPE that requires such a blob. The + * interpretation of the blob is TYPE-specific. + */ + struct drm_property_blob *data; + /** @state: backpointer to global drm_atomic_state */ struct drm_atomic_state *state; }; @@ -199,6 +207,17 @@ struct drm_colorop { */ struct drm_property *curve_1d_type_property; + /** + * @data_property: + * + * blob property for any TYPE that requires a blob of data, + * such as 1DLUT, CTM, 3DLUT, etc. + * + * The way this blob is interpreted depends on the TYPE of + * this + */ + struct drm_property *data_property; + /** * @next_property: * @@ -234,6 +253,8 @@ static inline struct drm_colorop *drm_colorop_find(struct drm_device *dev, int drm_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop, struct drm_plane *plane, u64 supported_tfs); +int drm_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop, + struct drm_plane *plane); struct drm_colorop_state * drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop); diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h index efe5de6ce208..e44362e74fa1 100644 --- a/include/uapi/drm/amdgpu_drm.h +++ b/include/uapi/drm/amdgpu_drm.h @@ -1283,15 +1283,6 @@ struct drm_amdgpu_info_gpuvm_fault { #define AMDGPU_FAMILY_GC_11_5_0 150 /* GC 11.5.0 */ #define AMDGPU_FAMILY_GC_12_0_0 152 /* GC 12.0.0 */ -/* FIXME wrong namespace! */ -struct drm_color_ctm_3x4 { - /* - * Conversion matrix with 3x4 dimensions in S31.32 sign-magnitude - * (not two's complement!) format. - */ - __u64 matrix[12]; -}; - #if defined(__cplusplus) } #endif diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index 53985d2b7eea..6fc1ce24800a 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -847,6 +847,20 @@ struct drm_color_ctm { __u64 matrix[9]; }; +struct drm_color_ctm_3x4 { + /* + * Conversion matrix with 3x4 dimensions in S31.32 sign-magnitude + * (not two's complement!) format. + * + * out matrix in + * |R| |0 1 2 3 | | R | + * |G| = |4 5 6 7 | x | G | + * |B| |8 9 10 11| | B | + * |1.0| + */ + __u64 matrix[12]; +}; + struct drm_color_lut { /* * Values are mapped linearly to 0.0 - 1.0 range, with 0x0 == 0.0 and @@ -872,7 +886,15 @@ enum drm_colorop_type { * A 1D curve that is being applied to all color channels. The * curve is specified via the CURVE_1D_TYPE colorop property. */ - DRM_COLOROP_1D_CURVE + DRM_COLOROP_1D_CURVE, + + /** + * @DRM_COLOROP_CTM_3X4: + * + * A 3x4 matrix. Its values are specified via the + * &drm_color_ctm_3x4 struct provided via the DATA property. + */ + DRM_COLOROP_CTM_3X4, }; /** From patchwork Thu Oct 3 20:01:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821516 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 701D1CF34C3 for ; Thu, 3 Oct 2024 20:02:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C140A10E93B; Thu, 3 Oct 2024 20:01:56 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="KLavWVHT"; dkim-atps=neutral Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2063.outbound.protection.outlook.com [40.107.94.63]) by gabe.freedesktop.org (Postfix) with ESMTPS id 60B6210E930; Thu, 3 Oct 2024 20:01:51 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=R/hCp7GfJrm/UztsSSJbDo+o3dUrFJorAeLuE83JqfggHt58xECgmBWekUrCbdQJcNI4SD5dbjXVJe1mH/vQ0vf4G0coABJpWUFGpymBF7pq7vDxqcl3gVHnYMxxSpjVf1kilwyPWupVmYb0B43T2aTN6dBTF5aBtOCg2MjN89Q6doNKn9DoY7f+j2axZPvnPivSo9zLZ72HouR8cGpk7Kpp7Wh98wtWASPs1gNfauKsRUFaIt1zIix4tqjlJ+pG5ClrqbDDMmiVeNzrLKeElZD04u/9xyEpuwi5L6IIa/zIQ6mvoY4ZhyLiCi1j2PQRQA4zoftIYo5vzlyrZT7WBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=I3Oi94OEyzmMnG+tOW1/cV6nuG7DLta95nx+JmMPGzY=; b=dsFoY/377WNE34/urpGJWE7ow9a++sFUU/bhhP9x+B3d7d1n6vXFi4N1Md8Wygi18gcztD2yVOL4nahUunLx1jU1jFFvLvyJXle94TBCioGBIyt+PYR1AHWtDdUKeuK36u9QZ6DmXW/+WPIrAriVJnwo4qcV1XDcBMFrOc6XKRE3fSxdJK6ZM0h4S0zdoEtP9N/5rwMM9+jvWJZG5Si8uIeSrAdntcSwaQWwNgOmwlzYVmLDsvrIVPd1DwGt2VMDEw5iZeCBYYW96pnPEk9vpKOGhHxkw79Hb/TJYZD7GPWIdaZMGU5jaYiEjoW4DGjmv4TMClrW6CYAIyO6YtBT8A== 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=I3Oi94OEyzmMnG+tOW1/cV6nuG7DLta95nx+JmMPGzY=; b=KLavWVHTHjQhMk7XRgkGDRFz8EB1KUTMq8AgB7syOSNfAlc6qyEEchDYcmsl5gtPK/QoJT3ble4J1i1uTdCX/5apECXX9480w3Cmvh98AdvH6qAXHsHULI+Jj0b528KUOCqNZ8nxuIpxPm7yPaPMzm0n5S8/pszxxXApmhTljhI= Received: from CH0PR03CA0257.namprd03.prod.outlook.com (2603:10b6:610:e5::22) by PH7PR12MB6761.namprd12.prod.outlook.com (2603:10b6:510:1ab::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Thu, 3 Oct 2024 20:01:45 +0000 Received: from CH2PEPF00000142.namprd02.prod.outlook.com (2603:10b6:610:e5:cafe::da) by CH0PR03CA0257.outlook.office365.com (2603:10b6:610:e5::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:01:45 +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 CH2PEPF00000142.mail.protection.outlook.com (10.167.244.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:45 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) 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.39; Thu, 3 Oct 2024 15:01:43 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:43 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:43 -0500 From: Harry Wentland To: , CC: , Harry Wentland Subject: [PATCH v6 18/44] drm/vkms: Use s32 for internal color pipeline precision Date: Thu, 3 Oct 2024 16:01:00 -0400 Message-ID: <20241003200129.1732122-19-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000142:EE_|PH7PR12MB6761:EE_ X-MS-Office365-Filtering-Correlation-Id: be0eda44-bc1d-466b-1dd1-08dce3e63536 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: Tgv5TBO7Nrmn4S4aAYBlA41k6sOXfeyj5mswpfua4oDnxmVKZ+ijfp4jG2qt9fsy11Wg0/EUA62sJpSHLgzIsTS1nWW9XVzt4dFP+zNaCVtmH8rZ3mRrXh3aLX4cNwrOHdqdzrYgNpQfqrtT75xxBhg9Ue3j7plCIEEwGJ+ob2a9lK0oahPn0Yj0Hw0G0iScumpcw54UfWxdxNEWb01YlS/IViFpYyAVoKCkIOKyTBDEmlVl5FDUo02/rTA+uBBkaQTTg3QK3gBynHvrTivn6BMEU5wsH4I5Owxel1L3gmXjSrF5zbtWYd3wL8xOQB/WOI+0lDEyOm7SU7izf5I7qsh1bzz+0NoAldChpFGF9I99daIXzeqqIunDR0zByCY5jqTKy/eJB+CW3RevhuffxeToiVsnSPuzW9heiwfDUF2Qmnvgj34TP4vHVTwus/ytbtskKD+GkrZGjC2TE4yzsimVh+Z6KGxbBXRIRf5c4kuKmEXHEXatSPhrj1tWYHU2X9B1q9SWwRcyJkvlDXp+zQDuclK8MwxsDcHe3joKBksMaxzL5VHPrVHcOjoIStLZWHKpXITBOS4HY64swY1dBj+8i7lmpNUiSCkXObtoDCzMdkyPJMp9NJ2hEHCbq8kYcN4RULQmzWnPq014vVOU0+zhkK/BT7gku6OapdkBVne94Kf1ZfyQ6M0JNUEwzDvxZLMJ5M5mN707xljpZ9a6sM5tyoR7vC4RNkqcnU1ZPIZya0qQBjoz/QpF/bdtbXcPuD1GJW2Jp9JAhVE1EJQKVnThnCYzV0110LTBjeT278NPt9xXdYRj5DTtxrspxDKq0lEazyWU1/ymr+LGLwxVRb0FDhCQVr/NCVp6AcDdNBqNBBmXcQesZrCH9xz7b7/iCqbcBTxQ2ZJdk03+d7g8uS0kxac0B8dpjUUMaOvFk661VzlqZ9fP2T3VdDqSGlGs4pwQKHSaRbKCAm2u0fzUiQnm9JJsaJnQM0kwWn+qrGSA2kaS+VZZ2mV74XVKFLIjkZ4DzeKlQKTotapRBp39eOgi7MIrOszuA2q3pDfv0awloVIS0RFlfC2s5do03vEmZy9jaTV2aqMGfR/enkdtpA7hyNxAzrpca2t7OMCPDexAz2zNxZcqLzG2r77C3L8nLUXkfEWDhrHNv+CJx6kU4YweLQhThY4Ffd9t0pATZSN4Dh2cvQH215qBeZz0i1J+V1xF6uk+hvNsA8NSFbv51JMm/3F4BHt0eQyjVoEMXPk/Zw9i5pPuWby2jmKF9doJL4zZBaUX1oQ7Sdmw+ZxGEH7A/qE7aOMfGjpe4GRccYkopTdXfGkPDh2hTmhEkvCvDe7PQvf+Vhj2C/1+YwCZJk6HtwjM9Sb8sOL3s00KAT0AG2JT6ZZbO9lvdsK9E6N4 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:(13230040)(376014)(36860700013)(1800799024)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:45.3552 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: be0eda44-bc1d-466b-1dd1-08dce3e63536 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: CH2PEPF00000142.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6761 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" Certain operations require us to preserve values below 0.0 and above 1.0 (0x0 and 0xffff respectively in 16 bpc unorm). One such operation is a BT709 encoding operation followed by its decoding operation, or the reverse. We'll use s32 values as intermediate in and outputs of our color operations, for the operations where it matters. For now this won't apply to LUT operations. We might want to update those to work on s32 as well, but it's unclear how that should work for unorm LUT definitions. We'll revisit that once we add LUT + CTM tests. In order to allow for this we'll also invert the nesting of our colorop processing loops. We now use the pixel iteration loop on the outside and the colorop iteration on the inside. Signed-off-by: Harry Wentland --- v6: - use clamp_val instead of manual clamping (Louis Chauvet) v4: - Clarify that we're packing 16-bit UNORM into s32, not converting values to a different representation (Pekka) v3: - Use new colorop->next pointer drivers/gpu/drm/vkms/vkms_composer.c | 27 +++++++++++++++++++++++++-- drivers/gpu/drm/vkms/vkms_drv.h | 4 ++++ 2 files changed, 29 insertions(+), 2 deletions(-) -- 2.46.2 diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index b4aaad2bf45f..01fa81ebc93b 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -159,7 +159,7 @@ static void apply_lut(const struct vkms_crtc_state *crtc_state, struct line_buff } } -static void apply_colorop(struct pixel_argb_u16 *pixel, struct drm_colorop *colorop) +static void apply_colorop(struct pixel_argb_s32 *pixel, struct drm_colorop *colorop) { struct drm_colorop_state *colorop_state = colorop->state; @@ -185,9 +185,26 @@ static void apply_colorop(struct pixel_argb_u16 *pixel, struct drm_colorop *colo static void pre_blend_color_transform(const struct vkms_plane_state *plane_state, struct line_buffer *output_buffer) { + struct pixel_argb_s32 pixel; + for (size_t x = 0; x < output_buffer->n_pixels; x++) { struct drm_colorop *colorop = plane_state->base.base.color_pipeline; + /* + * Some operations, such as applying a BT709 encoding matrix, + * followed by a decoding matrix, require that we preserve + * values above 1.0 and below 0.0 until the end of the pipeline. + * + * Pack the 16-bit UNORM values into s32 to give us head-room to + * avoid clipping until we're at the end of the pipeline. Clip + * intentionally at the end of the pipeline before packing + * UNORM values back into u16. + */ + pixel.a = output_buffer->pixels[x].a; + pixel.r = output_buffer->pixels[x].r; + pixel.g = output_buffer->pixels[x].g; + pixel.b = output_buffer->pixels[x].b; + while (colorop) { struct drm_colorop_state *colorop_state; @@ -197,10 +214,16 @@ static void pre_blend_color_transform(const struct vkms_plane_state *plane_state return; if (!colorop_state->bypass) - apply_colorop(&output_buffer->pixels[x], colorop); + apply_colorop(&pixel, colorop); colorop = colorop->next; } + + /* clamp values */ + output_buffer->pixels[x].a = clamp_val(pixel.a, 0, 0xffff); + output_buffer->pixels[x].r = clamp_val(pixel.r, 0, 0xffff); + output_buffer->pixels[x].g = clamp_val(pixel.g, 0, 0xffff); + output_buffer->pixels[x].b = clamp_val(pixel.b, 0, 0xffff); } } diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 278cf3533f58..b78bc2611746 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -36,6 +36,10 @@ struct vkms_frame_info { unsigned int cpp; }; +struct pixel_argb_s32 { + s32 a, r, g, b; +}; + struct pixel_argb_u16 { u16 a, r, g, b; }; From patchwork Thu Oct 3 20:01:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821509 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 0D0D0CF34C4 for ; Thu, 3 Oct 2024 20:02:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 598F110E943; Thu, 3 Oct 2024 20:01:52 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="FI1iapv4"; dkim-atps=neutral Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2087.outbound.protection.outlook.com [40.107.94.87]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2CC3710E933; Thu, 3 Oct 2024 20:01:50 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lN/TsqVytVffdIkqloKzlqQ2d+KRWXG9Mjeqc9/te/T8bU8zJ4CgzRAthfBHeMVYv1K3hPGOmsZNrjRHACtyIn50TslMZNzL/qYf/GGdBV5T98Y3zXest6x+krhKzxI3v8521ktRWS3zb/u/YFQmqhCCsDvc1Job3wrvuoDyjQpg9kL4sA4Ofyezm8BP81axrCTeJOedH1ERrkHXwj32E1wiozTXeZL4tahc7pzcuqtbKco2QpNkuz9sfN8yYZqy5MqsOCs2KYmcxUry1p7mMN1TW8KOk63+Nr+0kw3IujVkrI0vC/vjdZhNcID4wcMlulFLga1esK7yLJuEtT71ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=PG2JXaZ3XvmeDKM+maYaeJRK3XuAaGzpes4Ljpt+fhs=; b=Hih9wxlMWO+TabTrPJvMhwBut8Lwwyumpa+mFrJRHElcny9NSt4/TCq2A+ttJzgbcAnGhliH6uYPT/+udU55c68LMoMXDaT5yzhcn8iuHKXjw1/5EErhdqw+ZDBelqto7D5doeVMQFZkDz5KAk1I2huGU/CBBZ+lw3koCFOQgeSvJGn2/x+9J5MNGA8h5QRZyc7pUAB3IRnUw4H251pDDJh4nuNAvgCqRv6iO7X0r1oh8qHWap88eqoTaJrCIzZMyOOAJ+XkgJ1/M1BbYh6saLtp2pA9Y5lSHsn0cYmTyjcbaQpwrys63yJN+ZlvHLhXyJGHngQqcbaq+RWMSo1sqQ== 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=PG2JXaZ3XvmeDKM+maYaeJRK3XuAaGzpes4Ljpt+fhs=; b=FI1iapv4F0afjH2AwU1Zzas8G0AD3rE/6SBXa27ga6T3/P/CgoGu+3W1rMDQ5X3f9KQZcAnyPvdLwhBz7SB6Uy7mnj95+SvWuO4+6suLgnL4B24Vh03Ps5AG/r/WgeVacxmRtRvH/HuZM5cdYHdIdoVntTZ0hIh8a5paRuBknMo= Received: from CH2PR14CA0038.namprd14.prod.outlook.com (2603:10b6:610:56::18) by PH7PR12MB6492.namprd12.prod.outlook.com (2603:10b6:510:1f3::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.26; Thu, 3 Oct 2024 20:01:46 +0000 Received: from DS2PEPF0000343E.namprd02.prod.outlook.com (2603:10b6:610:56:cafe::7a) by CH2PR14CA0038.outlook.office365.com (2603:10b6:610:56::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:01:45 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS2PEPF0000343E.mail.protection.outlook.com (10.167.18.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:45 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:44 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:44 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:43 -0500 From: Harry Wentland To: , CC: , Harry Wentland Subject: [PATCH v6 19/44] drm/vkms: add 3x4 matrix in color pipeline Date: Thu, 3 Oct 2024 16:01:01 -0400 Message-ID: <20241003200129.1732122-20-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343E:EE_|PH7PR12MB6492:EE_ X-MS-Office365-Filtering-Correlation-Id: e4335768-296a-4ea5-b23b-08dce3e63539 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|82310400026|376014; X-Microsoft-Antispam-Message-Info: 2ctRcb1eY2HflNVf5KaV0tClPkuD611Z7JuuWfuwuaO7jNx6Q+JjVH/p39VSlvDrzWO4ABeHGC5e9/jbJsDqZTXxtvVA1jVCi8LCemEKcIOELLrAab2Ril2bzQA2gT+2KNPBJDrCqLt1/Tuo4M51VOtU4zFsJUKKh2+yh2pDvhbHkFuI4lITktpuNWbDG5TmooPwJiSdiqgjQnu8u6vSIzE29dEn7h7ne/NzpkjQEd/jNNaOtUNpYy/trXiXyhGGJvEWVkjff473fBEHUgPQExMQ2EaQV8Nljf9UqkDvo5YTLpHkf8j7GBuScoxX1cjf65te5KG4Dqi29qUvtSL3fXvbE7+cb7aZ5ppq7m5byju9kKbJPXlawDFQGgIEjQJFSAa8VGbiotmBmNnE2Ue5V6/joh93xH1Y9H6cpDxygj+5/IB4w0Ou4wa7RL1RBB8cuJNVgph581HF5jPGn2NoTlnN6xJnZ1BEJ2UxhGqY++SsMwX5FpxtAwnGlHMxpMmOwYcRTWigJSXgKqbti9DZlXh5vyVn0uvK5a5GDlO9B9pPStR5zyhkvRc4cjn3RAWbYhqRzmmV+Eq2B6DpmaMShRWsEQAiHpEE2wc8xdBYF6pCJOXthdRLNtEBEijAAB+247fJMnRI9Qi4VLFnhqo7srCWP7GbPnFoPeam85nTVVPmvQWYe2srrxPKnyE78BIbxZvmY1e1ow/WHcbyXBK+GSfOsdfWDA/3DHzk0CwtcdR2BBDhNsxRJlJb6OvGE6f5QZ7cjbp6bylxrKpEPxx4LoRu4XWlPSdyJ6R2+APhKp0nA0YiLaFmOHree+cjgokNGw5jfb5C5IWoLMcwtXt7/hAzOjoM+mUbEs7IfsBZofUqU+YOvUc+cqEmL2fC5yriT2NaxbMVTKWTeIwruftXVAbslyb1FOPALoZJc02a0267wjljt3AUo4P+AEoJp/PAeuFad8XYDy+b8qb10gLb9Ur5ioYvp07dMJvM6cQlmHUqCCgNC+ozcnHfo7QA4VrdteciIoY84ihluIk2Hvw3sPAlE2NvqiPHo/2muEStC2j0icVOp3O+xJVMrFhf2wsCarw/ikrpCZZOKCkLok0ySP209+EWhlNCzzaximpZoyWs2A6X8YnoJoyYyn0RxvKYOABMD4UMnk6G+ZkRzjJTC3PeDqYkpTmGAIoxvtmNs8ffE0KvLWZ8iySMyihiPROW413T7Zo8n/ht4hGFZ29CH68YgHMFWrRrxO5nVH1OYljaKECiR7RBT9trlpVIUAgjVL7piBjPFPScGtoniRTCGsY9dWVq/1x2/azimhCgII5z5hVgfIr0TA+V5y3oJBmHZpjc+g3w5VXYn5ZOB/c5IY5m2vJG62tyjO1umNXrU62+rVzkT3y4ZL/8zo60FGup X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(36860700013)(82310400026)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:45.3474 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e4335768-296a-4ea5-b23b-08dce3e63539 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF0000343E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6492 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" We add two 3x4 matrices into the VKMS color pipeline. The reason we're adding matrices is so that we can test that application of a matrix and its inverse yields an output equal to the input image. One complication with the matrix implementation has to do with the fact that the matrix entries are in signed-magnitude fixed point, whereas the drm_fixed.h implementation uses 2s-complement. The latter one is the one that we want for easy addition and subtraction, so we convert all entries to 2s-complement. Signed-off-by: Harry Wentland --- v6: - pre-compute colors (Louis Chauvet) - round matrix output (Louis Chauvet) drivers/gpu/drm/vkms/vkms_colorop.c | 34 +++++++++++++++++++++++++++- drivers/gpu/drm/vkms/vkms_composer.c | 32 ++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) -- 2.46.2 diff --git a/drivers/gpu/drm/vkms/vkms_colorop.c b/drivers/gpu/drm/vkms/vkms_colorop.c index aebd467c4e61..f0c264820a81 100644 --- a/drivers/gpu/drm/vkms/vkms_colorop.c +++ b/drivers/gpu/drm/vkms/vkms_colorop.c @@ -12,7 +12,7 @@ static const u64 supported_tfs = BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF) | BIT(DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF); -#define MAX_COLOR_PIPELINE_OPS 2 +#define MAX_COLOR_PIPELINE_OPS 4 static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_prop_enum_list *list) { @@ -48,6 +48,38 @@ static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_pr goto cleanup; } + ret = drm_colorop_ctm_3x4_init(dev, ops[i], plane); + if (ret) + goto cleanup; + + drm_colorop_set_next_property(ops[i-1], ops[i]); + + i++; + + /* 3rd op: 3x4 matrix */ + ops[i] = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL); + if (!ops[i]) { + DRM_ERROR("KMS: Failed to allocate colorop\n"); + ret = -ENOMEM; + goto cleanup; + } + + ret = drm_colorop_ctm_3x4_init(dev, ops[i], plane); + if (ret) + goto cleanup; + + drm_colorop_set_next_property(ops[i-1], ops[i]); + + i++; + + /* 4th op: 1d curve */ + ops[i] = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL); + if (!ops[i]) { + DRM_ERROR("KMS: Failed to allocate colorop\n"); + ret = -ENOMEM; + goto cleanup; + } + ret = drm_colorop_curve_1d_init(dev, ops[i], plane, supported_tfs); if (ret) goto cleanup; diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index 01fa81ebc93b..c8b9b9d7f78f 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -159,6 +159,35 @@ static void apply_lut(const struct vkms_crtc_state *crtc_state, struct line_buff } } +static void apply_3x4_matrix(struct pixel_argb_s32 *pixel, const struct drm_color_ctm_3x4 *matrix) +{ + s64 rf, gf, bf; + s64 r, g, b; + + r = drm_int2fixp(pixel->r); + g = drm_int2fixp(pixel->g); + b = drm_int2fixp(pixel->b); + + rf = drm_fixp_mul(drm_sm2fixp(matrix->matrix[0]), r) + + drm_fixp_mul(drm_sm2fixp(matrix->matrix[1]), g) + + drm_fixp_mul(drm_sm2fixp(matrix->matrix[2]), b) + + drm_sm2fixp(matrix->matrix[3]); + + gf = drm_fixp_mul(drm_sm2fixp(matrix->matrix[4]), r) + + drm_fixp_mul(drm_sm2fixp(matrix->matrix[5]), g) + + drm_fixp_mul(drm_sm2fixp(matrix->matrix[6]), b) + + drm_sm2fixp(matrix->matrix[7]); + + bf = drm_fixp_mul(drm_sm2fixp(matrix->matrix[8]), r) + + drm_fixp_mul(drm_sm2fixp(matrix->matrix[9]), g) + + drm_fixp_mul(drm_sm2fixp(matrix->matrix[10]), b) + + drm_sm2fixp(matrix->matrix[11]); + + pixel->r = drm_fixp2int_round(rf); + pixel->g = drm_fixp2int_round(gf); + pixel->b = drm_fixp2int_round(bf); +} + static void apply_colorop(struct pixel_argb_s32 *pixel, struct drm_colorop *colorop) { struct drm_colorop_state *colorop_state = colorop->state; @@ -179,6 +208,9 @@ static void apply_colorop(struct pixel_argb_s32 *pixel, struct drm_colorop *colo DRM_DEBUG_DRIVER("unkown colorop 1D curve type %d\n", colorop_state->curve_1d_type); break; } + } else if (colorop->type == DRM_COLOROP_CTM_3X4) { + if (colorop_state->data) + apply_3x4_matrix(pixel, (struct drm_color_ctm_3x4 *) colorop_state->data->data); } } From patchwork Thu Oct 3 20:01:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821510 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 9F15CCF34C4 for ; Thu, 3 Oct 2024 20:02:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DC7C410E902; Thu, 3 Oct 2024 20:01:53 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="LTFZuDUa"; dkim-atps=neutral Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2052.outbound.protection.outlook.com [40.107.94.52]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5D43610E944; Thu, 3 Oct 2024 20:01:52 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ntrUj0aSGlf9YlYv/tVnHm8GU69N05TQZ5uNs1RSTkpGIVzNTvPWpRpGGroI5Z9aerizF5rslC4Y3BJIse261TDFnsEezih654U/ALppnbePIHcJNVX5x03Z1C8nTax1G4OMlsL9tR0nRC521TvSaJtYwJA9RURkTqVSBAF4IfqwMx1dpGa6BaY5WnfDxW9g9HH30b71KLl0HTUDVg91/msCKON87TwCYJ32udfcvNHMnmiEps7BM1EX7FKFlPF1izlUlW/mN89Rma4yx97erKQaDNW540S+LxCcVN1JUF9T3ibmcEJxhRex3+hZvB1lv1K2H71++AUPdK2eJ1XmVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=gcyptxKg8vNclYQHOyNvD0mgjfSMnJ6XIxie57aeGCU=; b=FKAqQ0tvXxuownLQHYZnzgNUD5jSGK9l+H0NtPBKKxLJI5d6RnJMcWvCWNSXTp4jfGF7sqk4ZABDlGd2MwmmkX84yRG5jfgy7KnxrCP0hyS4w4Q0Nmz/bSp1OGWTcPpNK2wzH30XvM4WU+v4/BHPjrRlTpMLGGLucIIjCpzr+j4nlHESP+Tid2Zckn6FL0AWcHvgSej7orZY6sbUScYSfaofBCgKA704aYmy5SXSeIurUoNN26qExEwGdv+l8FNkf6s8nz5AmCBJk8N41Q5vdVsfgGeinGONChG9FtgudE/tciH1iVwJGqstmdbUNRnon7f+cNPaPF4pa1AssprVtQ== 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=gcyptxKg8vNclYQHOyNvD0mgjfSMnJ6XIxie57aeGCU=; b=LTFZuDUah/o45k52yxlqQznu6OMcrGT57ocsrszUOCtdbOGtrONZTrs8ygiDFmp1fqVmagmBIQupv26CLHymEskfio46RmK5/gwDiyMoePxxuTvpXpFDrDNxfmn7TYD7gnxPbWm0Hyt9oy6TfS6NsSFonJCZoTfefqmbMpE4a4M= Received: from CH0PR03CA0241.namprd03.prod.outlook.com (2603:10b6:610:e5::6) by MN2PR12MB4047.namprd12.prod.outlook.com (2603:10b6:208:1de::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Thu, 3 Oct 2024 20:01:48 +0000 Received: from CH2PEPF00000142.namprd02.prod.outlook.com (2603:10b6:610:e5:cafe::81) by CH0PR03CA0241.outlook.office365.com (2603:10b6:610:e5::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:01:47 +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 CH2PEPF00000142.mail.protection.outlook.com (10.167.244.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:47 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) 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.39; Thu, 3 Oct 2024 15:01:44 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:44 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:44 -0500 From: Harry Wentland To: , CC: , Harry Wentland Subject: [PATCH v6 20/44] drm/tests: Add a few tests around drm_fixed.h Date: Thu, 3 Oct 2024 16:01:02 -0400 Message-ID: <20241003200129.1732122-21-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000142:EE_|MN2PR12MB4047:EE_ X-MS-Office365-Filtering-Correlation-Id: a5d63383-fa39-4779-abde-08dce3e636a7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: 4QYSdp2t/n9kznfToxJxme06KJrOLfv6nRERckwoyieh59sZCDQKym/NtqPjyy+o84ekfYXvIROKoI4zwYVDaEccg4q4zrnwk9fRf9IzvMbjBuDNO24tMBGt9x9ITjKsXp1njarYh+96fnjWUVI/KHnAsxZ39oWTTbp29qDP4V2Xa1yEpasd05qZaMnSmrB5kmrrlSphK2EBTgeUwu3Dsqo8SJD+XA9dVTkwK9U/95yUVg71vcr+cB85UcC1uP/3GLp09lZZF0i7A2Ke4gJ+vOsKRWLglYHXWaqOmHcvKrEny3uE/s4Kr1WZlY6CgDD6/q2bQusk8rfaohxr26qvY2dADLs21BTCHLemTk3D3nxd7LZwOqPoijkZXZuUBbq56nR9QmwHZ/deEMBXEAdWw5Frcc4oURyS2O2ouSWr5P35tHjnRtPDC+MumhmMiZ9x/jYZB4Z4/ivISlQSM8GpXUW0opd56WK6ltLjOJEZi1VXToIyy0HCZ7QKUrEsY/YRZV3ff4PRwQUKZqEoJRyTW4eEjBttojLQ2THPiz0CnFDSoWl70LLf/Rx47aew2uwJPMAMLDG4AEeMYAczGOEDf5+b/mABLTApm9kBlowBrdUkCU4vERHQ6Pm6uj4w8nBjKGRJmt2qzV52MbMdL2OZE88A6lRgYQAM/atJzuzIZ2MigAtb+ArMFFeWqo986Hd5gD/NqhxEPBiHKCwkyAu4l7+g422e++AIF0zp23NVrJA7RjoeN9xljXwKu+mr6Uay6VVAlZsZsH7Q/CW2S/LLIIMf1SuJWHlfsIKnF/uelOmnNrJK3Jt96VE2MSryUBtI95/L448D3RWmvB8EdkE9/3RQ4lFvOP71y0hTGVJ2D2otfgfYZarXs4DE4S2+aqi/VPltXrwymceTSSF988TAnMCrScRaIuAiTSM87iyOjrYrg8uvrgnMlzzAsiPF1qCaJj6AFKV5IoChsXJhvu/0ol8zYSUILT6bR8QuduOYhUmJGqQId2blXSDRLzBmvMMDTLFVoyI5Nt2HJrETlvI65c98GAgO7Lgukb0x+rq3YcvvVmRC6vb5aQeZonhF/z2i3qBNOaBUVVgnf38xnaD2Sv0zIvhoB4MuC7PW3YEji8mNN4MEzHPBvQaX6HqIEYh/WC6EyzC3I981b7K5ozj515wyVXdZmV7JJtZt41Nb1avImQkEEBjiQmNPj4WZ8OsdP8kSZxphV3zBh16iIQiS8ZuBVJ9cJ4Dlld1sc7pZALeWsOe7wDym6EijT47xYqf5U5VAWE/8jd8BtEDFNZsql8EmJWNHq8dLfAOvI5CeXiicmqtlG1rrul1EReD0QTqkR91VzKf4vBBx9vj8CJba3W+LUsCUiP/2MjbKW/qf44o= 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:(13230040)(82310400026)(376014)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:47.7615 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a5d63383-fa39-4779-abde-08dce3e636a7 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: CH2PEPF00000142.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4047 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" While working on the CTM implementation of VKMS I had to ascertain myself of a few assumptions. One of those is whether drm_fixed.h treats its numbers using signed-magnitude or twos-complement. It is twos-complement. In order to make someone else's day easier I am adding the drm_test_int2fixp test that validates the above assumption. I am also adding a test for the new sm2fixp function that converts from a signed-magnitude fixed point to the twos-complement fixed point. Signed-off-by: Harry Wentland --- v6: - add missing MODULE_DESCRIPTION (Jeff Johnson) - fix buffer overflow drivers/gpu/drm/tests/Makefile | 3 +- drivers/gpu/drm/tests/drm_fixp_test.c | 70 +++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/tests/drm_fixp_test.c -- 2.46.2 diff --git a/drivers/gpu/drm/tests/Makefile b/drivers/gpu/drm/tests/Makefile index 56dab563abd7..bd69df0eee33 100644 --- a/drivers/gpu/drm/tests/Makefile +++ b/drivers/gpu/drm/tests/Makefile @@ -20,6 +20,7 @@ obj-$(CONFIG_DRM_KUNIT_TEST) += \ drm_modes_test.o \ drm_plane_helper_test.o \ drm_probe_helper_test.o \ - drm_rect_test.o + drm_rect_test.o \ + drm_fixp_test.o CFLAGS_drm_mm_test.o := $(DISABLE_STRUCTLEAK_PLUGIN) diff --git a/drivers/gpu/drm/tests/drm_fixp_test.c b/drivers/gpu/drm/tests/drm_fixp_test.c new file mode 100644 index 000000000000..24a801cf38be --- /dev/null +++ b/drivers/gpu/drm/tests/drm_fixp_test.c @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: MIT +/* + * Copyright 2022 Advanced Micro Devices, Inc. + */ + +#include +#include + +static void drm_test_sm2fixp(struct kunit *test) +{ + KUNIT_EXPECT_EQ(test, 0x7fffffffffffffffll, ((1ull << 63) - 1)); + + /* 1 */ + KUNIT_EXPECT_EQ(test, drm_int2fixp(1), drm_sm2fixp(1ull << DRM_FIXED_POINT)); + + /* -1 */ + KUNIT_EXPECT_EQ(test, drm_int2fixp(-1), drm_sm2fixp((1ull << 63) | (1ull << DRM_FIXED_POINT))); + + /* 0.5 */ + KUNIT_EXPECT_EQ(test, drm_fixp_from_fraction(1, 2), drm_sm2fixp(1ull << (DRM_FIXED_POINT - 1))); + + /* -0.5 */ + KUNIT_EXPECT_EQ(test, drm_fixp_from_fraction(-1, 2), drm_sm2fixp((1ull << 63) | (1ull << (DRM_FIXED_POINT - 1)))); + +} + +static void drm_test_int2fixp(struct kunit *test) +{ + /* 1 */ + KUNIT_EXPECT_EQ(test, 1ll << 32, drm_int2fixp(1)); + + /* -1 */ + KUNIT_EXPECT_EQ(test, -(1ll << 32), drm_int2fixp(-1)); + + /* 1 + (-1) = 0 */ + KUNIT_EXPECT_EQ(test, 0, drm_int2fixp(1) + drm_int2fixp(-1)); + + /* 1 / 2 */ + KUNIT_EXPECT_EQ(test, 1ll << 31, drm_fixp_from_fraction(1, 2)); + + /* -0.5 */ + KUNIT_EXPECT_EQ(test, -(1ll << 31), drm_fixp_from_fraction(-1, 2)); + + /* (1 / 2) + (-1) = 0.5 */ + KUNIT_EXPECT_EQ(test, 1ll << 31, drm_fixp_from_fraction(-1, 2) + drm_int2fixp(1)); + + /* (1 / 2) - 1) = 0.5 */ + KUNIT_EXPECT_EQ(test, -(1ll << 31), drm_fixp_from_fraction(1, 2) + drm_int2fixp(-1)); + + /* (1 / 2) - 1) = 0.5 */ + KUNIT_EXPECT_EQ(test, -(1ll << 31), drm_fixp_from_fraction(1, 2) - drm_int2fixp(1)); + +} + +static struct kunit_case drm_fixp_tests[] = { + KUNIT_CASE(drm_test_int2fixp), + KUNIT_CASE(drm_test_sm2fixp), + { } +}; + +static struct kunit_suite drm_rect_test_suite = { + .name = "drm_fixp", + .test_cases = drm_fixp_tests, +}; + +kunit_test_suite(drm_rect_test_suite); + +MODULE_AUTHOR("AMD"); +MODULE_LICENSE("GPL and additional rights"); +MODULE_DESCRIPTION("Unit tests for drm_fixed.h"); \ No newline at end of file From patchwork Thu Oct 3 20:01:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821515 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 9132DCF34C7 for ; Thu, 3 Oct 2024 20:02:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AFAB310E948; Thu, 3 Oct 2024 20:01:56 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="qlirlWRO"; dkim-atps=neutral Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2068.outbound.protection.outlook.com [40.107.244.68]) by gabe.freedesktop.org (Postfix) with ESMTPS id 818EB10E90E; Thu, 3 Oct 2024 20:01:50 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=T4iXOWJ7MLoT5CWfDLxI/iJRS94xYBZ/GVF20khwNSjxpKbD5a8voUqke+KqOMdyBzpD/F2CRHELV5WJQopA1hvIKgvRHePZNcCZ6bemNRsRRxDAOEE62BWL/CNWWSqvAW4L13hAZ8J8j067/5eJayJMoW9VVAd5O1vUNj5FJ86oYprPNgg902Nx6BmoOwuDF+5EW/qGoveMdgm3Yv3pfaIYHqJKkqZQfSa5dYjhZ0lzGLgGYB85d7W0Utyy9J/m1fcuEhcIIhSQpMyoj9PyMk+/Swm7ZYvQ8cD+nmh5auEKdVYg1TA8GNfQEU1UsD4Mh56YA+j+LNwvXqKWANo74A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=MGyqgMWYwW7qlhPYpJtvyScSYzWSzKiGH8lFTqQkAX4=; b=nie4Zm6IZQMCq7KSbDA+gNVYKKm3YnLx0oRswLapyyr236wZq7DIQ04g2547ya3AIha+5wuEhaCTuCcvIH1OLrLSo1DH0c3mhkyUCll3xzdoHZ3srgcovgx6XCAWHFGI57ye/67qNEZlTzdkEqRhz3fmGifCCrT8W+WpIQoO/1iCfHZXk9zI0UYzmJhCLBULmZfWIlrQuMsSi01hRsEk+oEcc9h2I+2iRcMlZvKHTEiSep2FgoLn61Y7+sY2RPKVLckWboMoSNoosoXfB9/sV0OLnhZEyqmoc+9B9BkoTk8SSRL8dSG48c28y4Cf4DAT31hCyCqBSRvLWiGDChhnQg== 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=MGyqgMWYwW7qlhPYpJtvyScSYzWSzKiGH8lFTqQkAX4=; b=qlirlWRObK/Y3G3oQ+ATTMhdvVMl4ecfHXa27oAEdpIBUfhRnmPoIcvSGlua2dhJ0WT/x5RqIY9BVC2w2QTmqvq/yw/220DZmEDm1r48jPVC/iEjodCviTBxlrWnL2QUAGU8A12eLte9qg3Yuw1zFhwWcy5ZRN51oYlRo2OSHvE= Received: from CH2PR14CA0046.namprd14.prod.outlook.com (2603:10b6:610:56::26) by CY5PR12MB6429.namprd12.prod.outlook.com (2603:10b6:930:3b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.27; Thu, 3 Oct 2024 20:01:46 +0000 Received: from DS2PEPF0000343E.namprd02.prod.outlook.com (2603:10b6:610:56:cafe::a2) by CH2PR14CA0046.outlook.office365.com (2603:10b6:610:56::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.17 via Frontend Transport; Thu, 3 Oct 2024 20:01:46 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS2PEPF0000343E.mail.protection.outlook.com (10.167.18.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:46 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:44 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:44 -0500 From: Harry Wentland To: , CC: , Harry Wentland Subject: [PATCH v6 21/44] drm/vkms: Add tests for CTM handling Date: Thu, 3 Oct 2024 16:01:03 -0400 Message-ID: <20241003200129.1732122-22-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343E:EE_|CY5PR12MB6429:EE_ X-MS-Office365-Filtering-Correlation-Id: cb198991-6b62-4c77-700a-08dce3e635d9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|36860700013|376014|1800799024; X-Microsoft-Antispam-Message-Info: mckMhzSvrXVGY9HFcL/ycyHi0ETB8O5ubyrmrF80ZWhJWontILh90LXNtZRMa+RuZl8rapJRQHCYfG4eMGNHb3A3SflyQ6/dCuuvN9/4VARbaXsFJZROpGMMQ5vrTOtBkona6UsR3MGn+wuh6FDCzjbY27RaD0dNB4RjpAG1BasEZSD1NBr8YyHONXiO3NfTM+nXeUcdble8Jkoj0z0HnPjyBgBRmeXOtXVZVHOdXxYw7cpqo6lU5OSBhon0oMboHpxpo0SjUdqfWpdxRqx6gI6jhrumFqsdkwBdcHDX7Jva9G7kIxtDHQpKO68HCLAbvCUlnykAAB0j5Ujrxc85I+zhT4KPGbb78CuMC4iqErOaRjhUCHCVJPR8F9E0WEhSZk4U/ezSVYPDPFbzV+F3dRA7ISmXC/0m0KsBmFG1zp1wW6deFmzO1rUwfNrdfb9pG2TPty/5+HuxPtqw4qgVfgtLiu8DFvyOEMshJpqtcELKQOvOWVJqlO/JoSRawoaT5B/yJUUZF0eOplATVxA5tUo+QajYDgvgl7Y6qO6TRD8slROdb1rSuZalaGHJjcqACS3Z4hDgVQsccfxzn6sz1UvQpUP03LIrz3w02PbOFAM6GltL8DUYucoOTuIoaSChjhFNTYqV6tqA27sZ1+73CmdnM6txhghIbAgoEbS3497edIfq5ra7iiBO7+8SBaOg7C8wo3+Roge6XV3sPxztT+MceJnn6bMlQ6Gl5vLC1Dt8kQJQ3quwduR3k8H2W4OmCSKab1kCvNB8tB813t8BWUrCux/DDaeu+9yIZ+EUfZZY2oVFCp7wxfoDqngNT+69rEhG/G2bZOsO7oLSkNcFXVvqV3yJTMGKSmlm9nVCrMHLOl6eqVMolUhCk5WPuuZptaV8Os/cpsB96Z2Hlv1hxNIEYRP4Mmra7Q0RyzbMiDITAVEGlQMXZ9Dq2YaSkBLGsZc+QKdnUXK5BvdYmMtvSiHhc4imdbHrKClxchdoVOiuLwwfSSzTE0l+FOke2/RbRUNscacPM4pyCwXMQL+KyEvIrbKqKmSV47wtmWYEL73nKdAKRSogkhRK6Aa1m1Pw5eh+rIL7SVaMyCgjBKGevgQkdIbBmEEjNQr8RNY4kL/gYbbyMdShcIXHn3e/GqQMTqw8FbeGn/6bO7+Sm1yaoLalOTKDnE+BBeI3YQeYCrQf+xeoUlcS1YVRMrZIRzjqdMaHKx6PTCYi1eBGLj0nitLE31/QleFu18m5sIv1JI5Vnp+pHmXck0Uzgm1djgC3EPxrijEQicm33+hoSjlU1eu8TVbKI6SkioYm1Qq5IUO+RfkPKuboSwz6ux/pbNO+qoW+zSqCZclKRgYK+aSeu20F9bJYwsYJo2Y+rbXh9vglPCSHAnCEgSDhLSMtrF9P X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(82310400026)(36860700013)(376014)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:46.3943 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cb198991-6b62-4c77-700a-08dce3e635d9 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF0000343E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6429 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" A whole slew of tests for CTM handling that greatly helped in debugging the CTM code. The extent of tests might seem a bit silly but they're fast and might someday help save someone else's day when debugging this. Signed-off-by: Harry Wentland Reviewed-by: Louis Chauvet --- v6: - update reference values since we're now rounding v5: - Make apply_3x4_matrix static v4: - Comment on origin of bt709_enc matrix (Pekka) - Use full opaque alpha (Pekka) - Add additional check for Y < 0xffff (Pekka) - Remove unused code (Pekka) - Rename red, green, blue to Y, U, V where applicable drivers/gpu/drm/vkms/tests/vkms_color_test.c | 250 +++++++++++++++++++ drivers/gpu/drm/vkms/vkms_composer.c | 3 +- drivers/gpu/drm/vkms/vkms_composer.h | 1 + 3 files changed, 253 insertions(+), 1 deletion(-) -- 2.46.2 diff --git a/drivers/gpu/drm/vkms/tests/vkms_color_test.c b/drivers/gpu/drm/vkms/tests/vkms_color_test.c index c36e67c7909e..d5eb1e4e9b67 100644 --- a/drivers/gpu/drm/vkms/tests/vkms_color_test.c +++ b/drivers/gpu/drm/vkms/tests/vkms_color_test.c @@ -187,11 +187,261 @@ static void vkms_color_srgb_inv_srgb(struct kunit *test) } } +#define FIXPT_HALF (DRM_FIXED_ONE >> 1) +#define FIXPT_QUARTER (DRM_FIXED_ONE >> 2) + +const struct drm_color_ctm_3x4 test_matrix_3x4_50_desat = { { + FIXPT_HALF, FIXPT_QUARTER, FIXPT_QUARTER, 0, + FIXPT_QUARTER, FIXPT_HALF, FIXPT_QUARTER, 0, + FIXPT_QUARTER, FIXPT_QUARTER, FIXPT_HALF, 0 +} }; + +static void vkms_color_ctm_3x4_50_desat(struct kunit *test) +{ + struct pixel_argb_s32 ref, out; + + /* full white */ + ref.a = 0xffff; + ref.r = 0xffff; + ref.g = 0xffff; + ref.b = 0xffff; + + memcpy(&out, &ref, sizeof(out)); + apply_3x4_matrix(&out, &test_matrix_3x4_50_desat); + + KUNIT_EXPECT_MEMEQ(test, &ref, &out, sizeof(out)); + + /* full black */ + ref.a = 0xffff; + ref.r = 0x0; + ref.g = 0x0; + ref.b = 0x0; + + memcpy(&out, &ref, sizeof(out)); + apply_3x4_matrix(&out, &test_matrix_3x4_50_desat); + + KUNIT_EXPECT_MEMEQ(test, &ref, &out, sizeof(out)); + + /* 50% grey */ + ref.a = 0xffff; + ref.r = 0x8000; + ref.g = 0x8000; + ref.b = 0x8000; + + memcpy(&out, &ref, sizeof(out)); + apply_3x4_matrix(&out, &test_matrix_3x4_50_desat); + + KUNIT_EXPECT_MEMEQ(test, &ref, &out, sizeof(out)); + + /* full red to 50% desat */ + ref.a = 0xffff; + ref.r = 0x8000; + ref.g = 0x4000; + ref.b = 0x4000; + + out.a = 0xffff; + out.r = 0xffff; + out.g = 0x0; + out.b = 0x0; + + apply_3x4_matrix(&out, &test_matrix_3x4_50_desat); + + KUNIT_EXPECT_MEMEQ(test, &ref, &out, sizeof(out)); +} + +/* + * BT.709 encoding matrix + * + * Values printed from within IGT when converting + * igt_matrix_3x4_bt709_enc to the fixed-point format expected + * by DRM/KMS. + */ +const struct drm_color_ctm_3x4 test_matrix_3x4_bt709_enc = { { + 0x00000000366cf400ull, 0x00000000b7175900ull, 0x0000000127bb300ull, 0, + 0x800000001993b3a0ull, 0x800000005609fe80ull, 0x000000006f9db200ull, 0, + 0x000000009d70a400ull, 0x800000008f011100ull, 0x800000000e6f9330ull, 0 +} }; + +static void vkms_color_ctm_3x4_bt709(struct kunit *test) +{ + struct pixel_argb_s32 out; + + /* full white to bt709 */ + out.a = 0xffff; + out.r = 0xffff; + out.g = 0xffff; + out.b = 0xffff; + + apply_3x4_matrix(&out, &test_matrix_3x4_bt709_enc); + + /* Y 255 */ + KUNIT_EXPECT_GT(test, out.r, 0xfe00); + KUNIT_EXPECT_LT(test, out.r, 0x10000); + + /* U 0 */ + KUNIT_EXPECT_LT(test, out.g, 0x0100); + + /* V 0 */ + KUNIT_EXPECT_LT(test, out.b, 0x0100); + + /* full black to bt709 */ + out.a = 0xffff; + out.r = 0x0; + out.g = 0x0; + out.b = 0x0; + + apply_3x4_matrix(&out, &test_matrix_3x4_bt709_enc); + + /* Y 0 */ + KUNIT_EXPECT_LT(test, out.r, 0x100); + + /* U 0 */ + KUNIT_EXPECT_LT(test, out.g, 0x0100); + + /* V 0 */ + KUNIT_EXPECT_LT(test, out.b, 0x0100); + + /* gray to bt709 */ + out.a = 0xffff; + out.r = 0x7fff; + out.g = 0x7fff; + out.b = 0x7fff; + + apply_3x4_matrix(&out, &test_matrix_3x4_bt709_enc); + + /* Y 127 */ + KUNIT_EXPECT_GT(test, out.r, 0x7e00); + KUNIT_EXPECT_LT(test, out.r, 0x8000); + + /* U 0 */ + KUNIT_EXPECT_LT(test, out.g, 0x0100); + + /* V 0 */ + KUNIT_EXPECT_LT(test, out.b, 0x0100); + + /* == red 255 - bt709 enc == */ + out.a = 0xffff; + out.r = 0xffff; + out.g = 0x0; + out.b = 0x0; + + apply_3x4_matrix(&out, &test_matrix_3x4_bt709_enc); + + /* Y 54 */ + KUNIT_EXPECT_GT(test, out.r, 0x3500); + KUNIT_EXPECT_LT(test, out.r, 0x3700); + + /* U 0 */ + KUNIT_EXPECT_LT(test, out.g, 0x0100); + + /* V 157 */ + KUNIT_EXPECT_GT(test, out.b, 0x9C00); + KUNIT_EXPECT_LT(test, out.b, 0x9E00); + + + /* == green 255 - bt709 enc == */ + out.a = 0xffff; + out.r = 0x0; + out.g = 0xffff; + out.b = 0x0; + + apply_3x4_matrix(&out, &test_matrix_3x4_bt709_enc); + + /* Y 182 */ + KUNIT_EXPECT_GT(test, out.r, 0xB500); + KUNIT_EXPECT_LT(test, out.r, 0xB780); /* laxed by half*/ + + /* U 0 */ + KUNIT_EXPECT_LT(test, out.g, 0x0100); + + /* V 0 */ + KUNIT_EXPECT_LT(test, out.b, 0x0100); + + /* == blue 255 - bt709 enc == */ + out.a = 0xffff; + out.r = 0x0; + out.g = 0x0; + out.b = 0xffff; + + apply_3x4_matrix(&out, &test_matrix_3x4_bt709_enc); + + /* Y 18 */ + KUNIT_EXPECT_GT(test, out.r, 0x1100); + KUNIT_EXPECT_LT(test, out.r, 0x1300); + + /* U 111 */ + KUNIT_EXPECT_GT(test, out.g, 0x6E00); + KUNIT_EXPECT_LT(test, out.g, 0x7000); + + /* V 0 */ + KUNIT_EXPECT_LT(test, out.b, 0x0100); + + /* == red 140 - bt709 enc == */ + out.a = 0xffff; + out.r = 0x8c8c; + out.g = 0x0; + out.b = 0x0; + + apply_3x4_matrix(&out, &test_matrix_3x4_bt709_enc); + + /* Y 30 */ + KUNIT_EXPECT_GT(test, out.r, 0x1D00); + KUNIT_EXPECT_LT(test, out.r, 0x1F00); + + /* U 0 */ + KUNIT_EXPECT_LT(test, out.g, 0x100); + + /* V 87 */ + KUNIT_EXPECT_GT(test, out.b, 0x5600); + KUNIT_EXPECT_LT(test, out.b, 0x5800); + + /* == green 140 - bt709 enc == */ + out.a = 0xffff; + out.r = 0x0; + out.g = 0x8c8c; + out.b = 0x0; + + apply_3x4_matrix(&out, &test_matrix_3x4_bt709_enc); + + /* Y 30 */ + KUNIT_EXPECT_GT(test, out.r, 0x6400); + KUNIT_EXPECT_LT(test, out.r, 0x6600); + + /* U 0 */ + KUNIT_EXPECT_LT(test, out.g, 0x100); + + /* V 0 */ + KUNIT_EXPECT_LT(test, out.b, 0x100); + + + /* == blue 140 - bt709 enc == */ + out.a = 0xffff; + out.r = 0x0; + out.g = 0x0; + out.b = 0x8c8c; + + apply_3x4_matrix(&out, &test_matrix_3x4_bt709_enc); + + /* Y 30 */ + KUNIT_EXPECT_GT(test, out.r, 0x900); + KUNIT_EXPECT_LT(test, out.r, 0xB00); + + /* U 61 */ + KUNIT_EXPECT_GT(test, out.g, 0x3C00); + KUNIT_EXPECT_LT(test, out.g, 0x3E00); + + /* V 0 */ + KUNIT_EXPECT_LT(test, out.b, 0x100); + +} + static struct kunit_case vkms_color_test_cases[] = { KUNIT_CASE(vkms_color_test_get_lut_index), KUNIT_CASE(vkms_color_test_lerp), KUNIT_CASE(vkms_color_test_linear), KUNIT_CASE(vkms_color_srgb_inv_srgb), + KUNIT_CASE(vkms_color_ctm_3x4_50_desat), + KUNIT_CASE(vkms_color_ctm_3x4_bt709), {} }; diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index c8b9b9d7f78f..daee7d56abb7 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -159,7 +159,7 @@ static void apply_lut(const struct vkms_crtc_state *crtc_state, struct line_buff } } -static void apply_3x4_matrix(struct pixel_argb_s32 *pixel, const struct drm_color_ctm_3x4 *matrix) +VISIBLE_IF_KUNIT void apply_3x4_matrix(struct pixel_argb_s32 *pixel, const struct drm_color_ctm_3x4 *matrix) { s64 rf, gf, bf; s64 r, g, b; @@ -187,6 +187,7 @@ static void apply_3x4_matrix(struct pixel_argb_s32 *pixel, const struct drm_colo pixel->g = drm_fixp2int_round(gf); pixel->b = drm_fixp2int_round(bf); } +EXPORT_SYMBOL_IF_KUNIT(apply_3x4_matrix); static void apply_colorop(struct pixel_argb_s32 *pixel, struct drm_colorop *colorop) { diff --git a/drivers/gpu/drm/vkms/vkms_composer.h b/drivers/gpu/drm/vkms/vkms_composer.h index 67ae09913460..afef65a5c3ba 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.h +++ b/drivers/gpu/drm/vkms/vkms_composer.h @@ -21,6 +21,7 @@ u16 lerp_u16(u16 a, u16 b, s64 t); s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel_value); u16 apply_lut_to_channel_value(const struct vkms_color_lut *lut, u16 channel_value, enum lut_channel channel); +void apply_3x4_matrix(struct pixel_argb_s32 *pixel, const struct drm_color_ctm_3x4 *matrix); #endif #endif /* _VKMS_COMPOSER_H_ */ From patchwork Thu Oct 3 20:01:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821513 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 7F2BCCF34C4 for ; Thu, 3 Oct 2024 20:02:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0AA2B10E938; Thu, 3 Oct 2024 20:01:55 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="c2R/io+Y"; dkim-atps=neutral Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2041.outbound.protection.outlook.com [40.107.95.41]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0D78510E927; Thu, 3 Oct 2024 20:01:50 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bpEKvY2efVMQf11rl5sulPJh+A9tz+M5j4x/+U3p/RwRSQHY44EosfQdPBlatmcb6Tt8gq+HB9nMovSfuvmFq7Ng0mGhmpx5Kx54NJrW0N0a+IUyDxy2mKJhVw0P76GG4FneXJ1PCUhahDx/oQlu39J2dvyN8WeDP+kSBYLm+f0iJiYAhKvunFy27x7MsP3wwL4V67IEIOA8+FdeX5ZZGWgTyH+el13eRTPQzNXgDip18fW6q50jQDGsfrajaKbllL+sqew3SppPLqJka2EI4KzqzssQlsRe7Tq6fvt5OCIcCJli1RTv7SXsJE8s7TM2rjoHmX6bNlFDS/V8hEr2EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=a0f2fUMHSGS8VRdlJYGKBRkvuZhJQLh8w1q7IS6p4YY=; b=fhe3/GJrV/o5b2YHQ3MKFmYEyk6nmifZbfOyzHrW+kkQJ9grzbMvX4vfbWRksEYnoL11wgV16UU4E0Oj7PnvPxx21hop0Cqa9F+sWMhxMlW45JSb32Um+MmqGJzbJuWSFOON3Z4l3xrEgWo6FZrmUbqfzwwmRuppMY2g6tDr3oK9oCidPvCyEiUIYwAMUi6T6uAPcama1i7rhSeYQznWNsGE2WM8W4KXjoKvxzgVa4y73T+KpYRG8w9gNxgG9X4yOqfs9d69u0ZQfBhUguZ3Eqa1ailslKjXA0jFYrRaz/bnbZXjnOGbIsIaB1D7QZvom3kHqzXczE9XDsFQnKIRcw== 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=a0f2fUMHSGS8VRdlJYGKBRkvuZhJQLh8w1q7IS6p4YY=; b=c2R/io+YAGLkEIaWHKnFVhAjq7G1ABGVfr3ao/RpKRb6pkb+IPgJbJUMT8f6DjRI+zxl2c54QcbUvS6tcudIi9sz/EKDn7jvDCwiiM3m2s3Wq3EHn1UKZp1SLM3WMj/NmZEI/oI7y/9M5/3QixFvESsqAX3IPH/RCWi4kPkItKE= Received: from CH2PR14CA0033.namprd14.prod.outlook.com (2603:10b6:610:56::13) by SN7PR12MB7369.namprd12.prod.outlook.com (2603:10b6:806:298::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18; Thu, 3 Oct 2024 20:01:47 +0000 Received: from DS2PEPF0000343E.namprd02.prod.outlook.com (2603:10b6:610:56:cafe::cb) by CH2PR14CA0033.outlook.office365.com (2603:10b6:610:56::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:01:47 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS2PEPF0000343E.mail.protection.outlook.com (10.167.18.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:47 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:45 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:45 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:45 -0500 From: Harry Wentland To: , CC: , Harry Wentland Subject: [PATCH v6 22/44] drm/colorop: pass plane_color_pipeline client cap to atomic check Date: Thu, 3 Oct 2024 16:01:04 -0400 Message-ID: <20241003200129.1732122-23-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB05.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343E:EE_|SN7PR12MB7369:EE_ X-MS-Office365-Filtering-Correlation-Id: 7598050f-b7b0-4a18-f543-08dce3e6363f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|1800799024|376014|82310400026; X-Microsoft-Antispam-Message-Info: dAAaRU0op03lCerUHmDRYfVkA/xUiJ3ziLknGOo/6PYLSTX1kH+H044qqyyUSiNa24Jd8RKRdH6wDN31IE72iqv0VEfksZmqFaInInqbdQ7RjFiOhbr44ae771OF3W4xMREqbhqm3kIglv+bTE8C0hr5DY0AWd1FBTlTH/yVGEffujQeS3J7RUM/mNCb/LJLgPzvfGkKA3Jk7QCH+8+ThourkqDLtkI6gsATOGmtZR+rC+cU0M88N0a/TxFYuQLudYGVHdoBBAmGc0UBHLPevVzhuIWuucgAz/XZdXgqCRuFuze9CVudpZDsk6PLlmcVsOewhJ5MqG0DlPFqbjti2uw/3EnGsf6POoodUlq3AzHHeZgcSoP5NzZJr+s60sKwV5Rghwn5qHuJJl8USRZE5X0GzzodDiU4RdO27zYpnwxUIYMZBS9h/SGn4cCXF7cFqeAVS4e3nsg6TdOhkGAr8oXqVjUDcVbM6/ejWgFPAAy5bQ00v8XaJG5WTOhK9WirjNEA5JLhS7auoiZ5/MxJoU3FsABsUMw19xf7J0bT2zT9gngBr09jsCx0LzOeVRHOQnl6AXwwiVISVYcErtzdDVtcqvXkUDsExBDneH9vDYJESR3PLNzuKIHXHiYx7uV1CC/o3TfpAW0IbvuYUtCnzkIjHUY+SMVAa0xRdvlIpdwMqU2nbr6vlABGYuFBTAF9MZBxUqRWxAiDxymYcXtokE3z6J0selnjjsJW0TjbFalP16ihTqzH69+c2T++bhh09UuwagKxGDgqjXrHbFp8+fyYnQFQAJOQ5LF5VASIiYlrKEik0/Pl+0yw0ifSGmDUXy8p8W/cuFoc8dktQ8+pIBFL1OR6BrZ6/MHbbe8ZqoxxVV5HLcBXYaQ0A5/bc4gKPpnNivY+G1qR33dVJDPDS7CeNWC+le4QIxJzETCCowsHHD9ABAhAJoaBL7eqsMYpcTIta9IhRdB/WCShJF2efsKh0CTAgO317rqMvjogSlrSnfM7NeJ7f2IUjUMC1fQDIwtjkty7Wejgo1cXupLo26iobjEq5GnbDI+f0RzmtpEx9sVNAetjCqGsYHGEroK+vX2uFJvR90rLUPdxWeUxqNMV/P60knuE+6XRQOFFzbSa/OuNW2aiVhc2u420uuBwr9IvZVm4hasACmGCIX1h1t0l8nGNd403Bf1AaDpz4aqDOJ/J0pZCweymk2hz6HGsGtviCqDYVe+Fxugsk6NsTAaiZFhM5p5/G1bgLZMGQhllJlgPEosLDde6oijyVP04d8JlMwXnlYuSUdHuq4LmDFm9x2S8FS0kUaBs9aQwLSagJfy4rDI7IIOnvdrL5LHBmTtXJW05w6K4LWCiZ7PFrwe60sC7nugXPHL72HBB1p6mZpPED4mJ3W4zpjlkS06r X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700013)(1800799024)(376014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:47.0662 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7598050f-b7b0-4a18-f543-08dce3e6363f 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF0000343E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7369 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" Drivers will need to know whether an atomic check/commit originated from a client with DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE so they can ignore deprecated properties, like COLOR_ENCODING and COLOR_RANGE. Pass the plane_color_pipeline bit to drm_atomic_state. Signed-off-by: Harry Wentland --- v5: - Fix kernel docs drivers/gpu/drm/drm_atomic_uapi.c | 1 + include/drm/drm_atomic.h | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) -- 2.46.2 diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index 12d9d18c1c78..fafbaa73b95f 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -1571,6 +1571,7 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE); state->acquire_ctx = &ctx; state->allow_modeset = !!(arg->flags & DRM_MODE_ATOMIC_ALLOW_MODESET); + state->plane_color_pipeline = file_priv->plane_color_pipeline; retry: copied_objs = 0; diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h index a2e7ac463eef..29e5d400a362 100644 --- a/include/drm/drm_atomic.h +++ b/include/drm/drm_atomic.h @@ -414,6 +414,24 @@ struct drm_atomic_state { */ bool duplicated : 1; + /** + * @plane_color_pipeline: + * + * Indicates whether this atomic state originated with a client that + * set the DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE. + * + * Drivers and helper functions should use this to ignore legacy + * properties that are incompatible with the drm_plane COLOR_PIPELINE + * behavior, such as: + * + * - COLOR_RANGE + * - COLOR_ENCODING + * + * or any other driver-specific properties that might affect pixel + * values. + */ + bool plane_color_pipeline : 1; + /** * @colorops: * From patchwork Thu Oct 3 20:01:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821511 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 0A316CF34C6 for ; Thu, 3 Oct 2024 20:02:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4412210E911; Thu, 3 Oct 2024 20:01:54 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="J22RZD/W"; dkim-atps=neutral Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2072.outbound.protection.outlook.com [40.107.95.72]) by gabe.freedesktop.org (Postfix) with ESMTPS id 96C9A10E92F; Thu, 3 Oct 2024 20:01:53 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oJSMXT26keozqJB5t6+BSdB/ypUIiaPi38KL1CLeWB5Pseoqynv30YKhMPvz+QDBmmgk4VxLkSOJQq7+vyawL0i4YgcEO/kiMPRpFfwIjOT71R8FuyOwMObrTijmIyoy1sVbzL9Gd08TD+ZV4MMY15TYW1SVffIIBddzdrkraatKz8HISznYsPggPdgbx62eg5NvCBkH/D+cTH60E2gj25M5RrvzjX1qmJ/ec3TsSr4vUin6EtExvEQp6FKMVjJ91efIq8nez0xVU++97wRUv+Q6IfZIMF9d5s+X/pD8ejosJ9OqRkPxXyiRtlwQCoqpWcUMEXDSJBZiZeyasLH4Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=+mDyacCAbHsyEVsCCmn7QUdAmvddf9Oc07pFMrrDisg=; b=U249u68Xv4N8U1kJDx3fzuqwCEcF1ZzOTr9vn8L5+6cgWPIpbxcsK85ynp7QxeE+ZPBHEhQH8hP78k9okTQq/iqPmlNKJeqM7qWuwJ2gWFuu6698WE+X+AJ5282P8a7sOh4JFCwBDQY2xAM40gUPvKPnotD9othFLcYZ+nKUDFrmUDuuA9hkwC4vP2le0/btthFj+Rb+EmmPU4zgelujcYOkWdrSKm9CftNzGuEHQuYt5LbXlYL/6OqSnKkvvRP9sy+3es4R0WVj3ri7/Js/nBbGOb0wNwxzY/qfmgiEhloQOPc+XqVfIc1ALAEnmqkP0k2gsd8oiPRlDLtu24XLVQ== 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=+mDyacCAbHsyEVsCCmn7QUdAmvddf9Oc07pFMrrDisg=; b=J22RZD/Wan5UW2l1NZWOif5ET5/rv3DErfRaeHs+FD6Otp1f43j9+0E7HqhsAqnFIGd2V9gRWjiFk06aEVakIwCBKhhMISodyF69jJhR8JYk5MSAyrXZ8lk+G3XA+AVWa6skcfXCL+TD0ek4JZw6rxU6sI/vDl9HuicClLCmbm4= Received: from CH0PR03CA0241.namprd03.prod.outlook.com (2603:10b6:610:e5::6) by CH3PR12MB8187.namprd12.prod.outlook.com (2603:10b6:610:125::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18; Thu, 3 Oct 2024 20:01:48 +0000 Received: from CH2PEPF00000142.namprd02.prod.outlook.com (2603:10b6:610:e5:cafe::86) by CH0PR03CA0241.outlook.office365.com (2603:10b6:610:e5::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:01:48 +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 CH2PEPF00000142.mail.protection.outlook.com (10.167.244.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:48 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.39; Thu, 3 Oct 2024 15:01:46 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:45 -0500 From: Harry Wentland To: , CC: , Alex Hung Subject: [PATCH v6 23/44] drm/colorop: define a new macro for_each_new_colorop_in_state Date: Thu, 3 Oct 2024 16:01:05 -0400 Message-ID: <20241003200129.1732122-24-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB03.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000142:EE_|CH3PR12MB8187:EE_ X-MS-Office365-Filtering-Correlation-Id: 48d73ff4-2075-4d72-7fa7-08dce3e6371c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: UH9n+5s96hLK/ZP/IbX5EjSEyP6dfbs6eTX0om9lgI01+y4yor3Dlw7smI9/xDMVHT7KONWdXDkbluGFLTev6hkJUrGnS62ouGJV/+6zRi7e/Xqef6g192tOE4PhnoRB6m6zBXxYJmVpmOS7euWJxlqSFNufKWHDk+oQrwIgH3klMNTY6jCUoxcu2rQx/Dg+kcchm+CtDhOQKUeEg8LSpBGcMMnq3nGfYFceiZr1YG4HkocaXm6WPdOPcbJfBYNGcVFFVo3kJmNtcjdLj7TNzhFv1mW6eISL4vV/laHnkedIM3xr+XtF2Y1tdvZlTXAM/kVN6Nq/SFdK3h+OgjvGkr9+xdgZF8CFHOKgjrFtcKzvdQdRrXu+duSHmJM9nRRgmB2xXOTmLUsJUsDHlzUUPc7GfpcIRHCzbVpmRPLMZh9ak2WhHBXP9DxL4qr+ZZJtN99n+vi9Mdj4XiuslmNM5adLefQTJTVn1X1shGlwE8GnFjiMlONnjH9XkMI1jlhnEhdTEbIQoTVk5jdggxPALmLrv7hjTecQ9AqzHS1Y36bDrRGnIpoPbgYol+2tWqZpRmRjbAFDz5gMGvJ7+qibah+KO0tUxcvB85u5szJbt24o3t8YDekvev4uhrUP/aLmDqRY8WyDHg4ebMrhzLfckwpMcBMLZYKfq0BAEqevDXxOgEybLY0JGTmkZ8GDu9a6xHdUiIYMnPDzSKCaqZu/G/BJv2ZoEO5RFOwX5ATieINlfrDMZgEyK7FCKyHHuRSyuTOQ+elnM4c/BcU2Jz13SBFElTeUow/7hvlV13ITw3jYqpghQl5KbNDh1Q6INsI2i2ug9h0bsZtcSlexiyRm9HYpGHy00UoPKwO6oR0B5TL1egibccWNUQosu06aO5FM7D/iHWReADO5ENbTV1xbkKMs62LfJTq+nU1XAyUXUfJoL2b3axJ9yPpIBIve0ZNMMhff5TeJbzym1z+iBoSX8LYqPJfGmTS4qCPnvHEElQiNGIJo9OHrUdkSQ4k81Mdx/mtGqrbsNDYgOhqua/u3cq7cGClJFh57SMTIlARnifDQXr4zazWmqLYWFdde8L8fpCCS2dzTBMRZmDCNXqR+8+IH5fM6BsXVyZnyS8MjMxn6cXRiqqr7rC1P451QHk4KyBVkVKo+ZypDV902eQQ8f2Yl/f/0rRm9pGxJ2bW4nnnQq7i2eW6Oywbzb+2kM2vZPQtFHIQRBPU3ziZ4WA6nYi4H8JeZsJghgRL3OBKtff1KLTBePRD17mS13KvhCMrry9afgTvcMrXLjPC3IDlHETNX0f0P0DfN73UsKuImUzRsjdzLx3hVKLp2eJPmsgEtKOTEqOneYXxJZKEnofIuhXeCv8zqlaipMdqZf8cTZBjHD1uXEbm8w/Ijx9fz9xhV 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:(13230040)(36860700013)(376014)(1800799024)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:48.5115 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 48d73ff4-2075-4d72-7fa7-08dce3e6371c 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: CH2PEPF00000142.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8187 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 Create a new macro for_each_new_colorop_in_state to access new drm_colorop_state updated from uapi. Signed-off-by: Alex Hung --- include/drm/drm_atomic.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h index 29e5d400a362..8b0c90d1d7be 100644 --- a/include/drm/drm_atomic.h +++ b/include/drm/drm_atomic.h @@ -1035,6 +1035,26 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p); (new_colorop_state) = (__state)->colorops[__i].new_state, 1)) +/** + * for_each_new_colorop_in_state - iterate over all colorops in an atomic update + * @__state: &struct drm_atomic_state pointer + * @colorop: &struct drm_colorop iteration cursor + * @new_colorop_state: &struct drm_colorop_state iteration cursor for the new state + * @__i: int iteration cursor, for macro-internal use + * + * This iterates over all colorops in an atomic update, tracking new state. This is + * useful is useful in places where the state delta needs to be considered, for + * example in atomic check functions. + */ +#define for_each_new_colorop_in_state(__state, colorop, new_colorop_state, __i) \ + for ((__i) = 0; \ + (__i) < (__state)->dev->mode_config.num_colorop; \ + (__i)++) \ + for_each_if ((__state)->colorops[__i].ptr && \ + ((colorop) = (__state)->colorops[__i].ptr, \ + (void)(colorop) /* Only to avoid unused-but-set-variable warning */, \ + (new_colorop_state) = (__state)->colorops[__i].new_state, 1)) + /** * for_each_oldnew_plane_in_state - iterate over all planes in an atomic update * @__state: &struct drm_atomic_state pointer From patchwork Thu Oct 3 20:01:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821522 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 07E0FCF34C4 for ; Thu, 3 Oct 2024 20:03:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5AA4D10E958; Thu, 3 Oct 2024 20:02:00 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="GaAwzt3F"; dkim-atps=neutral Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2049.outbound.protection.outlook.com [40.107.212.49]) by gabe.freedesktop.org (Postfix) with ESMTPS id E267A10E93D; Thu, 3 Oct 2024 20:01:55 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iZQbNCWjhdBN6T1+LHEw0p5wsR+jb+ctDAE9lZBNHqscnWg2yzYWuVISYY8MEm8WfEdipLP/UoqgBCNjPFFy19c7zeXSTlcOMYfCqEPMK8fviEnGKPZy9e+1lBUodbHFXXEHIC1AHO8TUROArSkHLH9jsXnjRjfTGHTPKuryUHkTD9aUsdBALGm61xCKIRXDwSaKHMksG6wQ32a5LzurBw4J42jrqMgLLDciEkXjcuSxILQ+of3RSANa09y1BE1JtIDN66w0d6ijLwr/8BBUEoWNZSAMN984BjBqbgQ/ybQk63yh7NHo2vfwj1SgTVaJu9QPiBK73j8/HjkVsN+7sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Cv06hQRa4CkVxvu8SwVXdopD9lQOA77m2L2Toxla8vc=; b=roODEySo5DWXlR1fGffdYTfKL9XCkXYlOzFvJ/Whktu9JL9i0eiZMj8ZlUHGc3MeLLa8BTwy9pNxnl5+lwanM1DDJwEA+k0ATjmvwmd9T0upt4uj6PcpRT8aqubDoV6zwDFfAONmH+NZHVuwhHAIler1E//MeZvVZKD7lqp18Ti6TYAXCj8BwXczgvAUc8eXfLMoohi2hqRY5M4aoJlXRM+U0v+dbaMKIpX3nv5gXmZ9NqcUIo4TtGuqpwLd6J1ELMtbRoOHUdsKi3OAv/ELM9pjGA79om0CboAx1UT9NacsGcW4x3KsGVYLK1ER78uGsDgYs/UhF9ORwEa3Qsxzeg== 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=Cv06hQRa4CkVxvu8SwVXdopD9lQOA77m2L2Toxla8vc=; b=GaAwzt3FBM+GU8cUTm0w7vqhRZ0gCaeQLXuFkqEs1ZYCCM3v9S4pRlHox1lrytQZhwMfXGLi/360C2DqGKE5i2P51eMb6gNC6OI9twQ9FehlVlCj+LGydk+NM2CYfmXw/BCXO2iCEqAXZdYYUpC/R5SWmxU2Th+wJB49vl/wG7s= Received: from CH0PR03CA0268.namprd03.prod.outlook.com (2603:10b6:610:e5::33) by MW6PR12MB8758.namprd12.prod.outlook.com (2603:10b6:303:23d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18; Thu, 3 Oct 2024 20:01:51 +0000 Received: from CH2PEPF00000142.namprd02.prod.outlook.com (2603:10b6:610:e5:cafe::19) by CH0PR03CA0268.outlook.office365.com (2603:10b6:610:e5::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:01:51 +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 CH2PEPF00000142.mail.protection.outlook.com (10.167.244.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:51 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.39; Thu, 3 Oct 2024 15:01:46 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:46 -0500 From: Harry Wentland To: , CC: , Harry Wentland Subject: [PATCH v6 24/44] drm/amd/display: Ignore deprecated props when plane_color_pipeline set Date: Thu, 3 Oct 2024 16:01:06 -0400 Message-ID: <20241003200129.1732122-25-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB03.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000142:EE_|MW6PR12MB8758:EE_ X-MS-Office365-Filtering-Correlation-Id: 382d7d18-79b4-40d1-347a-08dce3e63895 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: ZqXDnDBtQjkZ85PS+Fi1AferGkvZWYBTMVs9BMWaL1TW2QI2Oe3H+2sML+drBtSkyzoVb+3JZhbIYGPhlflS0C8qBq+Xd+rGacMnsxjDQT+p60wqCzVAJG38R3mlxHdNDxPlQAZhJDcxMoGUtm2FeI7Zv6X3VywkeYBoJbon0vSeKohiCKP2qrtFotehBkwBYrTj8zFXIvBoVEPdDag0vW20v1NaUtryxiuUdPzwkISF2tTfiLKNXonZ3W/51WBzTy6n9NqwPHXDsKKJLvVV5fBqfXmcaFqg8Es4MrE2ZDzfWMu7eaNxw6tRqLLE5U93guUXtl1nbE7vQVsvGzRNKuoBQ4tSjkLzb1abQMOScM00M+rErkpGq4ciim4Xcfj+b1ZeJAqiId8vFmO4pkulj6tGdvVBhDyMoGV/exnEas5EvM03Vu+l1InGvB1oKUjAttfxJdo35VjvuG01nrfO9wHMvGgdT7N/YCpgRf8l9sCxbsIQ0V8jicRMULxajdwg0YGV16pXflF9DxBhONVz65+WBoQdXGY8efjXhi/dX+jc2rGwZfjh/LZU0KC3Gg78hFBT+Yi1JZX75ud+XxjfleaqU8VckK08f2x2Dzp73QkQ4sfWJPYN/pWtrpqPKRqvRNyb7FfAJ5q0w/wZ3jCjzyaYKRs0A8dwsPGMmuuRk19t3c/8QxLrZi66EMnYxnD+BLmyL7MLtltA/f+o8q6DrsIgGFb8Rx7cZGgb93xFnd+2WxvWEkPCyHKLe9p1HTLH7T2bn0blin/FoShoaZAuch/Q6265vI8uLCZlpukaHDcp8y91bFXT+2fboav8KEPbhwJCpD+EuOC32HntT5xe9K4EPayh9oiO3ggcGnnqMILmgXYM9Zy049cWlUESvnQYW0YZduMRp73lkvPBVmw0NVUf7JfWg7OG2HMUZLqlMSxHJjyzgVEFjKJ/zbbrSvnH9kEEHc5BRp1m5DWGZr1t2JFyXv/4F92MUo3wUjPZNHDAYppfSr8UxRdq+LvpjyDEY3q7yrWC0PwQymdCIzMy8k7lzLZ/Ax5Eqt15X46QStOS5U8qbVxSidU8GaA2t89mcbXEGaxVIPz6kUfPSNqzIMDjUepDQtBZqmnp8fpgCCcW4vf55qCvXcn61LPSx1m3FiRzpv9fTclq+N4viwu1+j5mzipgabr8SizabAZ1j9UP/YrxRjkHBWnFD6vDGNsNGogQSSRjLTRC8OeWm7xk622HBYVLaTkFO0N2qfrZqpaBZCC4lBGPJJtSSVDzDVY7tORbcL/l6sZtZJDdkt9AhxawaJREZg0jsk49Sa3Wr8ayITRy1w7ubq/OEoRR4qdO3zsvVmFHz011jSfvLg1YVpDOFuuG4gc8c/+uCbK1d16Bg/hWzPGwWg1bRfING4MJ 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:(13230040)(1800799024)(36860700013)(376014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:51.0115 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 382d7d18-79b4-40d1-347a-08dce3e63895 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: CH2PEPF00000142.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB8758 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" When the plane_color_pipeline bit is set we should ignore deprecated properties, such as COLOR_RANGE and COLOR_ENCODING. Signed-off-by: Harry Wentland --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index 6e79028c5d78..575eacfc12e6 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -5420,6 +5420,10 @@ fill_plane_color_attributes(const struct drm_plane_state *plane_state, *color_space = COLOR_SPACE_SRGB; + /* Ignore properties when DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE is set */ + if (plane_state->state && plane_state->state->plane_color_pipeline) + return 0; + /* DRM color properties only affect non-RGB formats. */ if (format < SURFACE_PIXEL_FORMAT_VIDEO_BEGIN) return 0; From patchwork Thu Oct 3 20:01:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821514 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 C4DB6CF34C3 for ; Thu, 3 Oct 2024 20:02:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CDEA710E931; Thu, 3 Oct 2024 20:01:55 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="JYrUkhsQ"; dkim-atps=neutral Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2046.outbound.protection.outlook.com [40.107.223.46]) by gabe.freedesktop.org (Postfix) with ESMTPS id DB1F010E92D; Thu, 3 Oct 2024 20:01:53 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=f4PkU75XBRVyq1K+LZJJuziml00H0vrcclyqghorDc4hUDw9he7nYxen7IG3CN/2AQqIly0gaJQSbfFgEgjhFb9nDMm6CXnXgKyWiLpz6+4A3LuXBcPEyfhsvWUIPjYiys5JMk2VPTD5yXhCQV8Xw5l0wa5PhrXFrpuz2rNYyVeyEC70++6DiA8Z67LtmkjM6/grQtAsnLhOYTXg1yK1cDCH/PaliPGralJcLGd21pASFVreObeTEK3Ys6Oh9S0B+hUHiRrOgiCMzvX5UEfSmV274zAuTVXChupt60UbYKGrTCPLUGc7//SdrOkszkPwkEM8OXYBu0+oCiBoqHa3rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=2P0NN1OGUCeMabbtVdaccWSYjnzGFiUdU0g52YAZ2EI=; b=ESPloU6SWu70DTizjSvyBhSxrEnFn+2YsKdgRrnrhbuKfcDaSN5nmJ1X2YJ0Jt86J9br2ErvKtW25VhaKFcI/R8HYxh18vlOcSPirodet53VEKAx6Wmby7BsKSZXMsTjf4y2ZgYnHd24tMfZSrehjxT+eZXBCHzJ1sdjmpbVCkHlOAwY04uOuf6/PYiFCVcHx1PnKgGQLKcjDvb0YH9RUZqbwuVw09c35rGvY4uZfiCbfBzaToURe1yLrIrq5Au1DGY+XzdKoKgm6FO2RmMgHwEVC7bVQ0+UieySUvz16eviVTQ25VjpL8jaoRNCWSgRYAGzzSr7WIDhiITH6+h1Sg== 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=2P0NN1OGUCeMabbtVdaccWSYjnzGFiUdU0g52YAZ2EI=; b=JYrUkhsQoy6CcwT3pdg7m/YGujYURdJj+tjYBLGe3h6H7uo+MQHsiRDderMbiqHCfupaQSJplWh9SJsbwwIibgN9XUTIcbgIvPirfYlnT2omk18pbwSA1JAUoh5OSAfTdkouQtiDBcZkwJ5XlX3rUaT5E07GThUh9DM16+9yNAk= Received: from CH2PR14CA0035.namprd14.prod.outlook.com (2603:10b6:610:56::15) by IA1PR12MB8494.namprd12.prod.outlook.com (2603:10b6:208:44c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Thu, 3 Oct 2024 20:01:48 +0000 Received: from DS2PEPF0000343E.namprd02.prod.outlook.com (2603:10b6:610:56:cafe::c3) by CH2PR14CA0035.outlook.office365.com (2603:10b6:610:56::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.17 via Frontend Transport; Thu, 3 Oct 2024 20:01:47 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS2PEPF0000343E.mail.protection.outlook.com (10.167.18.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:47 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:47 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:47 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:46 -0500 From: Harry Wentland To: , CC: , Harry Wentland Subject: [PATCH v6 25/44] drm/amd/display: Add bypass COLOR PIPELINE Date: Thu, 3 Oct 2024 16:01:07 -0400 Message-ID: <20241003200129.1732122-26-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB05.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343E:EE_|IA1PR12MB8494:EE_ X-MS-Office365-Filtering-Correlation-Id: 38aa3974-cef5-4bb4-03d2-08dce3e636b0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: WBGMd2BH1wxyjHRpq7xvNk4PJU6Gqv/fnqcp8DF3N8V9g6Xl7Hd502WCTUw4QlTayDzl4q5+9j2roCwX3T1XYcdBWBPrnwZIKKTWlhXywk1ol/dBRSdd4L5aoCENyUEn6I8s1GQg6yxti+brtAgzjZbYn4sBDydJWczDHULCDXrYb1lBZ56y/OqXtEbUUGyjMv7ux+ES/N/lOo5mawgRl6q/aCrAHViiFiFiivKoWNrjg2kCehQEv2zqwEUbRo5nwKhYaNa9pU0/rkNT4DmV3svapXMoY03/Rbwz1Vl1cHFUUqKlrndxqClP6kym2cxsIsVtutQYzR2vQYP7hh+JHmhvjQvNkuSgOZszr93B6xQpX7TGwG/RyuRiQ6BiO73oTT4J1Y7DrY6XrGStYEJyxpzuZ25Y08WKseteBvyYAjLMVpYJvKsNLP0wgKzDrJ/ohCQ8EZCoAewC4YTPZNa6etr1snG8whB1Tqe8a3tNSEq9yip5XjzNDxKX8b+tjno+EnSy26DsvxfAXDc3ffDsMk6L3ggTLpYNqq7sMJrPY/IhTdJa02W1z1AJWaPGhVJ/Yor/G6Q9VLqHaof68m4wi4peXjccroOBBJFhyZySDpdqZVW+DOUinN6AKRdOsqKwPcQfjvsz5xzM7gwmsAOU9xPXsAuc0kAjivi1cyMkFuwRc11ysKd+3hIg/9qJpfyVsvk/ECTJk+OdFMo0NkFyYXleoO4AOvn6+2LJPAlSkEy+wdkfIGgCXJRVadIw4ScHWnPq0uw+V6o7B6fbZOcZW+srybyMe9Gh1uB9Mwz/mTtis9go0wUbkffCvI0itGhHyOFVvoLM0UUfcumC9/7dcuP0zNbLT7Kkz3JMhHckem0ULaxwUMJ4OhmRGJNN2x1hgHJvS1a+2huAncn+56dpNER3ULajg7m6izpzx52KHrd5R8/PBRoE6NN40PdsYnfVveS6qIVEHoXzWqOicn0fxqYuPK3iJNjnB8QbbkQQe6orj5hjEJo26CfdC7ByEN4fr51YTPKXP31yPkd1hjbp+vxgzZl4ESC/29qp5SJBuobAX8SpN/FuPXp1+AnTUVovOVbKSNsfT//VXjHj39CpikC3wT7xJKH36YxV6gwLgXvQkdAr84Ei4Cm8472SW8eB/w9HPps2bKAvO8C7X/c4mw40sLmsKlIQfo/V92V1JB276RZWEqUC/0vK8wspNwAgE+HAc+pNMjposSRCH5BNAKnqA+enZ+zvtoEsKhdcEiK/3Fhmh8HinOFygZAT8Oc6SmLqe+ZUq7HPIug2a+/1XsNAHzUvECItz6g1IhvDYexMTyZV1NORhkN/hNVkycIzp4ZO/RLaHn4VJNYwuPTSmQN763H894C/pomFi4MMp/XO0M9WqdYCPIt7i9rox+9v X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(376014)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:47.8006 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 38aa3974-cef5-4bb4-03d2-08dce3e636b0 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF0000343E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8494 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" Add the default Bypass pipeline and ensure it passes the kms_colorop test plane-XR30-XR30-bypass. Signed-off-by: Harry Wentland --- .../amd/display/amdgpu_dm/amdgpu_dm_plane.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c index 495e3cd70426..22ff9a31b592 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c @@ -1756,6 +1756,20 @@ dm_atomic_plane_get_property(struct drm_plane *plane, } #endif +#define MAX_COLOR_PIPELINES 5 + +static int +dm_plane_init_colorops(struct drm_plane *plane) +{ + struct drm_prop_enum_list pipelines[MAX_COLOR_PIPELINES]; + int len = 0; + + /* Create COLOR_PIPELINE property and attach */ + drm_plane_create_color_pipeline_property(plane, pipelines, len); + + return 0; +} + static const struct drm_plane_funcs dm_plane_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, @@ -1859,7 +1873,12 @@ int amdgpu_dm_plane_init(struct amdgpu_display_manager *dm, #ifdef AMD_PRIVATE_COLOR dm_atomic_plane_attach_color_mgmt_properties(dm, plane); +#else + res = dm_plane_init_colorops(plane); + if (res) + return res; #endif + /* Create (reset) the plane state */ if (plane->funcs->reset) plane->funcs->reset(plane); From patchwork Thu Oct 3 20:01:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821536 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 68973CF34C3 for ; Thu, 3 Oct 2024 20:03:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 60E1110E994; Thu, 3 Oct 2024 20:02:09 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="SeUKz8oX"; dkim-atps=neutral Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2083.outbound.protection.outlook.com [40.107.244.83]) by gabe.freedesktop.org (Postfix) with ESMTPS id AA74C10E987; Thu, 3 Oct 2024 20:02:03 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Wto5XaqN/2FLWkflJDLHxGfx3tyJbVEcL2DVxTjTCYIatEvrIKsDjBOT9PR3H8WyTqIN/NCKJGkJXg05VpSTWLiyXWyIMLZFj50rws8crMNoyCtcOql4LlCDzIA8ayE1KEm28LOGGHWSvZcKR3wPB7kEjyEWEqujqVnTJDcZjBfHafLyUA+DV5BiXLeHhSBaEpVwnUrZzItTnMuojGhv6eKAyHjTT0DDbzkwDPqfwIwVxXwls3/bFstj97OxYZ66TTy3e8QERnRp926IrVRXlB0RqKVzBHpfT9mMKITGdWm1SH/RzJTlM5dyjfW6oqZS3JZo3eNKDyAakJXzwpsJpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=jvwBTJgIkNXhzm9B2nuvATeqv1kkbfKKPkeMFHvymBE=; b=jV+NhZbhKKWQ2p/fpQKYGDryK5XYOgXpfkgWmk+1TTZ+Dib+MUo5CIYVjzYkzhGyRTzQsDBpK+JJD3mb8wno6qDLXYvIZz5kbZ23gzy6qSTjB9pqyNg2B9xI18BhA0+05uzWepgN1V+noQk5G1y7NnV+Sm0BxEqry13iVN+ueW2/b4OhiZIM+Dmvz9vNGySsi5ovfCEMCGayHnNyEjlUNrUg7jTx34/h9h9Shhnj0VGnHHJAzvDGv4qRIP+uKm/uWfaYM3Kr9JIwtthHq4yDVIKIPBiorm/AYI0dX8zvJF0cgc/KuOQZmlZPVBR1fxDXtc9zEICETOMFJw0yIlnTew== 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=jvwBTJgIkNXhzm9B2nuvATeqv1kkbfKKPkeMFHvymBE=; b=SeUKz8oX0CvEYgmP5nHgHzyOYNLVh/bLl6zTDIX9GAU26jZsZjRqvHOu8eeTIhG8XvwgHWgBm/0x4i9i2dwo/f10pUcy4aEWwPDHtHBedI08IPdAJlpSd7JDKOZYEAiBsZNTEZhKy0WlQ6Quo5w9FJPQyPwo6kQPRR3QCushodk= Received: from CH0PR03CA0249.namprd03.prod.outlook.com (2603:10b6:610:e5::14) by CH3PR12MB9430.namprd12.prod.outlook.com (2603:10b6:610:1cd::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Thu, 3 Oct 2024 20:01:52 +0000 Received: from CH2PEPF00000142.namprd02.prod.outlook.com (2603:10b6:610:e5:cafe::3e) by CH0PR03CA0249.outlook.office365.com (2603:10b6:610:e5::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:01:51 +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 CH2PEPF00000142.mail.protection.outlook.com (10.167.244.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:51 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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.39; Thu, 3 Oct 2024 15:01:48 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:48 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:47 -0500 From: Harry Wentland To: , CC: , Alex Hung Subject: [PATCH v6 26/44] drm/amd/display: Skip color pipeline initialization for cursor plane Date: Thu, 3 Oct 2024 16:01:08 -0400 Message-ID: <20241003200129.1732122-27-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB05.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000142:EE_|CH3PR12MB9430:EE_ X-MS-Office365-Filtering-Correlation-Id: 43782392-ca60-465e-082b-08dce3e6390a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: Rj5H+j639gqChrSwElkKNMMnMHh5/N8JLK8FLZma4O5UboVwUYnAB2KoEsHdS9AZ8Rr2Wu0bgXuV8n5zl6TZODnmGaJdsF43CRK+bgrtKhLWZrbwhJxhDwjGW77EVOZb0zpFjMBDyZ8iDI2vW7wZTWghdvRgglG4ZikOQyot70PGd3VCb1Kvxm11IEk7ypa4J1UnEuXYJIzx4nvIxlONYSO7BMpKuUAXyQCix8Ggxik81hFjaZA9k2a+lrMqlMNBB1/aK5kU/HGGf/p9eCpS7Oi2RkJ6DlPqsJAWK0WYBhpc+hciAaqlivMc91c8ndcU2gJljAT+i0XkXcp+XLwVeZJrMrP0hsz21hDbYQMKthW3XNDpKGcjxcpqLtpJP6L1V5eSodTA/J7fAB+49MN0yFM67RNxVZClTgT4Xbzsvw5t3K5SM9UGcB2sblP3J6sKwtNYcFgBPqZCa2uL/FcN0cPbTJxQmz9PzoEKquAyiVHsML2IE+k0vqAqYiC0JZ16XHcprx2kYNwGb9X8ya+XBuYqy4cDmHzan4xEcEwqfdoUncJcJ0xME8GGGUV2/1AlvPx+EZOa3mphJ/OEJdiskFqlZHuiIAIYS6aTsSV7fWLJqk1qZhStrrEskF2lnmMpOl5244rnt3WEi0Fkc68S1YIHHLRjESebh7+/vhCWyJ+8kMLh2EoblND1KYHbJLIbWqB1NxC+GSgGtWKt1DUsqLhQ1rPcF/LKYUI86P5d3oaHatt7R9o9eEXo5SCsECXflJesPk0m2ZlM66lnbrwcYUIwwGOoPzC+sW2Cw8Nnyf3ezMwSUcHts6xzbJSPJFM0DKzpOpH+HyU8fY84+jy9T8Cy59piLmbjuAZW/RneBJOSSRZXisd/2A+i14+yf/z/iPCtOc632WW2qto9HKcTW3XUfJjkPh3an3eUjKPta8JnauFOdgXf9GY40w1Mu4BLUqvfV8o/mGDGS+ztYsuNwrchLw9ZF45gvemy8AtZfuCPoYETjdbr/EV7WhJ4VNrvvl6L79OdFx24CcA88hwQ/+KwRGyGET+w/bhIGz2EN/MGBahznlHkE1dCB24PQbHR54tTorWCH2MThpPQe4Y3XDgnjJZp4VYvoWBrhsnK8sXAKrWqO9e0I2nApX0jYcII31ezE8B3iq/vRuggfNJLfpY3cz79uW3h6piTfjKk1cV2mYjmlKUbZrjtlrB7DXUAkRBLeAgGMfRbifAe7W0Cqzl6v0WMCnOjnTz8IduB2gvooU1TCR6la8vTGID7gnk6imo+k+1h3FN2IOzLfDzQRGufJSOUNmZK68KRRZOnxso4PuiKtB+Bx7ssN2WgY8ZJVb46iQc7Fopo7lxT7JJyeN5r6k9KVGlScDpnQDDPVwiK66QHdNWCzzKgQBnq2bpS 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:(13230040)(376014)(36860700013)(1800799024)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:51.7772 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 43782392-ca60-465e-082b-08dce3e6390a 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: CH2PEPF00000142.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9430 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 Signed-off-by: Alex Hung --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c index 22ff9a31b592..1bfb9f340c24 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c @@ -1764,6 +1764,9 @@ dm_plane_init_colorops(struct drm_plane *plane) struct drm_prop_enum_list pipelines[MAX_COLOR_PIPELINES]; int len = 0; + if (plane->type == DRM_PLANE_TYPE_CURSOR) + return 0; + /* Create COLOR_PIPELINE property and attach */ drm_plane_create_color_pipeline_property(plane, pipelines, len); From patchwork Thu Oct 3 20:01:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821529 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 70409CF34C5 for ; Thu, 3 Oct 2024 20:03:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7214C10E97F; Thu, 3 Oct 2024 20:02:03 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="netLFOyW"; dkim-atps=neutral Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2062.outbound.protection.outlook.com [40.107.243.62]) by gabe.freedesktop.org (Postfix) with ESMTPS id EE70D10E944; Thu, 3 Oct 2024 20:01:55 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iC4PpH3WwtIJ+GmG78MRiYyNWjwzFYvaUfLllXd/Z9Gh3+PNeQKjxzoFOU9aSZ2IeVfbFP6yLiw/tkCuQfc5tNFNExdoLADfSeNkyQQnHWvbprCu1grwm3F9+Oib76vqdGnbRekNbIhz30zIKVqDjYaTRuhLVbgwXkCouSNB4Wx48Vps7z1L3Ug21Dftfw3o40JyZWS+x+EZAb3AJ8hXq+RsaZQ14DcdqdjObwMLx5nn/PTNl2rNaDVdb6ddeDxM/+tgvQqS5X4vTGbs4NoM7eZDglmZzjGZYqGoCo3K56MsHq0pVI9ZHbfP+bMkG6k7EHbtS+sMu5SFR2zxUP0mhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=zz2T/towOpHElCA0E1k7JI+pJV1DUeILq1fMdY4fqFo=; b=I+jUzg7UnhaMVYN/ejkLykWk2dCg4hlT6bZ6V+zrln0gar4uoUNUhFeGtnYoOYGLGYQa16atEU9ufFNgCpknj1/vhq+2nigXCHKC8furqbNu9AND76j/KlRKdPGsvLUVicT/dINmV/n8BApwsV8G8NL7wNKdoUvSUlAb4iFeZcdFiM4DZdvYqDupa5c6bAysZmogPUsdbHmBzVjMqvuYrcU2eUNGr8ci5H1WfwRuFivFH8FgEMJskltzm5PZ5HyxNNEYi/SFg6vdM/6Md8df1uPm1AE7Cp6TBao3blj9kK2n98lY6I1eeerW6Gvg0HwppuFhSNc1zS0om/ataS86Zg== 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=zz2T/towOpHElCA0E1k7JI+pJV1DUeILq1fMdY4fqFo=; b=netLFOyWdA8mAaHHKqsdUZGTkSVXFSkKtIxvEkKe/Bj4M42WIsp0qvlMM4TTskr10scO7K/L8N4UezRVMfA04XjoeeIWZM7MuHxgQiMHMbxGrQTfWFMboOGvnyV2JLSri4imexsmImjshUbEoLcL5szWQRh7OIvOiJl3e46Ccss= Received: from CH0PR03CA0253.namprd03.prod.outlook.com (2603:10b6:610:e5::18) by IA0PR12MB7774.namprd12.prod.outlook.com (2603:10b6:208:430::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Thu, 3 Oct 2024 20:01:53 +0000 Received: from CH2PEPF00000142.namprd02.prod.outlook.com (2603:10b6:610:e5:cafe::d3) by CH0PR03CA0253.outlook.office365.com (2603:10b6:610:e5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:01:52 +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 CH2PEPF00000142.mail.protection.outlook.com (10.167.244.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:52 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.39; Thu, 3 Oct 2024 15:01:48 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:48 -0500 From: Harry Wentland To: , CC: , Alex Hung , Harry Wentland Subject: [PATCH v6 27/44] drm/amd/display: Add support for sRGB EOTF in DEGAM block Date: Thu, 3 Oct 2024 16:01:09 -0400 Message-ID: <20241003200129.1732122-28-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB03.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000142:EE_|IA0PR12MB7774:EE_ X-MS-Office365-Filtering-Correlation-Id: 64e6e511-918e-47a8-7985-08dce3e6397c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: 8o0vRFvLCBiZk4PPbzjg4GMsj70BnyedMBy1Mk6ENT8rpH7aPUzj7AzPqC2uFeixjW97e+cb34ftEIbbZkJ1svjiYJyB3GoU1YZAjLvjCdhfkXS4mWUDnrxHwOVS0RDyQ1DPt5EmfetMmlzk2W66TLIiMNoRgdsdNKgXJ8KSuCSCYFTRKGvW6f7Q4wdGvKrG5CjKVAkvDhhJDFBqTTwK6VGIF1O/WWhv8vCHurXVrDoJSWnj2i1KuOhVCtw6xXtnwBq0H6QMB/eU5SRVBb5WdWWDL2q5jaoZXHwjq9qxzvAYzHkRdxLPEAU52TQB4z0JlcCU6MBFRv75wiYXhUVURsU5j1lyR/GCL7zLhfDSfWWIoyix4r1IdvQGagZAXxGOWe1oNcFcdhB7Ga4nEVL5ApJDhK16DYRzhEUKPS/wNr0Lc5aK0Fbk5ql/PDoeHPAuG60YBoQD3Qh/W0k3FY07m9mFPACdW80Qy4BdTfpfbH0UViWxYmqmaZ1c3zrLRGEseB5NQKzeC3Ok+F7Uukt2j9+h6Kl+cNRKqEglzAO/5ufY/e50ezP0vHlfMoa0h4l756H/SFmmwgyJrTXlwdA3EB7eeqt2oDtRsZEnxOXI5l+sHsHmlR7jKADsRj+HxFr/4xIJ3/b2muKi8Z3b1r6vh4OvcBsaOvx9gn3u6uel/R1RHPRsI00ZtBO+180c0oTIFBWR2gEPbMa3VkYL2Qy9Rtltaif//hONVcTz/+RNbHJzJYIX1Bz8X8kMcBPFUT6PGN/WvbaEkB+omshJiNbtZvOs4VC83IvRXNHOinh07RO1plXmAyBGYEBUSNjJ3R9ByHn5qV+DVIyouFDpcVZMG6LJDaOpbEDCul6R2GW9OsAv3XzgABJqXSTJ8Bsqy5nh0CaNJr/6sU1tlBnE0kCK0Z4bCOh5p8GZ/78v3oNURcvufh07S07HU4/jrbY639yNyeAvHKIqTjMliDcuaokU/eQF2/vhaz2GbNEY2EYM3ptgMwT8nStwEnbCJRad+dho27Ngit076UgmPNUiGEmov1k0q3yjeek+m/pO+rAJpsbxNq385BgZo1tSDpBKVS7powpisFJjAACZUCbP6wHGMEPP8yVXASxuQfgnXVkNyZpQcdqyPP2mgsqjnXeUIwYZchAzMPuLURkwOaiyzO8EsFXXynbxY1LYRXGNjuUKrNMkyFnYsyjhv2KLdYBWcZ8SdQrmeuteuH6tHQQGaz7LQ4ZMx9JKqy7kLWAQygXVeHnSdlr06pV2MvCa5PxSaCKjXS0lZfk3ilbNNWtKqhLnAdD4+hZyyhRqpqa1zHMhfO9+WMFIZpPII9tbq4V1akiIpd+jGagZsZZzMhOhAK9YXzNdpqqL2s8ZmAJhwSv5ymbTAVh60n94oAUfjzuplVCC 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:(13230040)(1800799024)(376014)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:52.4803 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 64e6e511-918e-47a8-7985-08dce3e6397c 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: CH2PEPF00000142.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7774 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 one 1D curve colorop with support for DRM_COLOROP_1D_CURVE_SRGB_EOTF and program HW 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 The color pipeline now consists of a single colorop: 1. 1D curve colorop w/ sRGB EOTF Signed-off-by: Alex Hung Signed-off-by: Harry Wentland Co-developed-by: Harry Wentland --- v6: - cleanup if colorop alloc or init fails .../gpu/drm/amd/display/amdgpu_dm/Makefile | 3 +- .../amd/display/amdgpu_dm/amdgpu_dm_color.c | 88 +++++++++++++++++++ .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 71 +++++++++++++++ .../amd/display/amdgpu_dm/amdgpu_dm_colorop.h | 34 +++++++ .../amd/display/amdgpu_dm/amdgpu_dm_plane.c | 10 +++ 5 files changed, 205 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.h -- 2.46.2 diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/Makefile b/drivers/gpu/drm/amd/display/amdgpu_dm/Makefile index ab2a97e354da..46158d67ab12 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/Makefile +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/Makefile @@ -38,7 +38,8 @@ AMDGPUDM = \ amdgpu_dm_pp_smu.o \ amdgpu_dm_psr.o \ amdgpu_dm_replay.o \ - amdgpu_dm_wb.o + amdgpu_dm_wb.o \ + amdgpu_dm_colorop.o ifdef CONFIG_DRM_AMD_DC_FP AMDGPUDM += dc_fpu.o 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 ebabfe3a512f..adb1e4b3522d 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 @@ -668,6 +668,19 @@ amdgpu_tf_to_dc_tf(enum amdgpu_transfer_function tf) } } +static enum dc_transfer_func_predefined +amdgpu_colorop_tf_to_dc_tf(enum drm_colorop_curve_1d_type tf) +{ + switch (tf) + { + case DRM_COLOROP_1D_CURVE_SRGB_EOTF: + case DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF: + return TRANSFER_FUNCTION_SRGB; + default: + return TRANSFER_FUNCTION_LINEAR;; + } +} + static void __to_dc_lut3d_color(struct dc_rgb *rgb, const struct drm_color_lut lut, int bit_precision) @@ -1137,6 +1150,59 @@ __set_dm_plane_degamma(struct drm_plane_state *plane_state, return 0; } +static int +__set_colorop_in_tf_1d_curve(struct dc_plane_state *dc_plane_state, + struct drm_colorop_state *colorop_state) +{ + struct dc_transfer_func *tf = &dc_plane_state->in_transfer_func; + struct drm_colorop *colorop = colorop_state->colorop; + struct drm_device *drm = colorop->dev; + + 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, "Degamma colorop with ID: %d\n", colorop->base.id); + + tf->type = TF_TYPE_PREDEFINED; + tf->tf = amdgpu_colorop_tf_to_dc_tf(colorop_state->curve_1d_type); + + return 0; +} + +static int +__set_dm_plane_colorop_degamma(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; + + /* 1st op: 1d curve - degamma */ + 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 (!colorop_state) + return -EINVAL; + + return __set_colorop_in_tf_1d_curve(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) @@ -1187,6 +1253,25 @@ amdgpu_dm_plane_set_color_properties(struct drm_plane_state *plane_state, return 0; } +static int +amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state, + struct dc_plane_state *dc_plane_state) +{ + struct drm_colorop *colorop = plane_state->color_pipeline; + int ret; + + /* 1D Curve - DEGAM TF */ + if (!colorop) { + return -EINVAL; + } + + ret = __set_dm_plane_colorop_degamma(plane_state, dc_plane_state, colorop); + if (ret) + return ret; + + return 0; +} + /** * amdgpu_dm_update_plane_color_mgmt: Maps DRM color management to DC plane. * @crtc: amdgpu_dm crtc state @@ -1283,5 +1368,8 @@ int amdgpu_dm_update_plane_color_mgmt(struct dm_crtc_state *crtc, dc_plane_state->input_csc_color_matrix.enable_adjustment = false; } + if (!amdgpu_dm_plane_set_colorop_properties(plane_state, dc_plane_state)) + return 0; + return amdgpu_dm_plane_set_color_properties(plane_state, dc_plane_state); } 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 new file mode 100644 index 000000000000..c0134e8cf2e5 --- /dev/null +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c @@ -0,0 +1,71 @@ +// SPDX-License-Identifier: MIT +/* + * Copyright 2023 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: AMD + * + */ + +#include +#include +#include +#include + +#include "amdgpu_dm_colorop.h" + +const u64 amdgpu_dm_supported_degam_tfs = + BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF); + +#define MAX_COLOR_PIPELINE_OPS 10 + +int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_prop_enum_list *list) +{ + struct drm_colorop *ops[MAX_COLOR_PIPELINE_OPS]; + struct drm_device *dev = plane->dev; + int ret; + int i = 0; + + memset(ops, 0, sizeof(ops)); + + /* 1D curve - DEGAM TF */ + ops[i] = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL); + if (!ops[i]) { + DRM_ERROR("KMS: Failed to allocate colorop\n"); + ret = -ENOMEM; + goto cleanup; + } + + ret = drm_colorop_curve_1d_init(dev, ops[i], plane, amdgpu_dm_supported_degam_tfs); + if (ret) + goto cleanup; + + list->type = ops[i]->base.id; + list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", ops[i]->base.id); + + return 0; + +cleanup: + for (; i >= 0; i--) + if (ops[i]) + kfree(ops[i]); + + return ret; +} \ 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 new file mode 100644 index 000000000000..f16de6a9fbde --- /dev/null +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.h @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: MIT +/* + * Copyright 2023 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: AMD + * + */ + +#ifndef __AMDGPU_DM_COLOROP_H__ +#define __AMDGPU_DM_COLOROP_H__ + +extern const u64 amdgpu_dm_supported_degam_tfs; + +int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_prop_enum_list *list); + +#endif /* __AMDGPU_DM_COLOROP_H__*/ \ No newline at end of file diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c index 1bfb9f340c24..78c749ce1bd0 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c @@ -36,6 +36,7 @@ #include "amdgpu_display.h" #include "amdgpu_dm_trace.h" #include "amdgpu_dm_plane.h" +#include "amdgpu_dm_colorop.h" #include "gc/gc_11_0_0_offset.h" #include "gc/gc_11_0_0_sh_mask.h" @@ -1763,10 +1764,19 @@ dm_plane_init_colorops(struct drm_plane *plane) { struct drm_prop_enum_list pipelines[MAX_COLOR_PIPELINES]; int len = 0; + int ret; if (plane->type == DRM_PLANE_TYPE_CURSOR) return 0; + /* initialize default pipeline */ + ret = amdgpu_dm_initialize_default_pipeline(plane, &(pipelines[len])); + if (ret) { + DRM_ERROR("Failed to create color pipeline for plane %d: %d\n", plane->base.id, ret); + return ret; + } + len++; + /* Create COLOR_PIPELINE property and attach */ drm_plane_create_color_pipeline_property(plane, pipelines, len); From patchwork Thu Oct 3 20:01:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821519 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 13EDDCF34C1 for ; Thu, 3 Oct 2024 20:03:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 592C510E95B; Thu, 3 Oct 2024 20:01:58 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="0BQCL7RL"; dkim-atps=neutral Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2046.outbound.protection.outlook.com [40.107.236.46]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4B05910E931; Thu, 3 Oct 2024 20:01:55 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZmiWVaZMFS+NpcdRbel0cXdqBrqjj42so9Jqo7fxSp6IuiphCFgUs4em+P16eUcQKW7PcVLexNRlc1BIZ5ZXnqIfA50gF9eiqeyed0UKCx52oFvm43Bl5GS8K8tw7KDUpZnhXaG/PoNQTFwtMBXnLjn5gPlmHgLbe895L1QD3ioYUOaZyDe/WCEIEdlh3fxKADtZyybDTRTVoniMyXXs++VGwZSDtlgHUqYgb93Dt1CHhugooFVrhmed9zdpIza9h/0bOv0nB3AMOyUdxDzh3T2Q1Il5yj7AECr2PlKC4O2lH4LdajCIwQMPQAw7wdjaQfyrd45Z/2pJ2gSsdID1eQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=3uuj3Gq5I+T1RYlsQduEeBUffN6lFLBUibY92Flsr38=; b=l0rbIckzd5WnCyue3DQpm/Qpx/VIRHsk4w709qHczK1sg2zUmihYKQQSzgHyBJZ3+VSBBzr/vpLtuuxqdztpdz2Nnj3VTGF8k4zlIrdEmFY+JIgTVEf6w//ONasGIyAuml6xdejavFYb+gwA+eAHe5MTjZ1rVyHKEXPUE3FzQpRCjDTbTRKNp5jiK2p0R1GwG4OyGUZ4NDIQ2y1gNk2Wx3pMQ2+JTuaF/8uo8Ip1ALJPtWLNFQjg0yre13jzlY/aAxdu1aA2rrfwguadVTIS2YOewmLOJj2bQ7lvpjkuT46xiL0awiMraxX8qZFuaRpr1JjYJwibOUsGUdBJxFrEKg== 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=3uuj3Gq5I+T1RYlsQduEeBUffN6lFLBUibY92Flsr38=; b=0BQCL7RL4uhIv4ZTLKkuZ4DeLs6ieTnQ3/tITY6QQ32uDtqLcEij4XV95F5oXkI2gjMeuiRP1Hh/MSmPYPMIeYUSKwCnBUiDiRPhFPo647nruIcGthf0axa7KpwYjnpEOdc5pbtGT0A2Ka3yZsh81EHj5591a6IDi1LNYhHGCrM= Received: from DM6PR04CA0029.namprd04.prod.outlook.com (2603:10b6:5:334::34) by MW6PR12MB8865.namprd12.prod.outlook.com (2603:10b6:303:23b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Thu, 3 Oct 2024 20:01:50 +0000 Received: from DS2PEPF0000343D.namprd02.prod.outlook.com (2603:10b6:5:334:cafe::19) by DM6PR04CA0029.outlook.office365.com (2603:10b6:5:334::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.17 via Frontend Transport; Thu, 3 Oct 2024 20:01:50 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.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.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:50 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:48 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:48 -0500 From: Harry Wentland To: , CC: , Alex Hung , Harry Wentland Subject: [PATCH v6 28/44] drm/amd/display: Add support for sRGB Inverse EOTF in SHAPER block Date: Thu, 3 Oct 2024 16:01:10 -0400 Message-ID: <20241003200129.1732122-29-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343D:EE_|MW6PR12MB8865:EE_ X-MS-Office365-Filtering-Correlation-Id: d13f9ccc-bd3a-4315-21e3-08dce3e63801 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: 72CGCKh5oX0kiEiBUCFEvM0K6LafCWP2tG1+KOa9bJQ3nul6Tkr1DYQfJ5EtF+uc/VkYh9OmDKNFB3MpDrxLFlm1XgpUuyCl3r/ohx+/445z8L+s0xheuare9ff5vur9fTVmnqIqxM2zGDlucr34VO7d3rr6Ej6Qkxm4KNxPAOjIwzMENtboWIPy9rOZEiigknxMW0kP112fTY1eYF7H7X6t5ALWMI2MRNK80amCfkKXFhVeQSZMPonK/0CU0o7yvNFjPul/hdis4HCHfxQ8k9sOiLuuAWiEQt6SC4h7kF8FiavsRNnT7uVeMVaH+mzJEtI3ECqoU1SoUs/j9+x8UwQX55SiwpivTqxtGRbgyPVJDjoULZyZvlLLGPgl21u67mD/x3A5Y6se7L1dBXS6fD2TgjO1xB7u6xp19e9Vooskln8c3BBmRU0g+MNO4AwshzyhmrRJqCMiO7KUjC9BdJbb2zVbJciFR3J4xSaPyjnMdy07ucN653eThCJv/K3NUxZ1q7h1QMfHSww2oh+SylZ47bSIoJJT8H4FGOE/W5XG806CcpS6l4uEQ9oXWosQp/j/aPDDOhNdLY2iCjr1m8vGgxETpqWKjgh8LGH9hZ+inhbBhHz3QER3aUB9og38Sbv4t36EsQindbtz+xri57ewiMDtmhmiNYxW/SS6XeY8g33p1BtKLse6PO1re+V3zDLh15vsgVvdn/YOj4BWxYS8v8ANUtmH7RvhaV085BEb1siQMYR9TTngp5LFOxbmaxAzcX+3mWGGTXaEC8apqrAZf3APSkRHjCZYJ68XWlWQM2AeaMTYmXR3XYbbZqEhzxGSMyC3Ur06OQ/99GDwrT+zMY2gQmBesBCSZfQRN276bNUobBh6sTjhelcwxstlnP7fhkQFOPhyoeHGd5S56QAqDvSu35fIzWK1OeYPcaci+qgPHnJdyAvenS9gwnHVnN1aZH7XE3qhINJRnLtDgUC7Zhe0bm0XCap6vAzGrxmRAa35GOLq6RCS6PF/SjeH6LcFRQdwrjf6c4WeGRH1lEywIzDC3LnfvhBxUpGIzPkIwR1tWc81S83h+h3pjcBkmY4A5/gtHpwO3xh4rqtkbvA5N19siZN8o27ie4/IrzSCc21IxOCAczabyEmqwLRDnVU7rz8Kf4AtFFIwvy1DXWPIJAUvL+TfYEp1Ig2j51h6aPGeI0X4RzcphEiNMJikWpEJpU+q86nvwRGB5bh+wxrsnUJtLA+fXnW3iUEER2EWRJUn7sBiqkqgluYIix+bDCrjAdx5TVooiMG0Rd/FbdNoh7GYZfxYo2d5zEBsWaBJeJWSzeZNFHTE5R1Ua1Vo01OckzrenRwMAB9ED0jBPLVZyCUUnRzKdz2Vwz0ahWC1JhAgtVCXr74v5Fgq7aiu X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(36860700013)(1800799024)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:50.0099 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d13f9ccc-bd3a-4315-21e3-08dce3e63801 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=[SATLEXMB04.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: MW6PR12MB8865 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 2nd curve colorop with support for DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF and program HW to perform the sRGB Inverse EOTF on the shaper block when the colorop is not in bypass. With this change the follow IGT tests pass: kms_colorop --run plane-XR30-XR30-srgb_inv_eotf kms_colorop --run plane-XR30-XR30-srgb_eotf-srgb_inv_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 Signed-off-by: Alex Hung Signed-off-by: Harry Wentland Co-developed-by: Harry Wentland --- v6: - don't pass uninitialized variable into __set_output_tf .../amd/display/amdgpu_dm/amdgpu_dm_color.c | 74 +++++++++++++++++++ .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 19 +++++ .../amd/display/amdgpu_dm/amdgpu_dm_colorop.h | 1 + 3 files changed, 94 insertions(+) -- 2.46.2 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 adb1e4b3522d..d67f88340b6b 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 @@ -1203,6 +1203,68 @@ __set_dm_plane_colorop_degamma(struct drm_plane_state *plane_state, return __set_colorop_in_tf_1d_curve(dc_plane_state, colorop_state); } +static int +__set_colorop_in_shaper_1d_curve(struct dc_plane_state *dc_plane_state, + struct drm_colorop_state *colorop_state) +{ + struct dc_transfer_func *tf = &dc_plane_state->in_shaper_func; + struct drm_colorop *colorop = colorop_state->colorop; + struct drm_device *drm = colorop->dev; + + if (colorop->type != DRM_COLOROP_1D_CURVE && + colorop_state->curve_1d_type != DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF) + return -EINVAL; + + if (colorop_state->bypass) { + tf->type = TF_TYPE_BYPASS; + tf->tf = TRANSFER_FUNCTION_LINEAR; + return 0; + } + + drm_dbg(drm, "Shaper 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_output_tf(tf, 0, 0, false); + } + + return -EINVAL; +} + +static int +__set_dm_plane_colorop_shaper(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; + + /* 2nd op: 1d curve - shaper */ + 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_INV_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_in_shaper_1d_curve(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) @@ -1258,6 +1320,7 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state, struct dc_plane_state *dc_plane_state) { struct drm_colorop *colorop = plane_state->color_pipeline; + struct drm_device *dev = plane_state->plane->dev; int ret; /* 1D Curve - DEGAM TF */ @@ -1269,6 +1332,17 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state, if (ret) return ret; + /* 1D Curve - SHAPER TF */ + colorop = colorop->next; + if (!colorop) { + drm_dbg(dev, "no Shaper TF colorop found\n"); + return -EINVAL; + } + + ret = __set_dm_plane_colorop_shaper(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 c0134e8cf2e5..3afbac6c4e2d 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 @@ -34,6 +34,9 @@ const u64 amdgpu_dm_supported_degam_tfs = BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF); +const u64 amdgpu_dm_supported_shaper_tfs = + BIT(DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF); + #define MAX_COLOR_PIPELINE_OPS 10 int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_prop_enum_list *list) @@ -60,6 +63,22 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr list->type = ops[i]->base.id; list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", ops[i]->base.id); + i++; + + /* 1D curve - SHAPER TF */ + ops[i] = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL); + if (!ops[i]) { + DRM_ERROR("KMS: Failed to allocate colorop\n"); + ret = -ENOMEM; + goto cleanup; + } + + ret = drm_colorop_curve_1d_init(dev, ops[i], plane, amdgpu_dm_supported_shaper_tfs); + if (ret) + goto cleanup; + + drm_colorop_set_next_property(ops[i-1], ops[i]); + return 0; cleanup: 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 f16de6a9fbde..c4b1b187e9bf 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 @@ -28,6 +28,7 @@ #define __AMDGPU_DM_COLOROP_H__ extern const u64 amdgpu_dm_supported_degam_tfs; +extern const u64 amdgpu_dm_supported_shaper_tfs; int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_prop_enum_list *list); From patchwork Thu Oct 3 20:01:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821518 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 83E39CF34C4 for ; Thu, 3 Oct 2024 20:02:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DB6E310E951; Thu, 3 Oct 2024 20:01:57 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="PSvV6vuk"; dkim-atps=neutral Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2074.outbound.protection.outlook.com [40.107.236.74]) by gabe.freedesktop.org (Postfix) with ESMTPS id DC67210E93B; Thu, 3 Oct 2024 20:01:55 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eUZb/o+9ru/wL+j1lKzooPWrchdvKyR9jsG01O4hW+v9SpK17/vzqay2K8zp4q6jWGIX9c7jSRJGvwudAhZTjauUv/Za7wGu7mmlGOHf3cfMuAdwftQzGjvScp0sFChn/Sfk/ouBbo3vhIobsOnX9Xi9LLEH5Soiwsc2XWA3NH3zVf8jg00tRs0r9HmpZNXCFGsRZ37ZRsVKTEVnWVhtLbv/WMRxWky2PGHX8TpZQSYhATBxg0NibGNJOyDMyEqcP7azXecZeH4xvwqvmVL4WptmmlW+OqtrHzjf8wC6XJZJ9H+ZSMKeMYRddRRr3VZUq3EQcztJQXzpSEK1Q95+vA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=yDkUYRoAqeIJo9/Es++RfVl+aH+7XQLZdy5BOhRlaXI=; b=eHsBPtyVVHsZ+FT+bpeI/8L83RNdQkuvPRMq4BfozcIS3Bf0x2Wx9NSp50DsCQ6j7udmCjHGeQw5uUNJ62vHzydnQzvT82tsVFi+YAka3uZ9xphA0ORtF9xoffi3kCXDiJUqfZHgMLKSke4MK4e4QlYw0C0sLquNoUYGDqoxGThBANavxVahZrFSM6RMNKJztM04lhDbXWT349LUxR2fjpaOT98Y/xDtN3eLtD2oJ0xn9u+V4eDJ5njBOh8ZWRGeE2SLi+82XVtbwbRqsd/6Paqh9QjU3P7dz4kOi0bzRBmhMPmvyKNhKNpf/mQl7Rvxtb9YHtGbiXwZELifE2+PtA== 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=yDkUYRoAqeIJo9/Es++RfVl+aH+7XQLZdy5BOhRlaXI=; b=PSvV6vukW/gqk+Af2bbiM1LaSP18ZW/hpbXbPw+hk7cgy9J2/OCJI4A2aHwvJa3n8/5YmXuhDAaWZSTb3sF2NTzDsNXPQo8OAlMzlVt5McbsdSrVWXloNywFNvPoEC+nen0JLI6XBiXtINJ0EVr1p/Z1hGmu3A9YYFnar2xQ6tg= Received: from DM6PR04CA0006.namprd04.prod.outlook.com (2603:10b6:5:334::11) by PH7PR12MB5781.namprd12.prod.outlook.com (2603:10b6:510:1d0::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18; Thu, 3 Oct 2024 20:01:50 +0000 Received: from DS2PEPF0000343D.namprd02.prod.outlook.com (2603:10b6:5:334:cafe::67) by DM6PR04CA0006.outlook.office365.com (2603:10b6:5:334::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:01:50 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.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.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:50 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:49 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:49 -0500 From: Harry Wentland To: , CC: , Alex Hung , Harry Wentland Subject: [PATCH v6 29/44] drm/amd/display: Add support for sRGB EOTF in BLND block Date: Thu, 3 Oct 2024 16:01:11 -0400 Message-ID: <20241003200129.1732122-30-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343D:EE_|PH7PR12MB5781:EE_ X-MS-Office365-Filtering-Correlation-Id: 6e308b7f-b55f-4b0b-1d88-08dce3e6385e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: KN8ph+b0natfeBE0zaTNxGIXodnmjBg0/+ow6ZU5lwO83gLbsP1XHzYbaQE7yeDh49ENbwoT8X3KsXFSEjAHlIXbmFJdOnvCQstXgNpphHoP5QX0+fj4ktx8LhYgy2hSTZqVhL51vLH3HNmCemMK5VBtN/PAZDklgtFe1oxCOgFjfkDg3F+yks5BohRXF1fpIcSuuiVCnz8samDLw+JbnMDkMt400sKLDvLFEQVlhkHS6WcjvhbJ754Hxy5a7xv/5gv0d7d6EJdY4XSwC6CKwFe3PKsmG0ZHLScN9u53W2eTPVtGStvMZ3ID4b1+w1n8Q+FLNeE/HbJ/PDxsQ9vVHFCHVPPhta48npPOxziVoP5TDh5sVsjmZ1HdWStP1dcXbXnQDL9VBbmRrcwL6dznoIItSjDN0Ng3donIe6QcD5OcchcueVYzFHtXp+KTcyN7wNr/e6uZNcHCD/U4Fvl/1eM+l2lsixi3fdxBpol1ypklXKlk8ieQ5sk77VtQ0TYohluGbDmUlqSRWHOe9uVGt0L0C7n/Ubkb34QC76mWWL14cwASMGk5XgUi27vP+ZzbETKaN8DjKF3WZA9qcZy94+RrXFCYq6DkZK43q8brL1jRjH4X8BBOR8JJ0apIn8Tl93fjnuOogtwnDGh/tAlorz7qbvvVwxE8l+3ZX+D1DP77LCv0SJSRJpSv/1GcTKc6X6p/a3jmLm1tvN5UAq3lj+jmJSf3c1Qw0gG+aouOev3X4q54lqPIU5UI5udOOtgBTvz+NmZwW7QUmbmYWxqMeTVFSR3+BU/jAVqiAqc929GymAI/LHab2d+gV2/eagt62g+lEyqs9AIUqC7JzhBsCj97KwPLn3e9XZ1BOknpt+ULokwQxRVnyB18Vdi2reXL30yjRqiAhSufQODFJh4htOJb2ptCpr46/S/s6xYQNgNuIGAhwsFnz1FDSr82dNNpLQ8TBff4QyHWUZ83NzbC6G8xCC3rAzfvB8/hgnzM95AR+R1+WEib9ED/fcm9aZQO+j3A7AwM3CwRoiWENWQT0ZsIFjxR6MTeatwA2/lyCu5ebHTVglDfRz12E1rxzwAGnkl59PcdCUdZh9xqb2FiYJ+XIRn+k0C7E0X08EBaudwH6ybcLDyHYFgpJwOu5P2PS13B/IUjK+oBQEeaZ7jJqORs1aY67H/YiXZkxdCIAdugUDSZedl/PgZiCbePmdFaiJkLKlduqdGn9huahzFH/7WLOXxcHozgwcD6eUYLR8QOrCWWUWYfDYO1ixD4wEpx3QjbyoO6vKuY3rO+jZfXC0f6+F9Jxfaj1nZzPFwSiIoP5KbnnrjH0RS68C4zbh094oru1hCM0wfvG2/n7z0dZjsIWmmp3tpJcMglsCIzdj1OKzIMJvNXAiCP+0XTrYtX X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(376014)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:50.6193 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6e308b7f-b55f-4b0b-1d88-08dce3e6385e 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=[SATLEXMB04.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: PH7PR12MB5781 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 | 19 +++++ .../amd/display/amdgpu_dm/amdgpu_dm_colorop.h | 1 + 3 files changed, 97 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 d67f88340b6b..f0dac44d97b3 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 @@ -1265,6 +1265,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) @@ -1343,6 +1409,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 3afbac6c4e2d..7f58c7b6a1e0 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); + #define MAX_COLOR_PIPELINE_OPS 10 int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_prop_enum_list *list) @@ -79,6 +82,22 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr drm_colorop_set_next_property(ops[i-1], ops[i]); + i++; + + /* 1D curve - BLND TF */ + ops[i] = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL); + if (!ops[i]) { + DRM_ERROR("KMS: Failed to allocate colorop\n"); + ret = -ENOMEM; + goto cleanup; + } + + ret = drm_colorop_curve_1d_init(dev, ops[i], plane, amdgpu_dm_supported_blnd_tfs); + if (ret) + goto cleanup; + + drm_colorop_set_next_property(ops[i-1], ops[i]); + return 0; cleanup: 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); From patchwork Thu Oct 3 20:01:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821517 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 DD134CF34C6 for ; Thu, 3 Oct 2024 20:02:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F2D3610E954; Thu, 3 Oct 2024 20:01:57 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="ocoqr9FH"; dkim-atps=neutral Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2045.outbound.protection.outlook.com [40.107.93.45]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9E1FF10E944; Thu, 3 Oct 2024 20:01:56 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=J0fg+qKXV4zP7pZKH3a18MEiYUEaA7um0g16ZFO/OU7HMUy0EOKzXoVC5o3NPRIx6YquBLvDX5EPGKAhrhCc2L8jL7BEyK1359Zke1ZDK7Dnw62d0FyPR9aCJIt7gRBLYVWXqtW9Ej1F138a3o9JqVR79oPCbVsKgeLQRSRdZHkga1Uu046lUKBVghGJHkzqaq23PohzBnUol362wpJklziYnU2RS+XtDPyQCLaGSRrJQ0FYZdUmnjhvytq4tCMVzUTsmnRKB7kHjcSsvbKqinqe6anlVuXr/IhlFA5HcpcW7knABIrltjaGFtQWnpneLCCbBVWY2J3Y6J6t5nTbsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=aE2SiLTWrvFR/Pfag2/eKIdWyTgjnL7nmAmZm/nA/iE=; b=tEIIfPrQixMAxEcIMtQLzZ59oqAhSyJmeJLf4NALz3WGxCmaEQOa5eweEePX4tOe0CxVd6CSZmTtT5+BgrzH4k2N5wyks62le3qi5NTMBIyUPnJma3W69sccMCObHPwmhUkreSyu9xUG0nuUzpTQMWAJVdczYggZ0L82wwueBpTU6wuZlrqowBOf36Na1bKbVAaMtxxqfxr24+H1EBJvuXYrd720QmudKKCPmqTW1mn0D2zOP0xuD2XEsgCL/mW7VZhNREh6oLAqEWGuTCUo90tsfz/T8zpke/TLr9RuZLucQlwuiTWPnptSwISzId8THMYrXfGej4ziod4GFZ+foQ== 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=aE2SiLTWrvFR/Pfag2/eKIdWyTgjnL7nmAmZm/nA/iE=; b=ocoqr9FHxZG3Qrjb2OJhFy07ksPyUWtsVlnhriGSQ+2G8Vov6CQTsgQ+zK+3mQ1/qu3v3A/voH7fkJi1vb848G/97UCpMc9BnUC8b+LwPf4DInPibTKuD5ZdhLeow25Vgrykj70y+QZo9KNlyi0BFIKFxstZcLdreSYeWfo350I= Received: from DM6PR04CA0024.namprd04.prod.outlook.com (2603:10b6:5:334::29) by CH3PR12MB8935.namprd12.prod.outlook.com (2603:10b6:610:169::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18; Thu, 3 Oct 2024 20:01:51 +0000 Received: from DS2PEPF0000343D.namprd02.prod.outlook.com (2603:10b6:5:334:cafe::81) by DM6PR04CA0024.outlook.office365.com (2603:10b6:5:334::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:01:51 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.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.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:51 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:50 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:50 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:50 -0500 From: Harry Wentland To: , CC: , Harry Wentland Subject: [PATCH v6 30/44] drm/colorop: Add PQ 125 EOTF and its inverse Date: Thu, 3 Oct 2024 16:01:12 -0400 Message-ID: <20241003200129.1732122-31-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB05.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343D:EE_|CH3PR12MB8935:EE_ X-MS-Office365-Filtering-Correlation-Id: 8af3e84f-cad4-4cfa-52d9-08dce3e638d5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|1800799024|82310400026|376014; X-Microsoft-Antispam-Message-Info: eVw5BsRKWOkwVTVNswwdityfV+Ta42b2Ihuv3QV31Yu5XQwFQ+3P4YyKxvFqtqVi2WblWFFWa6eBNMW1/ZGPEih81zXTVTbj/9dD4zdFdgxSQrw9EYNwnwRYln0spG2P348tEy+Q5wjhU6anrU0wRYLH0uZEJOOPJ0ux8tDIJ06bqXORIkt4VeS8txHx86laI/eo+v/5ZMUFhDmNDDYWEEWVT3HtlOsiuzpt8GlbTSlAIRYEqQ1ZnZDS6RzCysMi7199fj65DRPYkCQUmi9vvbsOXlOZxMDZfizi3fssUWlPukvQ7lbh3awjLxmJLt0Y3AjuOutXUlrTeIhpYLs0+G72ClAr64S8TyBns+KsLbsLSddwwTTTU+ik30H8tZwVEJ6f6jZbCFwb+rS5kdfrPbrlrcSmOpsApwWFcCyY7RKP/SEdf06Pbz9agdAl7+KQovb8HCEmrgmHXdnIKCaoe9EG3nsN1DpbawGr/0gkNzrE2eGDpQ3FRH4/0sIHOqPRv8wmkCkoIig2cPPMLqeQo8FdlHTen0CIh4+SMuPAa8mLf/Omy187tBa2FCA/NQNyNqK0fgGW/e3KpmNKyBdOt9DcZksPBYTQA4OP8Wyla4cWm5x6zgubBynki1Zuy6jtdRp7eOBz/kv28c6wcfQXCEArfipIdlgr/HR3jR7tBUpc77PB3u1Y36MVCWDrGtRsrjB4YHINEbD+qXNdEDeTRxUIgm6ARNt6l+yEjZrf1lF5wsf9aQfsjLazd2RPAWUd2RBvxHAe2g54lobQqtTsIUe8roDnBT7hD1djRX++QFoDnGtcwXyAAOVSh2AIFKqVO4l4jOB3VTg5/ZJg4A3++hKFTinQi7dDDobdNy5yLYXGwmm/5QQ1H8E4na/hCcE326vJsxnsoNMvcU8SQ/RGi+1fp6+4Wa8D5or2PW0nzH2g8CshhZAOoHcLDm6JtXpbaMCcQILDYrjQDOqFyym3nX85j5mzp+iYzufcKnwh2gqGEYkov6MoQEEP7BmYj1txel5EfsFKyg248/xl0WOaZTKgRbT12y068xwmFx8YudLaWq6Yv7DbzMc80LRiVXTE4Zc1uRWqU7/s9XXIDIa2PGnaDB9yIsjlYDxbj6AAqyk+c9iSRtAydNnPXgi7mQ3nYQ+9ITekL/t3cT3kx3cKmC452tEFYzr42gKAgtKexM4t2DVg6iUcGdBpEnMBY9AQHq65qpXcM6He/LyUUSCF/r8kLd8+LYVJ70sTbYCGqF6q+1DOF9yOq4GTctgiWn+l815K6adzqB5QDuodi+3Eu0cKVpg/pbbwQZoRF9nZHW9UxHFqDaihPjOShWM1eQRJBa4NBcuv8o3sFTrdK1bTvWAgK6oy7dBNgks6wZ1V7Ag= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700013)(1800799024)(82310400026)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:51.4005 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8af3e84f-cad4-4cfa-52d9-08dce3e638d5 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=[SATLEXMB04.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: CH3PR12MB8935 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" The PQ function defines a mapping of code values to nits (cd/m^2). The max code value maps to 10,000 nits. Windows DWM's canonical composition color space (CCCS) defaults to composing SDR contents to 80 nits and uses a float value of 1.0 to represent this. For this reason AMD HW hard-codes a PQ function that is scaled by 125, yielding 80 nit PQ values for 1.0 and 10,000 nits at 125.0. This patch introduces this scaled PQ EOTF and its inverse as 1D curve types. Signed-off-by: Harry Wentland --- drivers/gpu/drm/drm_colorop.c | 2 ++ include/drm/drm_colorop.h | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c index a995a0e25a34..6e1d733ca50c 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -69,6 +69,8 @@ static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { static const char * const colorop_curve_1d_type_names[] = { [DRM_COLOROP_1D_CURVE_SRGB_EOTF] = "sRGB EOTF", [DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF] = "sRGB Inverse EOTF", + [DRM_COLOROP_1D_CURVE_PQ_125_EOTF] = "PQ 125 EOTF", + [DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF] = "PQ 125 Inverse EOTF", }; diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h index edad9c579781..f0cd4cbdd99e 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -35,7 +35,6 @@ * enum drm_colorop_curve_1d_type - type of 1D curve * * Describes a 1D curve to be applied by the DRM_COLOROP_1D_CURVE colorop. - * */ enum drm_colorop_curve_1d_type { /** @@ -55,6 +54,26 @@ enum drm_colorop_curve_1d_type { */ DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF, + /** + * @DRM_COLOROP_1D_CURVE_PQ_125_EOTF: + * + * The PQ transfer function, scaled by 125.0f, so that 10,000 + * nits correspond to 125.0f. + * + * Transfer characteristics of the PQ function as defined by + * SMPTE ST 2084 (2014) for 10-, 12-, 14-, and 16-bit systems + * and Rec. ITU-R BT.2100-2 perceptual quantization (PQ) system. + * Equivalent to H.273 TransferCharacteristics code point 16. + */ + DRM_COLOROP_1D_CURVE_PQ_125_EOTF, + + /** + * @DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF: + * + * The inverse of DRM_COLOROP_1D_CURVE_PQ_125_EOTF. + */ + DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF, + /** * @DRM_COLOROP_1D_CURVE_COUNT: * From patchwork Thu Oct 3 20:01:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821526 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 133E2CF34C3 for ; Thu, 3 Oct 2024 20:03:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 96A0810E968; Thu, 3 Oct 2024 20:02:00 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="LpUdiQ0C"; dkim-atps=neutral Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2079.outbound.protection.outlook.com [40.107.236.79]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0A5E410E94C; Thu, 3 Oct 2024 20:01:57 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=u2BCh1EfmbZ1v7BwQl5wnX+afTMZ4vONTBijX88NCZ/UgY9Q/6sInWO4qNBSieWUzUzmeHIj2b2M0+q1TYlY5GTVn6I3XHdKyYDUIc1fyphX//d0gdkLJ9Pc0VDV1xsLiLAOv0aAKRJ5iIhji15Ky9KPe0Wrr7lF/X5taPRK1B9FMVarBRydLj7I5JfZlOIGl7+Ow7Gn7ycM1rEfq/iMIH+b1Hk4k5SnSPRR5e9fb0W3Gg1nOSnwFUgzdRj/hw2PVTR+fa/Xugj99E5aN0690Evxp5LMcadCEG6FnDErMEZkMIQcuLRCpbthUPjGJnmOA/cso3pELEqMq7LW9HWkxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=lRS6B6PJ3nV1gMwzlrwm+6GVeeEJW3l8bpXxMD4eSpc=; b=CHIhaxU+0ohgeSXEs4ltPTbP8goM3RbkEKuTx4mKYAc+5dnu+KOojJllDhK9tl5p+weQtaSTzhfVp8EgeTJwPXmw5KtH0rwIFMGLDJBEW7VM1SJmSh83unJfkB9g9Ux5I0le9CKTGLBvnxmLlm+0A8d+2UijiVLML8LXQJ9QoIY3uM5oMJJLpbcts5rFmuYrcJUiODYaIvxgJoLJ5N81QqAYP5UfL/nAm0IjMb2eCwegwMAyD/phyuGxLA/t2Vp04W33mIgzMPwkFCqG/BC8qlWni48byzESDtAQQEFpSSMmTDwpNUER98I0WYHDA7atYn5PBDUYzr5nCuLN0BA2pA== 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=lRS6B6PJ3nV1gMwzlrwm+6GVeeEJW3l8bpXxMD4eSpc=; b=LpUdiQ0CrfV6JoJXyii3D/FsxxwYelMrLSsi1o+KdnBVybOyH94QgmhcTkys0D8YwGM+ORfa/vnw+LBJLlTZh+5rLVRkTrnHjBFCrSWtvd5bQv2kvsUCiqo5ic1XwjGlaU9BRx8JCnVytyhZ8VCUX5gzzCBSxzEX+pRUgoivSxY= Received: from DM6PR04CA0009.namprd04.prod.outlook.com (2603:10b6:5:334::14) by IA1PR12MB7494.namprd12.prod.outlook.com (2603:10b6:208:41a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Thu, 3 Oct 2024 20:01:52 +0000 Received: from DS2PEPF0000343D.namprd02.prod.outlook.com (2603:10b6:5:334:cafe::d5) by DM6PR04CA0009.outlook.office365.com (2603:10b6:5:334::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.17 via Frontend Transport; Thu, 3 Oct 2024 20:01:51 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.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.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:51 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:50 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:50 -0500 From: Harry Wentland To: , CC: , Harry Wentland Subject: [PATCH v6 31/44] drm/amd/display: Enable support for PQ 125 EOTF and Inverse Date: Thu, 3 Oct 2024 16:01:13 -0400 Message-ID: <20241003200129.1732122-32-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343D:EE_|IA1PR12MB7494:EE_ X-MS-Office365-Filtering-Correlation-Id: 776caaa2-c703-4b73-7749-08dce3e6391a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|1800799024|82310400026|376014; X-Microsoft-Antispam-Message-Info: ZwR9Bj7CLzaJ64gFafYH3XmAVvWwZ/HZr2MUQSFpw6UIFQJ12wxhZWBeUDv48220x7dyaTcF9NlZSp5JaKR7DUilD4LLxRzLn66n70+JV14RL/RKy24gAi5ADdFun/pzf+h2NleGYuV5bATYiEabgeSRAWeiFOM58V8s9i2V1CMbDSJUk2Hbk0wrpe+9rgmudZchm8WfoZ1xm6f8Zw6ICd1FavYbzWEYgW7H5XIEERGoeJyQ/Cj/sWhUKGVfcifRchCH+cX+giGbxmsSBjPcko8EL7nLVGt55PpE0a9IUH9RCfAjW0J/7zuJ9QF2nInAcEYMPXESA+/h7S+/tu/gBxKOPpENKIz9j5RCFFleefnc1ICkMdXWGJLW1VRz+TJJtsVZ7vLWS4iZAX7YKITn5H8SXVJJceQiwcl22hVzlOx+4bWiXBCSF9DsD7U4NrxVN4VGNvPlOkhFgisORCckXPIcAI5EwQNma832wiJ2bFRuasaIRdzknyCK9QxD7Ts8HXRTwS6/Oxhwt2wVkkl3P1/oS03JN/A3EYHL1TRGv79Ne37Lx4MiUE17LJe4z6F4Puc7poAXIag4eTfMy16nNA/qF/uRHMJvuKcGAW1OOhP5uxoKnjZnr6DAFnA1Bv9OERj/S4WyvgIqGaZNOJuoPa5YZTy0BVr+Zv4+estSMCwYV/I3WBksgVKUdka9NTNhZqBJJl8VNw2p3ch+bmOdxai0P+Nwuqo820LqqB0PMuHuxohaCbyh67oVuXZT1F9AnHophcwlwfm8ZpJ2iVhzm56KFym3Qw5z9zxoXz5ts+2FAwworJZgJVQXTGWx8BauNH4G570t+lz1SbB9d1tug1ZURq/XHIMgyaGW3PUe67mj5zRgkC94EdEBZneVH28Ae5GaDJH4C7ZoXL5vGs4bEtyJeXQ7plSth4WmcnOhGe8LQV7UJS/UnnMe6MlQPgNLzYwhqNLJKXNo4RaHP8bnnLNHwqZxjabWu8xWdbHUBIfrwRw5v/1yzJbN6s1ehJmlF27cz1fh0gCorw6d9Cf6aBOvnAgZkCCg/F9ZIKTba0xZyxVdutMihbPqhuQO3ZahpYuVCNwCMaZ67bE9/dNdfRPer9PM6VjWZjIZpciFGXSMzZah+dhtX70YXHETxwpk8sLBZo0TR6M+BWQBm08Uvfdv0iBYeNo5/rmUjqZEcW084dwxQMFotH/w47ILy/ifuiEAR5m6w+bPob96TpaQbJkNPE19s2nQOiCsHl0hFwZ4k/iku9TrCkyOguTQRxajJuFOhoEiSKjtE7XefDoxZ+0cN2rqY+5xm5Ogh63KRgSfoor5yL82OCa6ppjHDVGCUG2uQVnVmGD80GZPlVeXD3Q0qVFTGVjuiSpfr7TtZbm57b6YNGwphA91m8FYNREb X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700013)(1800799024)(82310400026)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:51.8536 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 776caaa2-c703-4b73-7749-08dce3e6391a 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=[SATLEXMB04.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: IA1PR12MB7494 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" This patchset enables support for the PQ_125 EOTF and its inverse on all existing plane 1D curve colorops, i.e., on DEGAM, SHAPER, and BLND blocks. With this patchset the following IGT subtests are passing: kms_colorop --run plane-XR30-XR30-pq_125_eotf kms_colorop --run plane-XR30-XR30-pq_125_inv_eotf kms_colorop --run plane-XR30-XR30-pq_125_eotf-pq_125_inv_eotf kms_colorop --run plane-XR30-XR30-pq_125_eotf-pq_125_inv_eotf-pq_125_eotf Signed-off-by: Harry Wentland --- .../amd/display/amdgpu_dm/amdgpu_dm_color.c | 20 +++++++++++++------ .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 6 ++++-- 2 files changed, 18 insertions(+), 8 deletions(-) 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 f0dac44d97b3..d4ef20bc2be5 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 @@ -25,6 +25,7 @@ #include "amdgpu.h" #include "amdgpu_mode.h" #include "amdgpu_dm.h" +#include "amdgpu_dm_colorop.h" #include "dc.h" #include "modules/color/color_gamma.h" #include "basics/conversion.h" @@ -676,6 +677,9 @@ amdgpu_colorop_tf_to_dc_tf(enum drm_colorop_curve_1d_type tf) case DRM_COLOROP_1D_CURVE_SRGB_EOTF: case DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF: return TRANSFER_FUNCTION_SRGB; + case DRM_COLOROP_1D_CURVE_PQ_125_EOTF: + case DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF: + return TRANSFER_FUNCTION_PQ; default: return TRANSFER_FUNCTION_LINEAR;; } @@ -1158,8 +1162,10 @@ __set_colorop_in_tf_1d_curve(struct dc_plane_state *dc_plane_state, struct drm_colorop *colorop = colorop_state->colorop; struct drm_device *drm = colorop->dev; - if (colorop->type != DRM_COLOROP_1D_CURVE && - colorop_state->curve_1d_type != DRM_COLOROP_1D_CURVE_SRGB_EOTF) + if (colorop->type != DRM_COLOROP_1D_CURVE) + return -EINVAL; + + if (!(BIT(colorop_state->curve_1d_type) & amdgpu_dm_supported_degam_tfs)) return -EINVAL; if (colorop_state->bypass) { @@ -1191,7 +1197,7 @@ __set_dm_plane_colorop_degamma(struct drm_plane_state *plane_state, /* 1st op: 1d curve - degamma */ 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) { + (BIT(new_colorop_state->curve_1d_type) & amdgpu_dm_supported_degam_tfs)) { colorop_state = new_colorop_state; break; } @@ -1211,8 +1217,10 @@ __set_colorop_in_shaper_1d_curve(struct dc_plane_state *dc_plane_state, struct drm_colorop *colorop = colorop_state->colorop; struct drm_device *drm = colorop->dev; - if (colorop->type != DRM_COLOROP_1D_CURVE && - colorop_state->curve_1d_type != DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF) + if (colorop->type != DRM_COLOROP_1D_CURVE) + return -EINVAL; + + if (!(BIT(colorop_state->curve_1d_type) & amdgpu_dm_supported_shaper_tfs)) return -EINVAL; if (colorop_state->bypass) { @@ -1248,7 +1256,7 @@ __set_dm_plane_colorop_shaper(struct drm_plane_state *plane_state, /* 2nd op: 1d curve - shaper */ 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_INV_EOTF) { + (BIT(new_colorop_state->curve_1d_type) & amdgpu_dm_supported_shaper_tfs)) { colorop_state = new_colorop_state; break; } 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 7f58c7b6a1e0..0578f33c8422 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 @@ -32,10 +32,12 @@ #include "amdgpu_dm_colorop.h" const u64 amdgpu_dm_supported_degam_tfs = - BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF); + BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF) | + BIT(DRM_COLOROP_1D_CURVE_PQ_125_EOTF); const u64 amdgpu_dm_supported_shaper_tfs = - BIT(DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF); + BIT(DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF) | + BIT(DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF); const u64 amdgpu_dm_supported_blnd_tfs = BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF); From patchwork Thu Oct 3 20:01:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821525 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 EF938CF34C1 for ; Thu, 3 Oct 2024 20:03:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8962A10E965; Thu, 3 Oct 2024 20:02:00 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="nEn2IWEA"; dkim-atps=neutral Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2083.outbound.protection.outlook.com [40.107.102.83]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5D93C10E95C; Thu, 3 Oct 2024 20:01:58 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GWrCijD0IHUHfS3fBz6ncFnHPupT93ASkbj7X4GXliQpjLYBjw09r3OaUOqCHU0czNFf/C3sXjdCku/0wS2ws+h0ao4pW7yAZFvRM3YqGn+XCxVWXQd1sebm95PJ820C60Anh0RXOFEiGhKeZE7+wqjN0i1EZLYc6p+QJDAsnUCK4eNmfjlyEySaWtIzwRKqv6cc4ApMF0jObotl1F4eVad816kKimw6rCoIIgqRWbtQ1ezYjDh7RO5tGgG4tqAL0x5WaSeXs7onud3n1EIn/5UsJebA4z5MwHX1aNEL81nn2GGMH73+Dqtl82Ra/KYIYDEo+8LOvytkjcY6Jb+XOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=qQC79tX7+L2j5Er0hVpmFINJsUGj9Xr5WCFOOPSat/E=; b=pafifSjfJ7PlX3RxaGt4PZ3HxggWosvOV6VNg9tv90kIHX7SNy2P3jJDVB7TJTa1Vjm2wk30yPi/Y3CjjelLq/54ytCikSH/uON6+fTOp/2EcH7hUvkFgmTPexmHljjIXNl95A7OwXBGwueCktmn1CanInyxHiHB0cjyyM1jxUYrY1pOAohYWRUpYSphxxTWP16dCDpx/icfQyKIEVdPasHOMCwd44q3q2yMNC/TuM82RCqAtqzwvpYMrmDuxOQsm3WtCWwF6g4LYR2TSI7524FiPN/WwGI3pay+IpcrLiKRYnc0jkG6kGKQEb9jC5UUnc1VVp6v2N6V3HcPjhOSYg== 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=qQC79tX7+L2j5Er0hVpmFINJsUGj9Xr5WCFOOPSat/E=; b=nEn2IWEA27ReN5bHt2UzESzqGAl4V6RerP899TIdR3GHl7GgY4RHMbeEnrLEfKVSv8waKBjoCPXj6X5bFZGpJHysNKz3x+I9FSFraDVNkAFJrMqUUYmH/Bq2g2D+avX0UIQLamnc6ViqcGPRqOEtnoxVxMP9JvxMXN1sjR/E6yo= Received: from DM6PR04CA0027.namprd04.prod.outlook.com (2603:10b6:5:334::32) by CH2PR12MB4264.namprd12.prod.outlook.com (2603:10b6:610:a4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Thu, 3 Oct 2024 20:01:53 +0000 Received: from DS2PEPF0000343D.namprd02.prod.outlook.com (2603:10b6:5:334:cafe::1f) by DM6PR04CA0027.outlook.office365.com (2603:10b6:5:334::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:01:53 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.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.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:53 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:51 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:51 -0500 From: Harry Wentland To: , CC: , Harry Wentland Subject: [PATCH v6 32/44] drm/colorop: add BT2020/BT709 OETF and Inverse OETF Date: Thu, 3 Oct 2024 16:01:14 -0400 Message-ID: <20241003200129.1732122-33-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343D:EE_|CH2PR12MB4264:EE_ X-MS-Office365-Filtering-Correlation-Id: ec68d9e1-4f65-45ea-e0da-08dce3e63a27 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|82310400026|376014; X-Microsoft-Antispam-Message-Info: qgx/2CAnY7lLJcmD/0bUHgjbs7SsGWUwfBAcAktXUFSJE02oSkCH0osyYbuHWUy6q2cwU3JszFdMr4QILhT7Tv87r5m1v/lgz/KBWhvnG3VFBci7fcg72P78Tvllx2pqkySNqUelshG8AMqRUgZY121sl9cc/WR9QdgkHNeJ/JpVZx8HqY6jkPoNilLt1kWK5qXq9SX5JBDcfMc6AZ3h5VYtuE8LMWQHz/Lf4z2T3xpaEWZHgGMO1/CEpN3h/YmY+X93iSjcSejWz1kp+6wKlHr+1y/M6KrES++t6ruv6rzJviZKqgkJrS0cHfemPlmhUGD/CAegHu/LGUaK79v0KWF8KzV7+mX4aNWMyWY6a29HBugzm2vpkYnflQKaqlnyzL1ESzQm55d7Bq+Sp8Gu64AA5OPQbq4oWW7Bu67GBhypHyeo1aLE+2k0PqnQe+NzkJV1bPQHxQCltMWDX/wTHDGz2CjL8St77zbEfaQPF7zb17taYhoo2WHejEb/v4UgQ3XmMoNKjCIfomqDPITtHLyDUESeh4EK3xkNhRgddzlIjIhbgVJLbyTnXOQmSToJnvQJ8c5DO/kfp8vQuNmM+P0/7vAYOCo1wGqKyXu5HhDi0t4bY16j3Rt1pe4XUE85sc4ZoHBH+/ikM/ektNyRGy2e8hCKvPLQV5yZZ0rVqQPTg2aA4Sl28b7d+KR5YucGEboL2L74NK0kZ4nlvae3EkeNiI+UWNa9OVXNoF/vjfh25PtJVRHjIblGoDbap1/TjvUgc9+fXO7Wn6NZZQeuh/5aI6nWYAoIIlSMB8NshZj2OSLwMT7xrNjfNuMoEVeDyMpYLVJsTqZLhNV4ZxMyiPoB+AX1o3g8wLv4rOOgSKasZ8CVwCzi+ftHvwoeix8CvYJLDI+T23a3vtCCXz9+UmYurIg7y2/pFvVXBHQz44L6RcVHH6FB5Zbkaj8rXsKqhG6IbjZoi+kaC+XJj7b1LvTN4McaBqorKqQNiL+T0KVUlmPIVYGsCimf/D8DTy3VSFQxWwyYn0tuTsUxnMhkppd15JA9WlnqV7QDgSI19DxunvyUs0W4XmoGOZWSu/xKgiewfV9Rqd1a4Knby07stVujACUaYww2KSZGAspPWVZu5XLh473o3SXcH3HE/fc7RwxbIjgsHFqw5xgo1jLmPbHcg2PLSbx2eJND6U3790EtVGLh1Dp3en+LFmn8LvhqGDGCy/APwsjv+G5ydvQQWXkt0PS0SwIlLckJ6QzHtAIacONGzcbDxADrsT1JVO1X7xIYjBpfEg6fBt2avU/1xh7Oc5i7P6BW4JCX3dM/XEsy/z3NAhcFcpkOD6H4lRqF4v4VRInZfY6d36KGp84gFsTiqxmwhj4R5+t0pUabSAJqRU2ZqKyg28RV57dcrYHe X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(36860700013)(82310400026)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:53.6192 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ec68d9e1-4f65-45ea-e0da-08dce3e63a27 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=[SATLEXMB04.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: CH2PR12MB4264 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" The BT.709 and BT.2020 OETFs are the same, the only difference being that the BT.2020 variant is defined with more precision for 10 and 12-bit per color encodings. Both are used as encoding functions for video content, and are therefore defined as OETF (opto-electronic transfer function) instead of as EOTF (electro-optical transfer function). Signed-off-by: Harry Wentland --- drivers/gpu/drm/drm_colorop.c | 2 ++ include/drm/drm_colorop.h | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c index 6e1d733ca50c..d6af7910ffc0 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -69,6 +69,8 @@ static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { static const char * const colorop_curve_1d_type_names[] = { [DRM_COLOROP_1D_CURVE_SRGB_EOTF] = "sRGB EOTF", [DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF] = "sRGB Inverse EOTF", + [DRM_COLOROP_1D_CURVE_BT2020_INV_OETF] = "BT.2020 Inverse OETF", + [DRM_COLOROP_1D_CURVE_BT2020_OETF] = "BT.2020 OETF", [DRM_COLOROP_1D_CURVE_PQ_125_EOTF] = "PQ 125 EOTF", [DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF] = "PQ 125 Inverse EOTF", }; diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h index f0cd4cbdd99e..ca3a480db787 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -54,6 +54,25 @@ enum drm_colorop_curve_1d_type { */ DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF, + /** + * @DRM_COLOROP_1D_CURVE_BT2020_INV_OETF: + * + * The inverse of &DRM_COLOROP_1D_CURVE_BT2020_OETF + */ + DRM_COLOROP_1D_CURVE_BT2020_INV_OETF, + + /** + * @DRM_COLOROP_1D_CURVE_BT2020_OETF: + * + * The BT.2020/BT.709 transfer function. The BT.709 and BT.2020 + * transfer functions are the same, the only difference is that + * BT.2020 is defined with more precision for 10 and 12-bit + * encodings. + * + * + */ + DRM_COLOROP_1D_CURVE_BT2020_OETF, + /** * @DRM_COLOROP_1D_CURVE_PQ_125_EOTF: * From patchwork Thu Oct 3 20:01:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821521 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 EAB47CF34C3 for ; Thu, 3 Oct 2024 20:03:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AA77610E963; Thu, 3 Oct 2024 20:01:59 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="OAw39GiD"; dkim-atps=neutral Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2089.outbound.protection.outlook.com [40.107.223.89]) by gabe.freedesktop.org (Postfix) with ESMTPS id D17C610E955; Thu, 3 Oct 2024 20:01:58 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VdsL7nT4/2Y7LPdBSTET19feJHhoTjoWFLS5HrfEf2Qrrji5O5Tng4FBPfF8bM5Ry3arUFaCOTksfV0L7r+ZkGl+HCGVHINkNLk+PG3Pmn8eghEaHXu2WaEztOLDmTfKm4G+U+R4XV72WweJWoz9sGLuxUabu0sczf+lItzJstKYIl1YsRy5h+07hDKL2Ldo/npVzdrs2sP1c9tuyG5JGOB3WSk3m0iuGIGE3LAo6F8jWjBzOBJDhwnQaayZiH/yYd9ahUaH6IE9tQ2uPBHJ6d+PvAXE5fiM1Pxcs4dBRq/oetL6VCmCkXKxiKSUMDW3vc31bquFE40bxhDXkrArUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=7t6bXtnAk50Utz0J5CwII5FryENPI/9GfBAtkKdP7xA=; b=bALmbk8hKQY27mtpo71AUwv+N+gXEk3ZsK8FY//kZPajrLPrghl7XrIgsQrO5SaZ4O/Khy/XLBsWYyb3it76/GZlJmwz95yahaow3Wxjs32gCfVvgghcORX2+Uf7vqet+8WY6X9C5Tg0cNWBVfX/8flWA3PaNw4YsXPmwP72lVoK7gLctxPLdeMG8NKETAqKJvmns6N5ZE/q0XNsO2rJna63CoNkHazrItGQngPaESmd8kpOFr9rGHgrAjYgUM/WAkBoFV1XbbCwk3OekK5LLZ2NTZnpG5hGiI/nFSsdaYKME0Ydx6PMKKb5Udv/JACqiTF55+cSKbVquIHJrRNg9g== 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=7t6bXtnAk50Utz0J5CwII5FryENPI/9GfBAtkKdP7xA=; b=OAw39GiDDnBXyGA+0zoT9jygaL2q4CN3Libq92c1RrKxnk/FYw7UEnX1DJMLPeYhmvl2DzipilK5g6hdtj4lwZlU919O/EEKNgH8RA2mfo6ksxk/SMp8yGpwkiOGxWkOPMPGmUSbOxAz7JioXJtvUiSgYk2JR2vRC363uZQ65b8= Received: from DM6PR04CA0005.namprd04.prod.outlook.com (2603:10b6:5:334::10) by SA1PR12MB8919.namprd12.prod.outlook.com (2603:10b6:806:38e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Thu, 3 Oct 2024 20:01:54 +0000 Received: from DS2PEPF0000343D.namprd02.prod.outlook.com (2603:10b6:5:334:cafe::6b) by DM6PR04CA0005.outlook.office365.com (2603:10b6:5:334::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.17 via Frontend Transport; Thu, 3 Oct 2024 20:01:54 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.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.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:54 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:51 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:51 -0500 From: Harry Wentland To: , CC: , Harry Wentland Subject: [PATCH v6 33/44] drm/amd/display: Add support for BT.709 and BT.2020 TFs Date: Thu, 3 Oct 2024 16:01:15 -0400 Message-ID: <20241003200129.1732122-34-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343D:EE_|SA1PR12MB8919:EE_ X-MS-Office365-Filtering-Correlation-Id: c4ea46ee-fef7-4fa0-408c-08dce3e63a68 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|1800799024|376014|36860700013; X-Microsoft-Antispam-Message-Info: UxASvz8F10QEaEU/eMIdzCHzTgx7bhnJjNTKH/ee/lCd5CUW8Z5C7Vv2/46Hg7HcnsPHts1bkeKU+7YYNkx8j3AwF2yy8EdWk8qMgf23/jUZ/fpr2iJ/WC7IhX+OaVIUKcBrUDoIcd6av34ftpwj1DBNR/dp84o6C0kSKZijH7LJpT5qIEX/kvL0N6f4SpEmTjzp8YjZW+xRx7X7HW/ctiV4jyLQBSJqe6cS/D2sGK+180ZcqIUwm/Biw+9q82l3TUOkiat87yUniWubSWpJaeNcW47cXvSawkWSwgdnt5K6VomV9HB2F1rcqsssaMHrknHaHDUfkZi7bW4f4yymhchsHCS+qYbE0WoqKABJPUojjCuEN7fcOJNozcvptR+mxqkzvgnzhAgE9ELG3gNTE79RXqrnMBji9UrCB9aCcp1hwcQj07J8u4Xq1eQnlA6gicTEx9eKqt4XpbCNCPvZKHmojLNz6IGNtfvXXiSlcTpDDGtwchqD7gzDR1ZBdWIMi4ANlGBfpxQEcpXHmq+3DX91qa7J0HPDBCoez5cGpO7Yc1i8ZES4oRQssy53MnKm94NR1HXNINpfWzwap5g/dNgVaAkWhKCd+N8hfYJRlsFQ9lP+Og4xE8hbcufcbJF9DmpkJwy8e4Yl1jCVBoMnFSdNdo7PUKQPWn9/uIpMbse6UBrxtJBzDwMlsfbcl+mQHY1ZarwxguVNEX2JTHt67Srw5rspu0TDtoG6KLUjVX0Qo6iJ7GV+nuQJttDoI/+qkX6uLZd32LmeVLq4Cz1uBD21XSzSmInkiBqEoYlB3DOjDLEotxr31cieO8Rukjetu6AtphHsrbxoT5WQVpE8g994ncXXlvuhT2zYqvwQxsXG0wEfN68MSU2mtTH92rKZrKKEkxub38B1HJT+4LZbi1m+z+EMrIPW6ET+POmt1qXZSBkBgQrhv4vDog3x7fm3IOOpkciDgTdmtyy3ZlaC8FO8duCrkKskqlzZ91CJksFnbfPpAw6POj8gqEU28paYueNUAnx8HqBFSqhdR6MNtGHTm8mkd74IaxFdxDP7j4b8oEqyucYgzKCskAejBkUH8MibvLRuZuO5Zvup732tYP+Y6kXBDFOAq4Q1Z5EQ49qsGLzcWO7TCJDke0wgx4oeXfRABJTNvMtvpmgE50R5B/nt3zTOBormpwHfehZ1dhTr7KBXdLn+vi+tGDoCVt3lwXzizAhDIxzgFyJPmXUP1JDRFf/5KPn9zftIXyJzQvfux+h8X7JjL3r6iQQDSvwN62aBJgh9TNhQXvvTRJNozhP+74cfx6ble7xQjyDdCSEHgyaqvt85FXyEdbb6GChL4YV6WW7H2TMMnR9R12ffz796FYjRUOQoajdmmnz6FiJOhMHeGa7A44oUBOIGhmGS X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(82310400026)(1800799024)(376014)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:54.0411 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c4ea46ee-fef7-4fa0-408c-08dce3e63a68 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=[SATLEXMB04.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: SA1PR12MB8919 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" This adds support for the BT.709/BT.2020 transfer functions on all current 1D curve plane colorops, i.e., on DEGAM, SHAPER, and BLND blocks. With this change the following IGT subtests pass: kms_colorop --run plane-XR30-XR30-bt2020_inv_oetf kms_colorop --run plane-XR30-XR30-bt2020_oetf Signed-off-by: Harry Wentland --- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c | 11 ++++++++--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 10 +++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) 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 d4ef20bc2be5..69d41b32f529 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 @@ -677,6 +677,9 @@ amdgpu_colorop_tf_to_dc_tf(enum drm_colorop_curve_1d_type tf) case DRM_COLOROP_1D_CURVE_SRGB_EOTF: case DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF: return TRANSFER_FUNCTION_SRGB; + case DRM_COLOROP_1D_CURVE_BT2020_INV_OETF: + case DRM_COLOROP_1D_CURVE_BT2020_OETF: + return TRANSFER_FUNCTION_BT709; case DRM_COLOROP_1D_CURVE_PQ_125_EOTF: case DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF: return TRANSFER_FUNCTION_PQ; @@ -1285,8 +1288,10 @@ __set_colorop_1d_curve_blend_tf_lut(struct dc_plane_state *dc_plane_state, 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) + if (colorop->type != DRM_COLOROP_1D_CURVE) + return -EINVAL; + + if (!(BIT(colorop_state->curve_1d_type) & amdgpu_dm_supported_blnd_tfs)) return -EINVAL; if (colorop_state->bypass) { @@ -1322,7 +1327,7 @@ __set_dm_plane_colorop_blend(struct drm_plane_state *plane_state, /* 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) { + (BIT(new_colorop_state->curve_1d_type) & amdgpu_dm_supported_blnd_tfs)) { colorop_state = new_colorop_state; break; } 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 0578f33c8422..7fd274dc89b7 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 @@ -33,14 +33,18 @@ const u64 amdgpu_dm_supported_degam_tfs = BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF) | - BIT(DRM_COLOROP_1D_CURVE_PQ_125_EOTF); + BIT(DRM_COLOROP_1D_CURVE_PQ_125_EOTF) | + BIT(DRM_COLOROP_1D_CURVE_BT2020_INV_OETF); const u64 amdgpu_dm_supported_shaper_tfs = BIT(DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF) | - BIT(DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF); + BIT(DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF) | + BIT(DRM_COLOROP_1D_CURVE_BT2020_OETF); const u64 amdgpu_dm_supported_blnd_tfs = - BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF); + BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF) | + BIT(DRM_COLOROP_1D_CURVE_PQ_125_EOTF) | + BIT(DRM_COLOROP_1D_CURVE_BT2020_INV_OETF); #define MAX_COLOR_PIPELINE_OPS 10 From patchwork Thu Oct 3 20:01:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821527 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 37E93CF34C3 for ; Thu, 3 Oct 2024 20:03:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 161D610E96A; Thu, 3 Oct 2024 20:02:01 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="SaA1Bmyz"; dkim-atps=neutral Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2061.outbound.protection.outlook.com [40.107.102.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id E1E6410E96A; Thu, 3 Oct 2024 20:01:59 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Q7pejosnBPRJH2N1NigkFvocYBfPZ55RNnWRmZU8Zpoi4LYM6fUJRebBui+Nlyn0BsgBdINUYKwICGF7n0Qo5aILVEjeGRDVYwLJ+X1GiVcJzfdoUYxw54AMUIksb0qTKTz8zyjpbWVVtywCTdyGfrhH+IpfJoLDzAUUtCrXiqCgH9zgPN6+NHTtolCCyBZzsXVVjGSrDTul3Lo6wKusuOwH8Twh5BuUe5a63ZqooUyUpPTuB3Knb4S76hsv5oWrnzt/ht1NU0P4XTlJHNpweLkwSfSmHEawxmeWv5jToioGhX+GyxeGV7ghBXwHXLTZHQamovBlNiglJerDeYGKzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=4hw1GKGgKPkaqx8yCzUsAzoFjN3EEGBKKXelolZ+urQ=; b=Gm2kFpncV96ruHwUvcwvinVyfsB6l7U+OpmB1Lrqj6TDGSQd8+HCpK4+MwHHM+RsND6mnztjSCyAobILvnA9+huDmGzzujC/fK5NMERsOz5tI3YL+KIi2DdZrfIMMp1RM0IOMOvllOS5NuGKyD54IIFzL0RBREyiJC6ZTcgCLr8mrV8/+Y4RGD2QPLmUyfNesor3TZwApCEGqbcjkYvBnWYs9ciFS4aNZSuwLMr6uFuoba31OFwVjG8dLiHUwas92NZHP7lWvo4eGYsvjzFmU7yCJuM2ZSEUXqibZ5thDgg7YN2Anw/ckLEl7MSQr62NhA81xEO0ALyqzmOKnXJKFg== 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=4hw1GKGgKPkaqx8yCzUsAzoFjN3EEGBKKXelolZ+urQ=; b=SaA1BmyzK5qhYOyLvzC0l+9WELNzlotqYr86zXy3DtbRGEMB/WZXdwBo97teQwNM+F3m/VRzSPssLO7TJN/DRXGBIG+dujKw+8P/EQMlmuDz4/4ixStgng0PXcVHUdyS87nfBnOibGL2fFetizZ/uXYAr7e82SFPge81nFKiAms= Received: from DM6PR04CA0017.namprd04.prod.outlook.com (2603:10b6:5:334::22) by CY8PR12MB7193.namprd12.prod.outlook.com (2603:10b6:930:5b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.27; Thu, 3 Oct 2024 20:01:54 +0000 Received: from DS2PEPF0000343D.namprd02.prod.outlook.com (2603:10b6:5:334:cafe::18) by DM6PR04CA0017.outlook.office365.com (2603:10b6:5:334::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.17 via Frontend Transport; Thu, 3 Oct 2024 20:01:54 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.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.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:54 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:52 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:52 -0500 From: Harry Wentland To: , CC: , Alex Hung , Harry Wentland Subject: [PATCH v6 34/44] drm/colorop: Add 1D Curve Custom LUT type Date: Thu, 3 Oct 2024 16:01:16 -0400 Message-ID: <20241003200129.1732122-35-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343D:EE_|CY8PR12MB7193:EE_ X-MS-Office365-Filtering-Correlation-Id: 76e8e255-158a-4c8c-2774-08dce3e63ad1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: XlIjgfuR9TPHPoM2tZaxE2I+AYcXOz4x1yfDzckbXYh2BXCoMrRcsYuluQ238Z6eaUzRL1ZdLDxeOvSlApqUa1gMCsoCKvlZLrGePA2GIrr+neg5PUmrZKxFT9IWmXmlg5eDNkB9LIz7MfnMSdBjsOhrzM5blAcC919+zyo2nKPTTD41Lu+AfZfY3vbFDdErl/ZXTV2BBZaa1xEaE2R3J4CawYRKEbNfVqCFGAiB5avcmQjiBX5Nb6Yaadq/7OrBK4T0VnEaA32i30F70Zd+86k7m7TNYwN32Q/JrgeXpKcAsy33RBkHPjJ41SF0KX4YTWKdWTC6Q/mB01/tQQZnPouHGgcqrQOTzMWbhujZNEd06Otj6bvT36o3hvuNtqmiQPmhbH+c71sJIz6AHORmOxc25s2jzrvjJt1GUuFO/h6tgyY+xYIRsqR7jowKh8ZewWb6PDQuIbO+F02I7xIYrArGD4jJuO7OQtg715k/Dxv3jwdrS2PU24VxoDM0+o3L+zaqieOmCwYOGtB1cooo5uMGE51GJAV9GSCQhqujVCDBNjRtMuRzwWVk5QyurS2Qhy+XoR8y7qDJwyxNbmgCHa5SB5OQas+oMSVIGwKWOlF8YJrk+uNYYO+UOLwDAUrcgRIQcrEaGbfhupOTY+e/lsRIJn4Xewhc0IC0PmXhyojqFvCL741LELqOYHxJEl5+YPtvw8j0b7V8TzJs0jSIKnnqXzLdPBb0iA72v/DKR1PewV/wLLfChJvCLHt3gIuwiiU5BFlG4xJWHmdm/NZEO2glj+uJ7fRO6soMLSFig2GyryZWIAVv6VjeSvBd0SoyBfgCTkdn207Gx1GsRvL6A0PxwXXVmp9H6YPq8XMac22opMCtvcxpeRP5qvE4eFaxk5pYRCr8jetNoKjOCN/Iem8Ti7DAtheiDTbVvtt2gS6RIYVEOzD40dJzcg6RqwMPFZLxBCoc+jMZQ1i2E0Vbgjt7RMNKhaHwwkJnPSg3kcqO5yolk0ygfrYPNP/tzFrMU+YANXLrkTG2W5MBNVojLYod/reWPdGlmj9UWSTJ9kVauv+8vNjWYDm+51+f3U9OrOKTZ1mWxhsjT8IUIoyU5Q3Oi3Ekn/qBz6LqNU4nCIoGra7RpZv7ZgziqzkiHkHfcqxLfa3JAavEG7JyKzuJEq2zncFwQH34GRwClcUfwyCgB8KdmLcQ7j6gQ+IP3BCjE5gvf4V+ipqeqsdDpuYa5joQ26ZY4tRDt/xU5dcQGSdFCPSyPu84AaiZuhFzSCKKCQX9dpljdwPd6xY9zpm7Efle6TZ+PUj55FrYgqeYigm37owXQ4Blk1neIol/Ezut9VgIpQNpFkHnnkaaNTq22fepF+gbPUF+CTiDKMEoXUNBKRsMn3zqTM44rPqTrn6x X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(82310400026)(376014)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:54.7286 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 76e8e255-158a-4c8c-2774-08dce3e63ad1 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=[SATLEXMB04.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: CY8PR12MB7193 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 We've previously introduced DRM_COLOROP_1D_CURVE for pre-defined 1D curves. But we also have HW that supports custom curves and userspace needs the ability to pass custom curves, aka LUTs. This patch introduces a new colorop type, called DRM_COLOROP_1D_LUT that provides a SIZE property which is used by a driver to advertise the supported SIZE of the LUT, as well as a DATA property which userspace uses to set the LUT. DATA and size function in the same way as current drm_crtc GAMMA and DEGAMMA LUTs. Signed-off-by: Alex Hung Signed-off-by: Harry Wentland Co-developed-by: Harry Wentland --- v5: - Add kernel doc - Define SIZE in similar manner to GAMMA_SIZE on drm_crtc (Melissa) drivers/gpu/drm/drm_atomic.c | 4 +++ drivers/gpu/drm/drm_atomic_uapi.c | 5 ++++ drivers/gpu/drm/drm_colorop.c | 47 +++++++++++++++++++++++++++++-- include/drm/drm_colorop.h | 16 +++++++++++ include/uapi/drm/drm_mode.h | 9 ++++++ 5 files changed, 79 insertions(+), 2 deletions(-) -- 2.46.2 diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index c58663327e6b..f06b1d5a61ed 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -793,6 +793,10 @@ static void drm_atomic_colorop_print_state(struct drm_printer *p, drm_printf(p, "\tcurve_1d_type=%s\n", drm_get_colorop_curve_1d_type_name(state->curve_1d_type)); break; + case DRM_COLOROP_1D_LUT: + drm_printf(p, "\tsize=%d\n", state->size); + drm_printf(p, "\tdata blob id=%d\n", state->data ? state->data->base.id : 0); + break; case DRM_COLOROP_CTM_3X4: drm_printf(p, "\tdata blob id=%d\n", state->data ? state->data->base.id : 0); break; diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index fafbaa73b95f..2b7368b337a4 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -700,6 +700,9 @@ static int drm_atomic_color_set_data_property(struct drm_colorop *colorop, bool replaced = false; switch (colorop->type) { + case DRM_COLOROP_1D_LUT: + size = state->size * sizeof(struct drm_color_lut); + break; case DRM_COLOROP_CTM_3X4: size = sizeof(struct drm_color_ctm_3x4); break; @@ -749,6 +752,8 @@ drm_atomic_colorop_get_property(struct drm_colorop *colorop, *val = state->bypass; } else if (property == colorop->curve_1d_type_property) { *val = state->curve_1d_type; + } else if (property == colorop->size_property) { + *val = state->size; } else if (property == colorop->data_property) { *val = (state->data) ? state->data->base.id : 0; } else { diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c index d6af7910ffc0..1d3fef74a30e 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -63,6 +63,7 @@ static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { { DRM_COLOROP_1D_CURVE, "1D Curve" }, + { DRM_COLOROP_1D_LUT, "1D Curve Custom LUT" }, { DRM_COLOROP_CTM_3X4, "3x4 Matrix"} }; @@ -218,12 +219,53 @@ static int drm_colorop_create_data_prop(struct drm_device *dev, struct drm_color colorop->data_property = prop; drm_object_attach_property(&colorop->base, - colorop->data_property, - 0); + colorop->data_property, + 0); return 0; } +/** + * drm_colorop_curve_1d_lut_init - Initialize a DRM_COLOROP_1D_LUT + * + * @dev: DRM device + * @colorop: The drm_colorop object to initialize + * @plane: The associated drm_plane + * @lut_size: LUT size supported by driver + * @return zero on success, -E value on failure + */ +int drm_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *colorop, + struct drm_plane *plane, uint32_t lut_size) +{ + struct drm_property *prop; + int ret; + + ret = drm_colorop_init(dev, colorop, plane, DRM_COLOROP_1D_LUT); + if (ret) + return ret; + + /* initialize 1D LUT only attribute */ + /* LUT size */ + prop = drm_property_create_range(dev, DRM_MODE_PROP_IMMUTABLE, "SIZE", + 0, UINT_MAX); + if (!prop) + return -ENOMEM; + + colorop->size_property = prop; + drm_object_attach_property(&colorop->base, colorop->size_property, lut_size); + + /* data */ + ret = drm_colorop_create_data_prop(dev, colorop); + if (ret) + return ret; + + drm_colorop_reset(colorop); + colorop->state->size = lut_size; + + return 0; +} +EXPORT_SYMBOL(drm_colorop_curve_1d_lut_init); + int drm_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop, struct drm_plane *plane) { @@ -332,6 +374,7 @@ void drm_colorop_reset(struct drm_colorop *colorop) static const char * const colorop_type_name[] = { [DRM_COLOROP_1D_CURVE] = "1D Curve", + [DRM_COLOROP_1D_LUT] = "1D Curve Custom LUT", [DRM_COLOROP_CTM_3X4] = "3x4 Matrix" }; diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h index ca3a480db787..32973ad99f8c 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -133,6 +133,13 @@ struct drm_colorop_state { */ enum drm_colorop_curve_1d_type curve_1d_type; + /** + * @size: + * + * Number of entries of the custom LUT. This should be read-only. + */ + uint32_t size; + /** * @data: * @@ -245,6 +252,13 @@ struct drm_colorop { */ struct drm_property *curve_1d_type_property; + /** + * @size_property: + * + * Size property for custom LUT from userspace. + */ + struct drm_property *size_property; + /** * @data_property: * @@ -291,6 +305,8 @@ static inline struct drm_colorop *drm_colorop_find(struct drm_device *dev, int drm_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop, struct drm_plane *plane, u64 supported_tfs); +int drm_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *colorop, + struct drm_plane *plane, uint32_t lut_size); int drm_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop, struct drm_plane *plane); diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index 6fc1ce24800a..40cc5c661cff 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -888,6 +888,15 @@ enum drm_colorop_type { */ DRM_COLOROP_1D_CURVE, + /** + * @DRM_COLOROP_1D_LUT: + * + * A simple 1D LUT of uniformly spaced &drm_color_lut entries, + * packed into a blob via the DATA property. The driver's expected + * LUT size is advertised via the SIZE property. + */ + DRM_COLOROP_1D_LUT, + /** * @DRM_COLOROP_CTM_3X4: * From patchwork Thu Oct 3 20:01:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821524 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 03C9ACF34C5 for ; Thu, 3 Oct 2024 20:03:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 749F710E960; Thu, 3 Oct 2024 20:02:00 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="sd5hrjLg"; dkim-atps=neutral Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2058.outbound.protection.outlook.com [40.107.220.58]) by gabe.freedesktop.org (Postfix) with ESMTPS id D873010E95C; Thu, 3 Oct 2024 20:01:58 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hcJ64RxFfXq7knoQGlo6zzpg3GIdlnOb5DwSdERsvc3CINFaHhu0GEfLByttPK4tJRJxs+NR8dyKQdtfITt6+ktdiSuqXEGYbRg3qB1GcsI1NcC0L9usqfkQR7fvnW6/+wFmHjmEqoevnfVVryBtdnqhGV0czNGt81U4avWZRzC21qgmZ1MygKxTd4LUUctClmtAO9DtFroR5qT6dDXhTEGf6Mb83cUHHT2j/nGUp59CS0ooO0JnSxF3+6ujc1hKO7TGbN1012qLagW8y0MTqwk3GiqYmUK2dWIkyEKVH4wAILatJAsqYHgMc8CzQ00H2n/Hbm7Se/TyvvRhPljtTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=XkeoRwygk/EYZ7WgeTbXESKt6iDYS/PlsqH8UoTKiCU=; b=Z1o/U9ivS4psN+EmlUaVp18l9eL86vwSO+STTl0M0MhzflbSYRWTh7ofRd5fw8lWoKGO1OqJYQjHHZUDRRWc1rxEUh52BdgWIUXtKekf1sejI6c9TjW4HnDQrCa99okIU0yIpU4I+q5k0SnR9YH9bVtx64sE3Inp/AzDXyfdRwqO3+Uus9xtyb1VmJM3eI6Fe5X+QmS7xTiSo7mG/ZOzGy1oszDSp8dS++ez9+oAUDDy+Iu/nSI1ixdVGSclUeZLIgnFE6c09pthhePY5XUs6tJyy9uWOOI2SSNnPn6786ufPqdYBxRY43Q7fZNnqgdTyI8Sykbo1Yqo5pJ0Cx515A== 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=XkeoRwygk/EYZ7WgeTbXESKt6iDYS/PlsqH8UoTKiCU=; b=sd5hrjLgtAxvzXfBuELgh7o27mcf8XEXOKBspo7jsHKJv8vnhi6NsT9kPPOqF0YNwK3JcPX7tqyMkhj5zOvoPYu5HyuIv/DtW8iwZ5/FY1QAOSz9zYxV9CPL6Ltnlykg6iAfh6+/SJpp0huMw5y2xUM+0OYNuU/IpjKBg4CmwZg= Received: from DM6PR04CA0013.namprd04.prod.outlook.com (2603:10b6:5:334::18) by CH3PR12MB8972.namprd12.prod.outlook.com (2603:10b6:610:169::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.27; Thu, 3 Oct 2024 20:01:55 +0000 Received: from DS2PEPF0000343D.namprd02.prod.outlook.com (2603:10b6:5:334:cafe::6c) by DM6PR04CA0013.outlook.office365.com (2603:10b6:5:334::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:01:55 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.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.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:55 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:53 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:53 -0500 From: Harry Wentland To: , CC: , Alex Hung , Harry Wentland Subject: [PATCH v6 35/44] drm/amd/display: add shaper and blend colorops for 1D Curve Custom LUT Date: Thu, 3 Oct 2024 16:01:17 -0400 Message-ID: <20241003200129.1732122-36-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343D:EE_|CH3PR12MB8972:EE_ X-MS-Office365-Filtering-Correlation-Id: 8cc2e658-9faa-4262-d51b-08dce3e63b1f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: bIQw8uHFbaSIpMJSpRIaS3whenFGIr+Evm5q2O8DAJdEQDzpBE4hAy2dznZdW7Lt4z4x+CDT8IRj2TnTLB0KcRvEOQw2iNhL1AA8P4YwMT3FzaFPeUIZhxHca5o2Vf7RlsZao9zLw5sAEezJp8uPWEPV46FTvEyFOspdcxTr2rFygFUwOY3u4bvA+WMuJKQkLdD3wDXd5Z9jK3fpzK1d9iio0f3/8KfnIeC/ZCXbDpoNyS3UvatUv1C4AxgD2nh0k/zodpjLLtRMETYQSE0irJewhTBO0FIUmZn9F2SZ/ndrOCt1hgVylkHOWgTY1zwYEH3gFozSaI0ZPEalSbBF0cbJ0811AsWkn2NBo9TsW0Odg/GRZuN0CbJZ7de1sxrkLT02Ea1uOLc3cfdAyrpwIKpOMWA4anOBveYrVWgA+LgeDi7ZcC6TVL5rU99iIjV6TVydn6LR8ZNWoRftIC9EBbBuoym9Q2JNofDqkDlCHqj5G4/MksKeyFSlL83UzVu4jjiC7QAoTFnKVQwjgrH21HpNE0IUoimZQyxf8wp6plM52ajcCxrjySMJybFhsEurnFZHDxReiF6qCoylqC49N42S/gL7IKoJGYEVPTerum9Yu0o42lNb/AqIVn03Sqrkdil3hRAi6x/1OcC6xVqP9E0Dv4TBiewk365lYgiPdqQ1jvn+4XoGL4EATyKZHUfE/gKzHklp8rBHALKLzZ8qnlZk92l1skDFlaCXTzxwBZ6Vz53SacsyB1VnxKUJi5YPiptUUbjQOAYNo72mDjNk/p5DCMz1KhdGITzNgEZYnCKC6mmCZbAV+5JVD856tU+WRVfQlJdNuPddcbsFBx1JEkOx2wwoNf5XBjyD5XRCI8kR3PZXEcaOVPSDLj0wY8bVIVNlEPHjwkYMxybp0NaJbdmB91xc4cuOma7Ad42DfRqhKO9pgAjv87v4AsRLTUjUGgZUERv4SdaCV/EnXspHoobWqRGRCi2c2imcVO+SX5WzoDWzSgV8f0D5oVr2pbd1z+sbcB6jPP8fyvmMbok/sUuZN2HzRdxmrUG8JBA1rJJUC0lfcAJrnO5RJ9ka8AwoqdXWn80H708aXP0OqdQC6dJpNKKRGF0kfDRwp1aEQYwssBaPxDZ9Q6WxZ6V6uweOBL5CMNpJI5AFlJRSEEym4b/H7AvV2kizbYzCCOlVnUHG8TCSR3yvKrZHp6xRvpCLHa2MEz+rSIwdaZy80dUX+viYbCOtjUUW/HWLlnilQjmR7DvboaLDtxtxhUoWNefF9+yTaTDiiZUQevF3OVld4eax3dlTEqfZNoh3teR+k6azM4c1ysaUxF9S46tWpnyELygxSNGst05m0cm0yWPIoVZwmjGdMLHjN/2mgo3PInjOt86TRoYJBQ05gV0fCkRE X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(1800799024)(82310400026)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:55.2442 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8cc2e658-9faa-4262-d51b-08dce3e63b1f 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=[SATLEXMB04.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: CH3PR12MB8972 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 This patch adds colorops for custom 1D LUTs in the SHAPER and BLND HW blocks. With this change the following IGT tests pass: kms_colorop --run plane-XR30-XR30-srgb_inv_eotf_lut kms_colorop --run plane-XR30-XR30-srgb_inv_eotf_lut-srgb_eotf_lut The color pipeline now consists of the following colorops: 1. 1D curve colorop 2. 1D curve colorop 3. 1D LUT 4. 1D curve colorop 5. 1D LUT The 1D curve colorops support sRGB, BT2020, and PQ scaled to 125.0. Signed-off-by: Alex Hung Signed-off-by: Harry Wentland --- .../amd/display/amdgpu_dm/amdgpu_dm_color.c | 168 ++++++++++-------- .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 32 ++++ 2 files changed, 121 insertions(+), 79 deletions(-) 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 69d41b32f529..10c7a37262ec 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 @@ -1212,38 +1212,6 @@ __set_dm_plane_colorop_degamma(struct drm_plane_state *plane_state, return __set_colorop_in_tf_1d_curve(dc_plane_state, colorop_state); } -static int -__set_colorop_in_shaper_1d_curve(struct dc_plane_state *dc_plane_state, - struct drm_colorop_state *colorop_state) -{ - struct dc_transfer_func *tf = &dc_plane_state->in_shaper_func; - struct drm_colorop *colorop = colorop_state->colorop; - struct drm_device *drm = colorop->dev; - - if (colorop->type != DRM_COLOROP_1D_CURVE) - return -EINVAL; - - if (!(BIT(colorop_state->curve_1d_type) & amdgpu_dm_supported_shaper_tfs)) - return -EINVAL; - - if (colorop_state->bypass) { - tf->type = TF_TYPE_BYPASS; - tf->tf = TRANSFER_FUNCTION_LINEAR; - return 0; - } - - drm_dbg(drm, "Shaper 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_output_tf(tf, 0, 0, false); - } - - return -EINVAL; -} - static int __set_dm_plane_colorop_shaper(struct drm_plane_state *plane_state, struct dc_plane_state *dc_plane_state, @@ -1252,64 +1220,61 @@ __set_dm_plane_colorop_shaper(struct drm_plane_state *plane_state, struct drm_colorop *old_colorop; struct drm_colorop_state *colorop_state = NULL, *new_colorop_state; struct drm_atomic_state *state = plane_state->state; + enum dc_transfer_func_predefined default_tf = TRANSFER_FUNCTION_LINEAR; + struct dc_transfer_func *tf = &dc_plane_state->in_shaper_func; + const struct drm_color_lut *shaper_lut; + struct drm_device *dev = colorop->dev; + uint32_t shaper_size; int i = 0; + /* 1D Curve - SHAPER TF */ old_colorop = colorop; - - /* 2nd op: 1d curve - shaper */ for_each_new_colorop_in_state(state, colorop, new_colorop_state, i) { if (new_colorop_state->colorop == old_colorop && (BIT(new_colorop_state->curve_1d_type) & amdgpu_dm_supported_shaper_tfs)) { colorop_state = new_colorop_state; break; } + } - if (new_colorop_state->colorop == old_colorop) { + if (colorop_state && !colorop_state->bypass && colorop->type == DRM_COLOROP_1D_CURVE) { + drm_dbg(dev, "Shaper TF colorop with ID: %d\n", colorop->base.id); + tf->type = TF_TYPE_DISTRIBUTED_POINTS; + tf->tf = default_tf = amdgpu_colorop_tf_to_dc_tf(colorop_state->curve_1d_type); + tf->sdr_ref_white_level = SDR_WHITE_LEVEL_INIT_VALUE; + __set_output_tf(tf, 0, 0, false); + } + + /* 1D LUT - SHAPER LUT */ + colorop = old_colorop->next; + if (!colorop) { + drm_dbg(dev, "no Shaper LUT colorop found\n"); + return -EINVAL; + } + + old_colorop = colorop; + for_each_new_colorop_in_state(state, colorop, new_colorop_state, i) { + if (new_colorop_state->colorop == old_colorop && + new_colorop_state->colorop->type == DRM_COLOROP_1D_LUT) { colorop_state = new_colorop_state; break; } } - if (!colorop_state) - return -EINVAL; - - 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) - return -EINVAL; - - if (!(BIT(colorop_state->curve_1d_type) & amdgpu_dm_supported_blnd_tfs)) - 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) { + if (colorop_state && !colorop_state->bypass && colorop->type == DRM_COLOROP_1D_LUT) { + drm_dbg(dev, "Shaper LUT colorop with ID: %d\n", colorop->base.id); tf->type = TF_TYPE_DISTRIBUTED_POINTS; - tf->tf = amdgpu_colorop_tf_to_dc_tf(colorop_state->curve_1d_type); + tf->tf = default_tf; tf->sdr_ref_white_level = SDR_WHITE_LEVEL_INIT_VALUE; - return __set_input_tf(NULL, tf, blend_lut, blend_size); + shaper_lut = __extract_blob_lut(colorop_state->data, &shaper_size); + shaper_size = shaper_lut != NULL ? shaper_size : 0; + + /* Custom LUT size must be the same as supported size */ + if (shaper_size == colorop_state->size) + __set_output_tf(tf, shaper_lut, shaper_size, false); } - return -EINVAL; + return 0; } static int @@ -1320,28 +1285,63 @@ __set_dm_plane_colorop_blend(struct drm_plane_state *plane_state, struct drm_colorop *old_colorop; struct drm_colorop_state *colorop_state = NULL, *new_colorop_state; struct drm_atomic_state *state = plane_state->state; + enum dc_transfer_func_predefined default_tf = TRANSFER_FUNCTION_LINEAR; + struct dc_transfer_func *tf = &dc_plane_state->blend_tf; + const struct drm_color_lut *blend_lut; + struct drm_device *dev = colorop->dev; + uint32_t blend_size; int i = 0; + /* 1D Curve - BLND TF */ 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 && (BIT(new_colorop_state->curve_1d_type) & amdgpu_dm_supported_blnd_tfs)) { colorop_state = new_colorop_state; break; } + } - if (new_colorop_state->colorop == old_colorop) { + if (colorop_state && !colorop_state->bypass && colorop->type == DRM_COLOROP_1D_CURVE && + (BIT(colorop_state->curve_1d_type) & amdgpu_dm_supported_blnd_tfs)) { + drm_dbg(dev, "Blend TF colorop with ID: %d\n", colorop->base.id); + tf->type = TF_TYPE_DISTRIBUTED_POINTS; + tf->tf = default_tf = amdgpu_colorop_tf_to_dc_tf(colorop_state->curve_1d_type); + tf->sdr_ref_white_level = SDR_WHITE_LEVEL_INIT_VALUE; + __set_input_tf(NULL, tf, blend_lut, blend_size); + } + + /* 1D Curve - BLND LUT */ + colorop = old_colorop->next; + if (!colorop) { + drm_dbg(dev, "no Blend LUT colorop found\n"); + return -EINVAL; + } + + old_colorop = colorop; + for_each_new_colorop_in_state(state, colorop, new_colorop_state, i) { + if (new_colorop_state->colorop == old_colorop && + new_colorop_state->colorop->type == DRM_COLOROP_1D_LUT) { colorop_state = new_colorop_state; break; } } - if (!colorop_state) - return -EINVAL; + if (colorop_state && !colorop_state->bypass && colorop->type == DRM_COLOROP_1D_LUT && + (BIT(colorop_state->curve_1d_type) & amdgpu_dm_supported_blnd_tfs)) { + drm_dbg(dev, "Blend LUT colorop with ID: %d\n", colorop->base.id); + tf->type = TF_TYPE_DISTRIBUTED_POINTS; + tf->tf = default_tf; + tf->sdr_ref_white_level = SDR_WHITE_LEVEL_INIT_VALUE; + blend_lut = __extract_blob_lut(colorop_state->data, &blend_size); + blend_size = blend_lut != NULL ? blend_size : 0; - return __set_colorop_1d_curve_blend_tf_lut(dc_plane_state, colorop_state); + /* Custom LUT size must be the same as supported size */ + if (blend_size == colorop_state->size) + __set_input_tf(NULL, tf, blend_lut, blend_size); + } + + return 0; } static int @@ -1411,7 +1411,7 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state, if (ret) return ret; - /* 1D Curve - SHAPER TF */ + /* 1D Curve & LUT - SHAPER TF & LUT */ colorop = colorop->next; if (!colorop) { drm_dbg(dev, "no Shaper TF colorop found\n"); @@ -1422,7 +1422,12 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state, if (ret) return ret; - /* 1D Curve - BLND TF */ + /* Shaper LUT colorop is already handled, just skip here */ + colorop = colorop->next; + if (!colorop) + return -EINVAL; + + /* 1D Curve & LUT - BLND TF & LUT */ colorop = colorop->next; if (!colorop) { drm_dbg(dev, "no Blend TF colorop found\n"); @@ -1433,6 +1438,11 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state, if (ret) return ret; + /* BLND LUT colorop is already handled, just skip here */ + colorop = colorop->next; + if (!colorop) + return -EINVAL; + 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 7fd274dc89b7..d2423b98da15 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 @@ -29,6 +29,7 @@ #include #include +#include "amdgpu.h" #include "amdgpu_dm_colorop.h" const u64 amdgpu_dm_supported_degam_tfs = @@ -90,6 +91,22 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr i++; + /* 1D LUT - SHAPER LUT */ + ops[i] = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL); + if (!ops[i]) { + DRM_ERROR("KMS: Failed to allocate colorop\n"); + ret = -ENOMEM; + goto cleanup; + } + + ret = drm_colorop_curve_1d_lut_init(dev, ops[i], plane, MAX_COLOR_LUT_ENTRIES); + if (ret) + goto cleanup; + + drm_colorop_set_next_property(ops[i-1], ops[i]); + + i++; + /* 1D curve - BLND TF */ ops[i] = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL); if (!ops[i]) { @@ -104,6 +121,21 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr drm_colorop_set_next_property(ops[i-1], ops[i]); + i++; + + /* 1D LUT - BLND LUT */ + ops[i] = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL); + if (!ops[i]) { + DRM_ERROR("KMS: Failed to allocate colorop\n"); + ret = -ENOMEM; + goto cleanup; + } + + ret = drm_colorop_curve_1d_lut_init(dev, ops[i], plane, MAX_COLOR_LUT_ENTRIES); + if (ret) + goto cleanup; + + drm_colorop_set_next_property(ops[i-1], ops[i]); return 0; cleanup: From patchwork Thu Oct 3 20:01:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821528 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 B931CCF34C4 for ; Thu, 3 Oct 2024 20:03:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5F63910E97B; Thu, 3 Oct 2024 20:02:02 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="Rures5rm"; dkim-atps=neutral Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2060.outbound.protection.outlook.com [40.107.94.60]) by gabe.freedesktop.org (Postfix) with ESMTPS id B5DD910E965; Thu, 3 Oct 2024 20:01:59 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ezj+TvVVWtGZGTO13e+CYVF95EY/XTRCIEpi/mPhP6quIf0tbMk+wmNAxefB+Wl3zfybqYuh8o3vEA0AdW85hctM3I9H5rwF3lNO9wsDQ1XskKFB81beNrrjhWoKCkI8kGkBuMEX4vPKPxYKKHkRK93NchzvyEhC+3pRcZSRSwAzQqPjkn5r7EgQnfmfpZLXYxaMkTZTJ+PlxzRToUGYM4X952YI6Xu/glA05qTng2V+ZaX1xD/94X2cZcvmeDNOcTgIWdrQdNFJKHIDBhAt7O5WL33+Hvihy4cHetfch9gvodOuzcX2uISigBkDz9fpYZ2g/hTPU6cCLIoLOsB+NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=ylhan1TVFO+eSv9JAnQM9kdnsm/e4LzzQyOa165W2Ig=; b=M/NJQ3SkAqv8vQ6IyToHL5l6iJqw0pKl2XPCwy5ryIyqtXMVUoqmiHsoRuLlWRVdKzUvJ7upS+i5K4vHnYA7koAta7lX7M/39ZYblRC3bComF4vnEM6ZNKMTavKStLsQlhZeoQIe+b97UCgi+31NCIM+At6kGNfrcFKWGQa62M+MLg3zX+TLn4jenMQuAbkbl+DMLQjirt+KGXwG0K5COvHJZVjGKlfVmj1NHf71VR3VQoqlvMdhKNt9Uqy4v6DEOi7cs4jXuHE5g5CO1peQb9wl9+92fs9cbYLohhBEMlC7Si9iKqhb+EtwBSFAbRUA+LLk8W1/7ke71ZoOU4ahbg== 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=ylhan1TVFO+eSv9JAnQM9kdnsm/e4LzzQyOa165W2Ig=; b=Rures5rmkV3irdJPXaqmGj1PMxJmNC4lP/mnIjz7EqcEH/kMbT5Ve/tiqoaNSSAc50fFWS8W5Yzq5Gnb3SfQbu8SqKu9Kf+B/j0P7o2aNpR9QI8HhcxS/xldBqF7YyU6ZagOgcH0FNMf7PrImLGEswh/ncbVenjxjyuGqO5ycHI= Received: from DM6PR04CA0003.namprd04.prod.outlook.com (2603:10b6:5:334::8) by DM4PR12MB6009.namprd12.prod.outlook.com (2603:10b6:8:69::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Thu, 3 Oct 2024 20:01:56 +0000 Received: from DS2PEPF0000343D.namprd02.prod.outlook.com (2603:10b6:5:334:cafe::6f) by DM6PR04CA0003.outlook.office365.com (2603:10b6:5:334::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:01:56 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.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.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:55 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:54 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:53 -0500 From: Harry Wentland To: , CC: , Alex Hung , Harry Wentland Subject: [PATCH v6 36/44] drm/amd/display: add 3x4 matrix colorop Date: Thu, 3 Oct 2024 16:01:18 -0400 Message-ID: <20241003200129.1732122-37-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343D:EE_|DM4PR12MB6009:EE_ X-MS-Office365-Filtering-Correlation-Id: 510f1706-2708-4e21-f7a1-08dce3e63b83 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: jA4pbgP3dCm3WqwTUvYv9O6EWrcM5mrkE709xIXaA1TEW1nfk5GXEN+HS3AYBJTEUMSpz5dJM32c/xGnP0H+9c9/trneEajyouJXkuXVU2V3RtK7PRnbcor2Vge/OjgxPilL6egPF4Aht2Fxoc7LxwYlsmBkACPYN1l+C6BMeukOz34i759GnR2dkT1osRx0nN7w0wOnm4kPTNl/WG4/kAXwUWavuSN1n8GSAJ86kntD5JdtsMj4GRK8imO6uUsNA2Y8c//tfneOckQ0vF0G5YNKXwO2nuy7JU8GVTzOjEiXlmjzBXa9gAQ9b2/5j6knVVTVU+EDPmQHwDaGvdWcLKuNoUSAbZs9C3wX+8s1FzDSugTQucoXWFNjdEnlaAwLW66VcG4RK7DEhxkVFrgBQGP223Z1On/y4m7Hgz5dg5+aBcymjhwLaxbHmyCnNDvCN57AVgLwLR7BXnmyWZNHXTt4t7/0T659Vc/qjVFpNgj4nPUAtOgix0yIBkWcGBU75GsuuQALqEltr+UnM6G5uTa6eyRhugOsKdYoIkVx6eAaQ1JGNAqnMbvmPFtftqpnYp8CiKDDxmfqJINng99RZLNJV5tB7XOQU+Lp8YvFgowQDDezGEvym6TbSi88BaGGw4OTzmYawVHqaZ20Kw9Yj5qI/DmaFxDHEUlmNnlqMRnA0pXYf1oAZFo1LkK1pN1NlVxVrAU9HFymV7nqu5HyAxlEQBTGtyQXje8HvR90RN4mZ48zjIckilE8QpTgDRY+LTfnJ8ErRU+6Bo0oTXV8RNH6y6jvUNfk5GDzbJU/0KruRUJCO4h2PTBdIVYvVXC8aaatnosOCuukfz9Dd6XnE4ovCXMgQrefrVm5rJyIbhTdEVa3snkRknKjfh8eSYguB+HDJEx6WyJwj9zRRfK3KYOGvqYV4KxT0h1t+hVmsqm402IWflGShxqdxsPQ4nGtJNkAxZUxAYauaQN+GncAxa2pxZc0/3Ll0R5HhvXoEvmuE6X5gOe6MmlcjD2gFc2ZQZMU1vy6p5NFFXIn5Bs1xCDvR/pVoassM1zmXvI4JVqnZCYSxgStM5/Y3bob5LNNZuS04VAaEM0Ix3nirjMvTQeqTCrPv0R9uIF7co0gYWgBZsL7ADZiLvbDjQ1S6rJsVL/ltKU6lXzO5xtyCGMhxvdhX7nFdkEke3gw8Ux9Es0PUiDVbLhhc4ytNRocVDEThQVZ6flxOfRrTgcjr578xQ9vIZH/lj7SWNPSPYtqlqhFA7igxKg6dr1zDagp5jOofZbMvNJxZ0+ECyyvvDiHTxRr2t28jRrfCaFcsLrDUUXGMIJq26/jh/KDfa1R9BGY7bA+Af0i9ROQeZlY0fl1io+QOZKCP4+b0+6+Ozn8PlJhjWSgNkdgMnxg9KWbQYKR X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(82310400026)(36860700013)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:55.9317 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 510f1706-2708-4e21-f7a1-08dce3e63b83 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=[SATLEXMB04.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: DM4PR12MB6009 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 This adds support for a 3x4 color transformation matrix. With this change the following IGT tests pass: kms_colorop --run plane-XR30-XR30-ctm_3x4_50_desat kms_colorop --run plane-XR30-XR30-ctm_3x4_overdrive kms_colorop --run plane-XR30-XR30-ctm_3x4_oversaturate kms_colorop --run plane-XR30-XR30-ctm_3x4_bt709_enc kms_colorop --run plane-XR30-XR30-ctm_3x4_bt709_dec The color pipeline now consists of the following colorops: 1. 1D curve colorop 2. 3x4 CTM 3. 1D curve colorop 4. 1D LUT 5. 1D curve colorop 6. 1D LUT Signed-off-by: Alex Hung Signed-off-by: Harry Wentland --- v6: - fix warnings in dbg prints .../amd/display/amdgpu_dm/amdgpu_dm_color.c | 50 +++++++++++++++++++ .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 16 ++++++ 2 files changed, 66 insertions(+) -- 2.46.2 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 10c7a37262ec..9861e2608d16 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 @@ -1212,6 +1212,45 @@ __set_dm_plane_colorop_degamma(struct drm_plane_state *plane_state, return __set_colorop_in_tf_1d_curve(dc_plane_state, colorop_state); } +static int +__set_dm_plane_colorop_3x4_matrix(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; + const struct drm_device *dev = colorop->dev; + const struct drm_property_blob *blob; + struct drm_color_ctm_3x4 *ctm = NULL; + int i = 0; + + /* 3x4 matrix */ + old_colorop = colorop; + for_each_new_colorop_in_state(state, colorop, new_colorop_state, i) { + if (new_colorop_state->colorop == old_colorop && + new_colorop_state->colorop->type == DRM_COLOROP_CTM_3X4) { + colorop_state = new_colorop_state; + break; + } + } + + if (colorop_state && !colorop_state->bypass && colorop->type == DRM_COLOROP_CTM_3X4) { + drm_dbg(dev, "3x4 matrix colorop with ID: %d\n", colorop->base.id); + blob = colorop_state->data; + if (blob->length == sizeof(struct drm_color_ctm_3x4)) { + ctm = blob ? (struct drm_color_ctm_3x4 *) blob->data : NULL; + __drm_ctm_3x4_to_dc_matrix(ctm, dc_plane_state->gamut_remap_matrix.matrix); + dc_plane_state->gamut_remap_matrix.enable_remap = true; + dc_plane_state->input_csc_color_matrix.enable_adjustment = false; + } else + drm_warn(dev, "blob->length (%lu) isn't equal to drm_color_ctm_3x4 (%lu)\n", + blob->length, sizeof(struct drm_color_ctm_3x4)); + } + + return 0; +} + static int __set_dm_plane_colorop_shaper(struct drm_plane_state *plane_state, struct dc_plane_state *dc_plane_state, @@ -1411,6 +1450,17 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state, if (ret) return ret; + /* 3x4 matrix */ + colorop = colorop->next; + if (!colorop) { + drm_dbg(dev, "no 3x4 matrix colorop found\n"); + return -EINVAL; + } + + ret = __set_dm_plane_colorop_3x4_matrix(plane_state, dc_plane_state, colorop); + if (ret) + return ret; + /* 1D Curve & LUT - SHAPER TF & LUT */ colorop = colorop->next; if (!colorop) { 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 d2423b98da15..9152f0a771ef 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 @@ -75,6 +75,22 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr i++; + /* 3x4 matrix */ + ops[i] = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL); + if (!ops[i]) { + DRM_ERROR("KMS: Failed to allocate colorop\n"); + ret = -ENOMEM; + goto cleanup; + } + + ret = drm_colorop_ctm_3x4_init(dev, ops[i], plane); + if (ret) + goto cleanup; + + drm_colorop_set_next_property(ops[i-1], ops[i]); + + i++; + /* 1D curve - SHAPER TF */ ops[i] = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL); if (!ops[i]) { From patchwork Thu Oct 3 20:01:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821530 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 7978DCF34C1 for ; Thu, 3 Oct 2024 20:03:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8BD8D10E98A; Thu, 3 Oct 2024 20:02:05 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="cqR/2Exg"; dkim-atps=neutral Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2050.outbound.protection.outlook.com [40.107.92.50]) by gabe.freedesktop.org (Postfix) with ESMTPS id 524AA10E96E; Thu, 3 Oct 2024 20:02:04 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=N1ER3Npkq63WRrRqept/a91MPZlh7uuU25TgUfzo0OjzZqbsqxYEnODfdrDAIqM/B+PckGnZfLSLSQDTh4/QvnZ5TyJt98j97s6CiMoPnML3jwURzVBC2oc2p9E+uKUThUa8T2q2wI8AoCuOi2kFTJF8VwGefBNQ8bBZw0rG3I4XekNS2WhiGOK6KRAFEF5XpiRTbZVek8Y0H39PEOsNmnAu/wBzio5dPJCrSctWyIkn4UaNrfMtRMHJenGeWa98Zca8QAY/rz599nr3mhcXmaxWt147qSk9XhCZnfEzsLQ4Cd9H2IhJzqXuuQmDo99oXMumoC6v+CEoWMB8I9/HlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=AkWHw1EEbSB5aG8mMOI1SVjJAVluRFXOSbOQcN0MFXw=; b=IKBMcAxdcQo9++x0OMZh+lKzISWMgng1QrQv2sLkWaBlKPE8tK8XBNBVvOBB74y+Lf8kschumBJzYhopm1AddvQcY97JPWCRzb7x5PMfZykF4rls2b0Uu1foa67AqkhxYXDzOVWcjLLQZjiMuzNDJB7/zV8Hbm1QI51hjJ13uM09bdBGo2nqHnFgsmG+KTywfys4zqal2wjd2lo2mb4FfhmnaWXeHl2nT5SKDjW4spM6EC0ceJ9y4w8bLmYji5OtWpvr41OBG+boWyVbKbcbqbexKHRqECvgf663rUqtgakFVk5B/y00HQnDLOxSCwbOGyDY7eLPoY9u69YYf+2A1w== 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=AkWHw1EEbSB5aG8mMOI1SVjJAVluRFXOSbOQcN0MFXw=; b=cqR/2ExgkdyLrsgGlNw9AK++t3HuGj6kTjrm6f5WfRFgIF71umKh9cjG5qOsMa3Coybr0XhYr9Hmzu+bYmiSjcABBa7quxtkOkrwUg6NMx+rUmKim9olJMFbkShM38Doo6912n4vrG0I6XzBj2OA50SBQtYhfdx91oDZYtV8IjA= Received: from DM6PR04CA0027.namprd04.prod.outlook.com (2603:10b6:5:334::32) by DS0PR12MB8442.namprd12.prod.outlook.com (2603:10b6:8:125::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.26; Thu, 3 Oct 2024 20:01:58 +0000 Received: from DS2PEPF0000343D.namprd02.prod.outlook.com (2603:10b6:5:334:cafe::e5) by DM6PR04CA0027.outlook.office365.com (2603:10b6:5:334::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:01:56 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.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.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:56 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:54 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:54 -0500 From: Harry Wentland To: , CC: , Alex Hung Subject: [PATCH v6 37/44] drm/colorop: Add mutliplier type Date: Thu, 3 Oct 2024 16:01:19 -0400 Message-ID: <20241003200129.1732122-38-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343D:EE_|DS0PR12MB8442:EE_ X-MS-Office365-Filtering-Correlation-Id: 7c36e7f9-d106-44b1-a55f-08dce3e63bd2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: p6by4bR4K9GctZV98PRVJwD0uiqHBG4IEiGYHnPOEnlj7wEGAFMJcWW+32Dg7HqeOqAp6p9BBqFO479t778tFrbRFMuFFU3PMXQ3jachZpW06M42Xx/ODStVDXzu/qx75cjIwFZPgwI7iWP3KpFk/HRBCRhwIXI4oSI0oB4oROAkoNok2OIaBvOhD4FLTjvtd+NpOHeCC0TPJm2S2zC/XFMKCyzGxNE1zY9qeDjjeiA0SIoFxverCBWUsbeYukHOM2SrDh20foN90jOzuIAJMtGvUu5MzCcKulvvZvvgJDUVHRWVF9fWCKOzmPOqModlqWsmc8xwYJF8uklp4Zghfrt9uxBByiWkukHviZRhbgCJ29Aopx4sK2LZFUaWe/9494p5tJGDpz8Me6n0Lw3kidqvoi8DyDhlHsm4X5mTcy+5lw2dbm1FPNHQT9/sC5pylp2uvamqnMQ6n27iXlVoT50jFcaMn91lZdyhbFl/sBjvAQH6t7+2ePvNg2CVozg1cdPFLqfjplCZDRMGoP7RZMRfxsCfCqfvhUGZhDzDovMV01rpSPwoZnpGP3AoO/D3XS1r12uABrUqo9KI9Azud2KyDV7SLAlld1DDCUA94bl/4G5+DlQam68lwTwioktUcTnY2Qwu7MXbTMQU2O7x3fqiXnXsd74m3gG9z7mbrcwbmzNlQ9lWi2gqam/usHTI0YnAe6Oztqv1FzGF7T7jOLOdYiFPZpDWhJD6kZUTdQkvEz1TeFJo4p5oqd69QQLsbmsihnd0YNR5nY47PHgQguT/cAMLmhbxcQYsCgO3BLm8xfGGRLCJxN8rdF1cVhMI3vjYE+2rRps53DR6BUUnTwRsOycj8icTVlSCWT4XDZSMghBB8C862QSAimMXMTuswxbtiT3BXfi6ynBXNdHNjwsBLJOnOlWSpcyyIavJWTpmaw2oT/J5Tzqxm3BXcFZAIiGjijMeOIv0l1Bs8B/u0ZJTpIIQ9OYVFpkyz83jID47D0Zqgsw5NfdEFtPinZzeKUW+rer+Ual/9pQfiX9mSja3wBXXNmgTiK+SZiI/vfgtP6lBr0DW8LOZL14u6ymQP2lw/iS4FQgFHZnFvxKzJA2FdbN8dhzAi4bfQwjRS75f+IYRHnczu3gjRb8Sj+QKGj5xQUw6rYIob4KHBnU39fq5nc6keNcyHTRdHhaiBYQf3KWfSNGtFyqgbOgtYdv/xF+cWIvh0yf7uAKnbELeZCbGe2fCsdvuEVpc1sVDSUHI6BmSDJl/eGBrjUfjL/PYuxrMF2yDH28REzb6vqcEFTY2qA1EbkT6+ISzdIYww6900bSGRPGU2arSqSeKNXvH1aVrqaQlSnpOvpiU57HtzzDU1BQgYJGfXiOZfpCctN4HR4VeukhkfNZ1ZU/JsUja X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(1800799024)(82310400026)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:56.3224 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7c36e7f9-d106-44b1-a55f-08dce3e63bd2 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=[SATLEXMB04.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: DS0PR12MB8442 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 This introduces a new drm_colorop_type: DRM_COLOROP_MULTIPLIER. It's a simple multiplier to all pixel values. The value is specified via a S31.32 fixed point provided via the "MULTIPLIER" property. Signed-off-by: Alex Hung --- drivers/gpu/drm/drm_atomic.c | 3 +++ drivers/gpu/drm/drm_atomic_uapi.c | 4 ++++ drivers/gpu/drm/drm_colorop.c | 37 +++++++++++++++++++++++++++++-- include/drm/drm_colorop.h | 16 +++++++++++++ include/uapi/drm/drm_mode.h | 9 ++++++++ 5 files changed, 67 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index f06b1d5a61ed..acd8a2fc0270 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -800,6 +800,9 @@ static void drm_atomic_colorop_print_state(struct drm_printer *p, case DRM_COLOROP_CTM_3X4: drm_printf(p, "\tdata blob id=%d\n", state->data ? state->data->base.id : 0); break; + case DRM_COLOROP_MULTIPLIER: + drm_printf(p, "\tmultiplier=%llu\n", state->multiplier); + break; default: break; } diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index 2b7368b337a4..57029e5938f6 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -727,6 +727,8 @@ static int drm_atomic_colorop_set_property(struct drm_colorop *colorop, state->bypass = val; } else if (property == colorop->curve_1d_type_property) { state->curve_1d_type = val; + } else if (property == colorop->multiplier_property) { + state->multiplier = val; } else if (property == colorop->data_property) { return drm_atomic_color_set_data_property(colorop, state, property, val); @@ -752,6 +754,8 @@ drm_atomic_colorop_get_property(struct drm_colorop *colorop, *val = state->bypass; } else if (property == colorop->curve_1d_type_property) { *val = state->curve_1d_type; + } else if (property == colorop->multiplier_property) { + *val = state->multiplier; } else if (property == colorop->size_property) { *val = state->size; } else if (property == colorop->data_property) { diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c index 1d3fef74a30e..41f0ade76b57 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -64,7 +64,8 @@ static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { { DRM_COLOROP_1D_CURVE, "1D Curve" }, { DRM_COLOROP_1D_LUT, "1D Curve Custom LUT" }, - { DRM_COLOROP_CTM_3X4, "3x4 Matrix"} + { DRM_COLOROP_CTM_3X4, "3x4 Matrix"}, + { DRM_COLOROP_MULTIPLIER, "Multiplier"}, }; static const char * const colorop_curve_1d_type_names[] = { @@ -285,6 +286,37 @@ int drm_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop } EXPORT_SYMBOL(drm_colorop_ctm_3x4_init); +/** + * drm_colorop_mult_init - Initialize a DRM_COLOROP_MULTIPLIER + * + * @dev: DRM device + * @colorop: The drm_colorop object to initialize + * @plane: The associated drm_plane + * @return zero on success, -E value on failure + */ +int drm_colorop_mult_init(struct drm_device *dev, struct drm_colorop *colorop, + struct drm_plane *plane) +{ + struct drm_property *prop; + int ret; + + ret = drm_colorop_init(dev, colorop, plane, DRM_COLOROP_MULTIPLIER); + if (ret) + return ret; + + prop = drm_property_create_range(dev, DRM_MODE_PROP_ATOMIC, "MULTIPLIER", 0, U64_MAX); + if (!prop) + return -ENOMEM; + + colorop->multiplier_property = prop; + drm_object_attach_property(&colorop->base, colorop->multiplier_property, 0); + + drm_colorop_reset(colorop); + + return 0; +} +EXPORT_SYMBOL(drm_colorop_mult_init); + static void __drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop, struct drm_colorop_state *state) { @@ -375,7 +407,8 @@ void drm_colorop_reset(struct drm_colorop *colorop) static const char * const colorop_type_name[] = { [DRM_COLOROP_1D_CURVE] = "1D Curve", [DRM_COLOROP_1D_LUT] = "1D Curve Custom LUT", - [DRM_COLOROP_CTM_3X4] = "3x4 Matrix" + [DRM_COLOROP_CTM_3X4] = "3x4 Matrix", + [DRM_COLOROP_MULTIPLIER] = "Multiplier", }; const char *drm_get_colorop_type_name(enum drm_colorop_type type) diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h index 32973ad99f8c..f78ef745887c 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -133,6 +133,13 @@ struct drm_colorop_state { */ enum drm_colorop_curve_1d_type curve_1d_type; + /** + * @multiplier: + * + * Multiplier to 'gain' the plane. Format is S31.32 sign-magnitude. + */ + uint64_t multiplier; + /** * @size: * @@ -252,6 +259,13 @@ struct drm_colorop { */ struct drm_property *curve_1d_type_property; + /** + * @multiplier_property: + * + * Multiplier property for plane gain + */ + struct drm_property *multiplier_property; + /** * @size_property: * @@ -309,6 +323,8 @@ int drm_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *co struct drm_plane *plane, uint32_t lut_size); int drm_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop, struct drm_plane *plane); +int drm_colorop_mult_init(struct drm_device *dev, struct drm_colorop *colorop, + struct drm_plane *plane); struct drm_colorop_state * drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop); diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index 40cc5c661cff..96cb32e6980c 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -904,6 +904,15 @@ enum drm_colorop_type { * &drm_color_ctm_3x4 struct provided via the DATA property. */ DRM_COLOROP_CTM_3X4, + + /** + * @DRM_COLOROP_MULTIPLIER: + * + * A simple multiplier, applied to all color values. The + * multiplier is specified as a S31.32 via the MULTIPLIER + * property. + */ + DRM_COLOROP_MULTIPLIER, }; /** From patchwork Thu Oct 3 20:01:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821535 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 D66BFCF34C1 for ; Thu, 3 Oct 2024 20:03:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0F59110E989; Thu, 3 Oct 2024 20:02:09 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="Nt5k2p5V"; dkim-atps=neutral Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2060.outbound.protection.outlook.com [40.107.220.60]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9727110E910; Thu, 3 Oct 2024 20:02:06 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PIcoMp3vcqpOfEgmlHjZUh5uV4Dg74ozY4TAnj4iOXoCqBgXXuy2TKPKuqOxNRkvRKhKiSu+dbmehoCvhkRc/ss7kzH1FFVgoMDbpj/g2dxumUtCz1RVxZiU4VHmlbZd0roe6/3C2IeeEgDjS6UCBJDJk/r8W1MTd9diCsrp8AjKoJsD5Xsh0h3MSY9DGCD3tERDDUthfofIQE5YCbId0HtS5lgqWdiOcjVncwEvGuE6xqJU4GvLm3yQSgqo/Cvkfa2UW9SH7eahHvpCOoJ2wU5VGTl/+d99uutmmWk87LYBDXKzrqtmpsHQuNdLS4xXffootlxuNN/C58hxMhQFAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=EJnVB93cRXbKDWSkvDnKM9aQuqQPYiGuzi5HvVwt1VU=; b=wsLD8HMmevbwXkAVdnfe71xC/29y1X2gW54wWKpBhLrqU4dphKa1sOsa0TKmx6/khNE0tdrCUHBmw6dxBaHEEUk1J7lpMlKsDYLTb6RF8LEY6XdDPjMisf6QPWbP8z4KrFDk4+cgfKEZvlbyWn7TSYOoOtQrFI53cUUxaDncZhlXlpqQr7HQO2MS6tqj12aXoW6tlzIoqNqC5ICUEzIIC0+vDMTm//TQh5GDq/vJaphvdqxUc4f4dNfwyiQWfIoWR/S8lUkqKgRchWGAtD3GnumZciUcFJZp5b5ReHIWwMaTOIotebeUtRanly2blhx/xpTd0hE3f6ifsNql5kHmNw== 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=EJnVB93cRXbKDWSkvDnKM9aQuqQPYiGuzi5HvVwt1VU=; b=Nt5k2p5V5ftEbxbo2LVjxzEtbxE/+LaaX9LxmTM+v2boye3YIpXi6lhkCgGK0hvnwfcsTrj4JX0T3mL0khAqf8zNuisV9am41LaNY8cf7P6nmh3R7iKrrcsOsA6OB6YZhHSFCBBbsVM16EPC7w7nYSg2qgxjZyuL+1Fac6so6/U= Received: from DM6PR04CA0021.namprd04.prod.outlook.com (2603:10b6:5:334::26) by SJ0PR12MB6757.namprd12.prod.outlook.com (2603:10b6:a03:449::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Thu, 3 Oct 2024 20:01:59 +0000 Received: from DS2PEPF0000343D.namprd02.prod.outlook.com (2603:10b6:5:334:cafe::b3) by DM6PR04CA0021.outlook.office365.com (2603:10b6:5:334::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:01:58 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.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.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:58 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:55 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:55 -0500 From: Harry Wentland To: , CC: , Alex Hung Subject: [PATCH v6 38/44] drm/amd/display: add multiplier colorop Date: Thu, 3 Oct 2024 16:01:20 -0400 Message-ID: <20241003200129.1732122-39-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343D:EE_|SJ0PR12MB6757:EE_ X-MS-Office365-Filtering-Correlation-Id: 3a807480-586b-4133-93f3-08dce3e63d46 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: +tvaowef/mgJ+CxsEjpVUdKe1BYoIL//JyAG45/bYKR9T+FAuYv1cGVq5kkeGDKcoExhl5Y8dyrdUg6ZbzqWuq56HClkPY0v5t5fNoVrrT6wjsihAbl6bg9Z/RoyJxO0P9kXL28AgmhIQDjqcKFEgPybsPDjP3OoXatw3UANcs0xL4K4e1EgiWQucC3+qcf8CTsa3hGtA0Uyvo80JsQ1G8+V7KdTi9CnXCzObFyPdZH00qQ+Dhyt221mCtQS2SM/aol/YQrT4BuOqNVOW/vSqDPiTnopfdJ7m4N/s1IgWdT+DSnu+evw/wTn8R8UHHSEtafDh5nESQcxraGH2B/rqEfT1mYu+wCBOfqqsOLT6jNhv2Ebub9xtnYIhduzBWaGfCEEArw/6KOnJU4cntHy/750tjHUubJSFVudVD9YW0IZnT3J/X8V55rZPHoUjlrt7S+GrMkG2aHnjQiILke2x0qPVw4UlHPZrgtwPpzZH3Uae3ZBhEeUmF2akEhk192KbJJ4NHTNRWMF3YzlpeHBQz5WOg7Bq1JlcX5qAOqaAY1qFz0LVIdBCDaRoLbJiK89eii7O+R0p3HGAkMDi0yrthlB+WQAAucYj0/PfyhOZHtLFi9gFcB7PvE+LRZb9ndLm1ANcsCWuupx+2B1oNfymRrPMys2bIWSZxmuFetncYfgj1PZ2ZVlOzAeDcz5qC5cxetpiLkvmVgBYG5JeuuSODFnq919lRm/v1EsVtUDSAUJumBbU/wcDM61AXTA4bTK/w7kzW5T2pu6Cny9n1WjGhf0bKRE+kVmWX+02En+6g3/74A6SNaNLjlEJnvCN0JSqeMXPP51eOMhXUYuQmzSHMOp+oC34UmKErx3eKAx2UGzDS6jSwj8ECRRcZvzR49O9lPidJGNooEzWEYYbL+9t5doWgpCDDWmzdFrgYYf/+jdOIrkaR4WaG+KiWlFYIDxPORNkc/VK5VYrkPiWK5crhArM9QPBz6opSsAIzLCQ7tlro8PystnlT7DEvTFSlBybaGvNRtFbfgasgg6d30N5bWzfM/nNu2fvrv/lI7mq+KKl9MwIrY2c7kw0wlZEaUaBJuxSA1SX97iLQ5NiWI3rw2l2pGPqerTD6SXfTcGPUcw14WiDXq1Lw/75WLVRTde/84B0kJ7rlNjXGxOy4v0xU/TIneVgwsAeK3VuCJ6zcLK4wpaKH+EpJ0oBokzTHun5bM/D1q09/6Qil0W5Lq/9VM1XTk6vTaZswtweV4ZzsxgU2t+PnH+yEkglyV/WSWFfGxZOB6eAkZkArl9rHXjU3VOzgGtzKCDP2ff9mG9ig+CCqMyoSCt8WdVxqgaUMwaj6FGA/BzMBU12IfNnrTvnVl8Z9DMjrVtgZ/AAbQM0CFxOrrDFgns1mQN7wek+u7g X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(82310400026)(376014)(36860700013)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:58.8536 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3a807480-586b-4133-93f3-08dce3e63d46 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=[SATLEXMB04.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: SJ0PR12MB6757 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 This adds support for a multiplier. This multiplier is programmed via the HDR Multiplier in DCN. With this change the following IGT tests pass: kms_colorop --run plane-XR30-XR30-multiply_125 kms_colorop --run plane-XR30-XR30-multiply_inv_125 The color pipeline now consists of the following colorops: 1. 1D curve colorop 2. 3x4 CTM 3. Multiplier 4. 1D curve colorop 5. 1D LUT 6. 1D curve colorop 7. 1D LUT Signed-off-by: Alex Hung --- .../amd/display/amdgpu_dm/amdgpu_dm_color.c | 40 +++++++++++++++++++ .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 16 ++++++++ 2 files changed, 56 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 9861e2608d16..cd545adbb13a 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 @@ -1251,6 +1251,35 @@ __set_dm_plane_colorop_3x4_matrix(struct drm_plane_state *plane_state, return 0; } +static int +__set_dm_plane_colorop_multiplier(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; + const struct drm_device *dev = colorop->dev; + int i = 0; + + /* Multiplier */ + old_colorop = colorop; + for_each_new_colorop_in_state(state, colorop, new_colorop_state, i) { + if (new_colorop_state->colorop == old_colorop && + new_colorop_state->colorop->type == DRM_COLOROP_MULTIPLIER) { + colorop_state = new_colorop_state; + break; + } + } + + if (colorop_state && !colorop_state->bypass && colorop->type == DRM_COLOROP_MULTIPLIER) { + drm_dbg(dev, "Multiplier colorop with ID: %d\n", colorop->base.id); + dc_plane_state->hdr_mult = amdgpu_dm_fixpt_from_s3132(colorop_state->multiplier); + } + + return 0; +} + static int __set_dm_plane_colorop_shaper(struct drm_plane_state *plane_state, struct dc_plane_state *dc_plane_state, @@ -1461,6 +1490,17 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state, if (ret) return ret; + /* Multiplier */ + colorop = colorop->next; + if (!colorop) { + drm_dbg(dev, "no multiplier colorop found\n"); + return -EINVAL; + } + + ret = __set_dm_plane_colorop_multiplier(plane_state, dc_plane_state, colorop); + if (ret) + return ret; + /* 1D Curve & LUT - SHAPER TF & LUT */ colorop = colorop->next; if (!colorop) { 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 9152f0a771ef..a431de9d2b8f 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 @@ -91,6 +91,22 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr i++; + /* Multiplier */ + ops[i] = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL); + if (!ops[i]) { + DRM_ERROR("KMS: Failed to allocate colorop\n"); + ret = -ENOMEM; + goto cleanup; + } + + ret = drm_colorop_mult_init(dev, ops[i], plane); + if (ret) + goto cleanup; + + drm_colorop_set_next_property(ops[i-1], ops[i]); + + i++; + /* 1D curve - SHAPER TF */ ops[i] = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL); if (!ops[i]) { From patchwork Thu Oct 3 20:01:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821532 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 3E66BCF34C3 for ; Thu, 3 Oct 2024 20:03:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E038F10E910; Thu, 3 Oct 2024 20:02:06 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="QqhXb5e2"; dkim-atps=neutral Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2074.outbound.protection.outlook.com [40.107.223.74]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1CF9A10E985; Thu, 3 Oct 2024 20:02:06 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yTKtd/HEXqerstYLjMptujVgG8LV7jtSUJUTZVezKCi8lIdTl0QSIyKuq4ru/x5Ikgdd4b5NvvgEw5YQNb3ULfAWIdZ5o4EpxKarZOBBAsxeQPtIl3Su9QBU8qqerYebHIxQ2E4Xl7neZeyk0WVgF5Ic0zzxfPSha/J2ZQZ57mpg6/WjaZgl20R9cYzRIkUVjGwbaNPkP574SiaELKU3uxPTefd1qeGa5SW+0S0xDiacE4EScwDdsQquIfEn4VF+FDbp0raIOL7q4wmByXfUslpoUHEH+wGMBZLiiBmf98PnD6HStFNFXh9O/WQzVMy34i14fcyMOtBoDH7H0JJnlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=ih6N8Q9d71y233omgDpMvBSPfujdk5ey7D303tnDnB0=; b=bk63Mp0F6NFtdtrR2QTKMlo34AwXiiIQM8aN8pwNFAbPdvlQh0d0uy6WogLJIgLLj318ux7kyCVDygmNmiqQLkgFz8rn+vmyHiHM1PxLwmnKGVskzNLvmApsufOk7OIRQR3T2KhECeEhlG7ZzIFzATn9h2uxLk12LUmwgIWB09vZy+c8xKipPhXBfZgW7ofXMjdaky++i4lMvGAL1SKA0urfNuKn9zTs+Uz8sq2O1kJgz8LePDU3TR/aNooeuFiYsk47kAl88HGM2hFsnjMUCKYmgNJzowDcs9f9MNpurJkyz18lyZMZqZ0uaVHMVVN5xd228xLykz4v2RUNnhOWpQ== 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=ih6N8Q9d71y233omgDpMvBSPfujdk5ey7D303tnDnB0=; b=QqhXb5e2YW7I7twEzpFjQZJnwxMC1JxI1CP7PLRfE2mMF1GGSkGS8u6/BiknyoYCeL8DfHac8xI+7TK5dt8OIfyfqzcaQD9M0UJf5r39Y/wmHv/rzlU1WZrZE9xUyoeh5OX/0q0rt+kKiM9hPp9wuT0UuguIPzmqHGYW186rOv4= Received: from DM6PR04CA0028.namprd04.prod.outlook.com (2603:10b6:5:334::33) by PH7PR12MB8014.namprd12.prod.outlook.com (2603:10b6:510:27c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18; Thu, 3 Oct 2024 20:02:01 +0000 Received: from DS2PEPF0000343D.namprd02.prod.outlook.com (2603:10b6:5:334:cafe::c2) by DM6PR04CA0028.outlook.office365.com (2603:10b6:5:334::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.17 via Frontend Transport; Thu, 3 Oct 2024 20:02:01 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.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.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:02:01 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:55 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:55 -0500 From: Harry Wentland To: , CC: , Alex Hung Subject: [PATCH v6 39/44] drm/amd/display: Swap matrix and multiplier Date: Thu, 3 Oct 2024 16:01:21 -0400 Message-ID: <20241003200129.1732122-40-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343D:EE_|PH7PR12MB8014:EE_ X-MS-Office365-Filtering-Correlation-Id: fdbe7ae1-8d0c-4c0b-2050-08dce3e63eb8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|1800799024|376014|82310400026; X-Microsoft-Antispam-Message-Info: OIyNzCKk2SA2WkLrhCtzlQMBYBlU4h00dvtU4MfC+zpxlfMfIn7TxtRm1k3GrMV23i+ENK+1wEdt7iMXxBXsoMzZS+z39ssZn3KGaRUq9sFhXFdTSpun/rwKkcRFnxdY8nA6XlyneAvYyIkYqXirtqL/16MXlRYu8qoSmv4bgFhT9vhR+445ICFfyBostTFVDM7L5EV3+OUrM71RdNLPrOdEF3hnFXSOMYumA+JM2EhY7IuktRrRVgRtJU1ii0hh4mFva2XPkwz1jROCjjkAVp8E+NguBBfweY47w6iCNLFJik9JcGNt+Z+cR8fOa0PER2XUHDn5jA/f76sBFUakrUUF8TjG6KWf2FCDtDAREilHDZkwBNTdJNUd9PHWX6XSQ3Fgp5D3VdgY67EQRyNYu3vaUZDBSQD4T+yFweJG0T0/F4JoGoWV6bRkd4qtRz7TKj2IkqEvi+K+/b9yWC09kQ3RfhrGPL+1UptwwMJbDsyIyIWyx1756+XvIPV5Mrs5F6iqfpw9z9NITvEUghio603s6ou+sEbTtFe5ZNoE3vSh0GRN4xagInOO7kqexZdbMoNcsuuc3iwSfgKkSTu+7ybEAA4PyzDbnnBbihrBglz2h2vK0lbG7R0GkJKEgmdIohWjjZKhMlVWl4LEP5QYUaLBkxTT3KBKx0p/LI919YjVZPpWA3fuM6UCsW75mFiJU8l2WazsdANkUz/v/NGY0CmKq3cmfeVFZ5ebRxRNXZ1XsNCbrJM+CWeU6YI4rRifBhnrs7f7RICUoxoueVIVFqrPWfWm2FYkdt0KWz0ze29mtuteAm30ptFGCZDhffc/u3ldZNFPJF5QpV/ilyHvR1TU2IfqQ8Gp+mciXGDNm/6fpsfZrLlsfWQaOZvJHOJxp8ENX4WOjbm5zwSG/GhdId208tZKMPSbx/OIgQGTExQ4jMeCkspA7Z+3XWyHd+BvLnD4gZUCl+omiHAh87yEcDOPu5zyzYLSVZeO00g3gECGDWaMT18Z9e1YHHh7XnNVpqu/BGFV3i9MSiYkfko/l29XPc6YMnJoKOmIqF0fI8QfScoH4Kp/Wh7KHXGWA6ktnRfG4sUnAKt0DcN5wp8SfCCN4j81D18VAA1NG4uXzyrVjnSfltFM67q1lYUEIhWQ5auwermdvtueD6fC++iz03z2Wqdv+uODxmJ9EGP90at8WOpIJbmEdRldpe23a8e6MeA9JA4UlFba7ssMN4NoeWoofKHhooM6/Zu3JmB610YNFkcnEWhql6WWN15tckMl66/z2m0dJBhVUpLZ5ww02uuYj3sGt4cZQrdI/94fyjMoPUxeS16EZcSSj+tzWve7NXwFj/o6rTRlVePY+rGWC+N5X/QdO/JgNFTiJPfozqbATxtkeHvmsLOzF/ZFir9g X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700013)(1800799024)(376014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:02:01.2286 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fdbe7ae1-8d0c-4c0b-2050-08dce3e63eb8 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=[SATLEXMB04.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: PH7PR12MB8014 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 Swap the order of matrix and multiplier as designed in hardware. Signed-off-by: Alex Hung --- .../amd/display/amdgpu_dm/amdgpu_dm_color.c | 22 ++++++------- .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 32 +++++++++---------- 2 files changed, 27 insertions(+), 27 deletions(-) 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 cd545adbb13a..e41329cffd9e 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 @@ -1479,17 +1479,6 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state, if (ret) return ret; - /* 3x4 matrix */ - colorop = colorop->next; - if (!colorop) { - drm_dbg(dev, "no 3x4 matrix colorop found\n"); - return -EINVAL; - } - - ret = __set_dm_plane_colorop_3x4_matrix(plane_state, dc_plane_state, colorop); - if (ret) - return ret; - /* Multiplier */ colorop = colorop->next; if (!colorop) { @@ -1501,6 +1490,17 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state, if (ret) return ret; + /* 3x4 matrix */ + colorop = colorop->next; + if (!colorop) { + drm_dbg(dev, "no 3x4 matrix colorop found\n"); + return -EINVAL; + } + + ret = __set_dm_plane_colorop_3x4_matrix(plane_state, dc_plane_state, colorop); + if (ret) + return ret; + /* 1D Curve & LUT - SHAPER TF & LUT */ colorop = colorop->next; if (!colorop) { 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 a431de9d2b8f..df82fb14f8ca 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 @@ -75,22 +75,6 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr i++; - /* 3x4 matrix */ - ops[i] = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL); - if (!ops[i]) { - DRM_ERROR("KMS: Failed to allocate colorop\n"); - ret = -ENOMEM; - goto cleanup; - } - - ret = drm_colorop_ctm_3x4_init(dev, ops[i], plane); - if (ret) - goto cleanup; - - drm_colorop_set_next_property(ops[i-1], ops[i]); - - i++; - /* Multiplier */ ops[i] = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL); if (!ops[i]) { @@ -107,6 +91,22 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr i++; + /* 3x4 matrix */ + ops[i] = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL); + if (!ops[i]) { + DRM_ERROR("KMS: Failed to allocate colorop\n"); + ret = -ENOMEM; + goto cleanup; + } + + ret = drm_colorop_ctm_3x4_init(dev, ops[i], plane); + if (ret) + goto cleanup; + + drm_colorop_set_next_property(ops[i-1], ops[i]); + + i++; + /* 1D curve - SHAPER TF */ ops[i] = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL); if (!ops[i]) { From patchwork Thu Oct 3 20:01:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821531 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 8B3DECF34C3 for ; Thu, 3 Oct 2024 20:03:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 146F610E983; Thu, 3 Oct 2024 20:02:06 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="WtlAvcN4"; dkim-atps=neutral Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2078.outbound.protection.outlook.com [40.107.223.78]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5B02310E981; Thu, 3 Oct 2024 20:02:04 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Oe+l9dXcSVYEHrZvNXSIG+tvgrRbu3rZcEC//8aW44AK+++LwL+Wqp5V3pTkcaUYOtqVoNSGRTGoqIy9LMnM0utWj8eXGuUr0q5oyfJHA4ChsgHEdhEdNejKPe9j9zp21vx6ardtf9gpxO/D9ckw871APpNCAbnNrvqwwFnpnWu+DDuHA/WjsvjJ6ZkJ+Bq923vS1h+vWeTqagg4WZqv2yWQAVPJy5hVN3rDjrJHCo9KGMACa923pZ+yzryMxJIbKq/Khf+4u5561q4Xp7/XJIh6B4y2c4tMNQOmZrrOGejDuk3wbRoW52HvWyhcssfdWCrfMkWd/3594bm7xG/BGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=wW+eYB/q20ibVF7FuqCMOpFx+H8xWnOLKbtz4TnIkeg=; b=sYYlUBR5dfMn7R+cQFISqMSJjmbYGsJQ2vSN4rprcflLJR0oDHRERfa/rOvTDpsjpEi3HfvwGr7wQPEP/E2FSAxM+Vbjo+JLkwY+Q/RsOQLbjPx+1GmFI+puGppCctyZBejuPdEwsvf11PmKAkzrLwrAcwBAVMCe3ZZvtaYnTJIyRNU7FompCiwpcYVdknlZtsg02FeOOeQD4k6qR+R7mmcXXhpgfaa/kv8nRRFn8IKsTbJhBR7I/FfeBWJhMVIr+BPJEWM3sCYt3aEDpgxzgRYHeZcDse7OnZ3XOt4fqbOm0exkxg9OeaGjYT07Sm+zkK2qVM81/uBD+qRiBYv1Qw== 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=wW+eYB/q20ibVF7FuqCMOpFx+H8xWnOLKbtz4TnIkeg=; b=WtlAvcN4/GmxdxSn2y4rNPM6p9Ujs9kJGV950SW4AcyB2i1IBz0jllZkVmDeEo9BgvEoRF8682q9c8UOySbh6DvntH8GJtp3nU8SMWfGHbAQpbmTUHKxDc4fmffJrctmHMn4nkYwl+bxZ2Fsb9Xq0g5w2iz9HUiU1K7LhZuAiCs= Received: from CH2PR14CA0049.namprd14.prod.outlook.com (2603:10b6:610:56::29) by IA0PR12MB8374.namprd12.prod.outlook.com (2603:10b6:208:40e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Thu, 3 Oct 2024 20:01:59 +0000 Received: from CH2PEPF0000013E.namprd02.prod.outlook.com (2603:10b6:610:56:cafe::27) by CH2PR14CA0049.outlook.office365.com (2603:10b6:610:56::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:01:59 +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 CH2PEPF0000013E.mail.protection.outlook.com (10.167.244.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:58 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) 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.39; Thu, 3 Oct 2024 15:01:57 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:57 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:56 -0500 From: Harry Wentland To: , CC: , Harry Wentland Subject: [PATCH v6 40/44] drm/colorop: Define LUT_1D interpolation Date: Thu, 3 Oct 2024 16:01:22 -0400 Message-ID: <20241003200129.1732122-41-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF0000013E:EE_|IA0PR12MB8374:EE_ X-MS-Office365-Filtering-Correlation-Id: 742db6bb-3376-4d33-f390-08dce3e63d60 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|82310400026|1800799024|376014; X-Microsoft-Antispam-Message-Info: 3TXVcQiq10jaxr1XU77aLPLno5XjBmrTMFZGDlya7whfH/MPpF60cnwRFkV8ECbt93yEC1PvnLEsWHJ4sPqGeas1l8JPSI8tZy0kQmLYBOZ+TJWrR/LkoCvQsI5L+AIPLIw6La9YiQyvvZ3dRzDsfQPvdAiVLOLSX9VwAD4OyjbXgqkK3krKviWbhDEF+NR1xZYtROWJZnTtpAKExxsTzP4Cg+bzPdE3yxKs7rIKy978FLoTfcaTx0UGAfbt1slWHtJSNt697FPS38YRliC+qnAceEQxfE4o2r1iuXB3YpLeqJMwTGAXGdh9OkplRlPjmXOVMrhlIZwoTrXGqn7J1EqHgAhXHm9aabrDFgNxe0HX1QjMwIhVN/nVi0FBKvGfXF7mKR13LShT6D3F384foqqPiUZnLqZI5KgF5o+jBICFdO8mIaGfqsmbvlfd8krHmkJs7P/FdsjTJzwx5NGPtKwkiIT9T1sy2cPCqw21zjPERCMDYZ4w64Wzo8HdAgHOdMx/5IS5yd9f2SSg14fGWBim8PELFsmXGUntj5j3KRZnFsKDdyBBKtECDCjLEYhUqCMvuKHlSr31/q7FEIWxFuwd3DvxR+1VThKzcDWtm4iY9WNWhvFMTuL6iZRO+JxY4MLkIs78mMgGokDeNj3bTCqPqa5LJ8hMc6G2ub4wGNA0vA690yodPTS8BLfBJK0mG8obsxDEdgb7GszwiE3CyLsFFet+H0Jm2UylgVh6ejkVbli4EX6tg3FlBlz0yvvjBfYDR0qLFHQjaNPwTWb/voPompUuWJjweYHkCuN2FvnZ8AzMUyCI/g9VtWLIjtVXCHkXoo7w8R5Uk++Wpq0Kw2T1odCPGu9DEpF9ORsJ7yM26oGDWmU9UI3msw721JbIGas/V5kzi6FM//ny0auT5Lvsyvn0heMRAoNoahTX1NrK1/Nr0Q3YFNwF8lIbCKm4LVOyQ/gAlu0JfGAF4Mlw49nBLnN+JEDFQwo3T4qLT2ZFaeRt8gl9hfTEwozy2yMsqt31btqN048z0msB2vn8FAW7Y0IQLOhjEdHYbFb8bok8M2UntSIE6enc1kg2UsmaLgr7IAvG+a89e5r1Q6Sg/7GE6gJYB467mAZf7mMo7P99TXXk0GCQiCo6Qwjw2WtJDpfVPVD4JN9vqrcW746b+7lX7mNzo4eRS1W9Umpkvy665KkDppTBIajdv2K5rkvLRRyIM17u7Z2V3y7TTbekKv4m6tzPSSmmZCOmZOtiYskKSAlvltcNOF3RFwfmlDWpWGH6Tv3ruGJdyxXxFegpVui3mIUJfxuxPJG8ZwJno6ongV3NBBu+E0S7bUO3A3EkhMGtmvtbO5OSUi3tt/Js2+1gfA78Xw2ckbQ/iZ5qFKvbl2JiplMsc9YoClwK4qFU 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:(13230040)(36860700013)(82310400026)(1800799024)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:58.7764 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 742db6bb-3376-4d33-f390-08dce3e63d60 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: CH2PEPF0000013E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8374 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" We want to make sure userspace is aware of the 1D LUT interpolation. While linear interpolation is common it might not be supported on all HW. Give driver implementers a way to specify their interpolation. Signed-off-by: Harry Wentland --- .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 6 ++-- drivers/gpu/drm/drm_atomic.c | 1 + drivers/gpu/drm/drm_colorop.c | 36 ++++++++++++++++++- include/drm/drm_colorop.h | 19 +++++++++- include/uapi/drm/drm_mode.h | 13 +++++++ 5 files changed, 71 insertions(+), 4 deletions(-) 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 df82fb14f8ca..f0f7ef6b52a9 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 @@ -131,7 +131,8 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr goto cleanup; } - ret = drm_colorop_curve_1d_lut_init(dev, ops[i], plane, MAX_COLOR_LUT_ENTRIES); + ret = drm_colorop_curve_1d_lut_init(dev, ops[i], plane, MAX_COLOR_LUT_ENTRIES, + DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR); if (ret) goto cleanup; @@ -163,7 +164,8 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr goto cleanup; } - ret = drm_colorop_curve_1d_lut_init(dev, ops[i], plane, MAX_COLOR_LUT_ENTRIES); + ret = drm_colorop_curve_1d_lut_init(dev, ops[i], plane, MAX_COLOR_LUT_ENTRIES, + DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR); if (ret) goto cleanup; diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index acd8a2fc0270..e492a06c3a6b 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -795,6 +795,7 @@ static void drm_atomic_colorop_print_state(struct drm_printer *p, break; case DRM_COLOROP_1D_LUT: drm_printf(p, "\tsize=%d\n", state->size); + drm_printf(p, "\tinterpolation=%s\n", drm_get_colorop_lut1d_interpolation_name(colorop->lut1d_interpolation)); drm_printf(p, "\tdata blob id=%d\n", state->data ? state->data->base.id : 0); break; case DRM_COLOROP_CTM_3X4: diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c index 41f0ade76b57..3ad3e22d37c2 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -77,6 +77,9 @@ static const char * const colorop_curve_1d_type_names[] = { [DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF] = "PQ 125 Inverse EOTF", }; +static const struct drm_prop_enum_list drm_colorop_lut1d_interpolation_list[] = { + { DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR, "Linear" }, +}; /* Init Helpers */ @@ -233,10 +236,12 @@ static int drm_colorop_create_data_prop(struct drm_device *dev, struct drm_color * @colorop: The drm_colorop object to initialize * @plane: The associated drm_plane * @lut_size: LUT size supported by driver + * @lut1d_interpolation: 1D LUT interpolation type * @return zero on success, -E value on failure */ int drm_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *colorop, - struct drm_plane *plane, uint32_t lut_size) + struct drm_plane *plane, uint32_t lut_size, + enum drm_colorop_lut1d_interpolation_type lut1d_interpolation) { struct drm_property *prop; int ret; @@ -255,6 +260,17 @@ int drm_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *co colorop->size_property = prop; drm_object_attach_property(&colorop->base, colorop->size_property, lut_size); + /* Interpolation */ + prop = drm_property_create_enum(dev, DRM_MODE_PROP_IMMUTABLE, "LUT1D_INTERPOLATION", + drm_colorop_lut1d_interpolation_list, + ARRAY_SIZE(drm_colorop_lut1d_interpolation_list)); + if (!prop) + return -ENOMEM; + + colorop->lut1d_interpolation_property = prop; + drm_object_attach_property(&colorop->base, prop, lut1d_interpolation); + colorop->lut1d_interpolation = lut1d_interpolation; + /* data */ ret = drm_colorop_create_data_prop(dev, colorop); if (ret) @@ -410,6 +426,9 @@ static const char * const colorop_type_name[] = { [DRM_COLOROP_CTM_3X4] = "3x4 Matrix", [DRM_COLOROP_MULTIPLIER] = "Multiplier", }; +static const char * const colorop_lut1d_interpolation_name[] = { + [DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR] = "Linear", +}; const char *drm_get_colorop_type_name(enum drm_colorop_type type) { @@ -427,6 +446,21 @@ const char *drm_get_colorop_curve_1d_type_name(enum drm_colorop_curve_1d_type ty return colorop_curve_1d_type_names[type]; } +/** + * drm_get_colorop_lut1d_interpolation_name: return a string for interpolation type + * @type: interpolation type to compute name of + * + * In contrast to the other drm_get_*_name functions this one here returns a + * const pointer and hence is threadsafe. + */ +const char *drm_get_colorop_lut1d_interpolation_name(enum drm_colorop_lut1d_interpolation_type type) +{ + if (WARN_ON(type >= ARRAY_SIZE(colorop_lut1d_interpolation_name))) + return "unknown"; + + return colorop_lut1d_interpolation_name[type]; +} + /** * drm_colorop_set_next_property - sets the next pointer * @colorop: drm colorop diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h index f78ef745887c..d3a00296973d 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -252,6 +252,21 @@ struct drm_colorop { */ struct drm_property *bypass_property; + /** + * @lut1d_interpolation: + * + * Read-only + * Interpolation for DRM_COLOROP_1D_LUT + */ + enum drm_colorop_lut1d_interpolation_type lut1d_interpolation; + + /** + * @lut1d_interpolation_property: + * + * Read-only property for DRM_COLOROP_1D_LUT interpolation + */ + struct drm_property *lut1d_interpolation_property; + /** * @curve_1d_type_property: * @@ -320,7 +335,8 @@ static inline struct drm_colorop *drm_colorop_find(struct drm_device *dev, int drm_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop, struct drm_plane *plane, u64 supported_tfs); int drm_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *colorop, - struct drm_plane *plane, uint32_t lut_size); + struct drm_plane *plane, uint32_t lut_size, + enum drm_colorop_lut1d_interpolation_type lut1d_interpolation); int drm_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop, struct drm_plane *plane); int drm_colorop_mult_init(struct drm_device *dev, struct drm_colorop *colorop, @@ -374,6 +390,7 @@ const char *drm_get_colorop_type_name(enum drm_colorop_type type); * const pointer and hence is threadsafe. */ const char *drm_get_colorop_curve_1d_type_name(enum drm_colorop_curve_1d_type type); +const char *drm_get_colorop_lut1d_interpolation_name(enum drm_colorop_lut1d_interpolation_type type); void drm_colorop_set_next_property(struct drm_colorop *colorop, struct drm_colorop *next); diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index 96cb32e6980c..5ef87cb5b242 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -915,6 +915,19 @@ enum drm_colorop_type { DRM_COLOROP_MULTIPLIER, }; +/** + * enum drm_colorop_lut1d_interpolation_type - type of interpolation for 1D LUTs + */ +enum drm_colorop_lut1d_interpolation_type { + /** + * @DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR: + * + * Linear interpolation. Values between points of the LUT will be + * linearly interpolated. + */ + DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR, +}; + /** * struct drm_plane_size_hint - Plane size hints * @width: The width of the plane in pixel From patchwork Thu Oct 3 20:01:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821533 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 59534CF34C1 for ; Thu, 3 Oct 2024 20:03:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4910210E9A0; Thu, 3 Oct 2024 20:02:07 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="r+MDMY67"; dkim-atps=neutral Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2043.outbound.protection.outlook.com [40.107.101.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1524210E982; Thu, 3 Oct 2024 20:02:05 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rN3icA5FRPPE79Mg8e1pB8GuLua7qL0ek52ZN+ef6z1pR4qdcS4R5Ui9CeDmLivFN5OckjVYCnOKBGx3TX82DZi4e5SVMDVjMJN0WmyCKKrL2o1lDPRUi4jDF6mCUI3aJ3zB7cQD7NnHLrECZIzGShhXmxczHl27UlUmkHit7yxa1x9E9upsx/Weqmi7QgaTwK49fb4wHl4oVs4C0e7u1WVEGosjuPqlOL0Xs/SXzNpa4THaKHtG6nG2lwQV9kUXhS08TpAj6jsbMdpHKWYofMhLpGc/6dko/4jnLQTpHktRINOCT1jHigRw1HSWE0abfyLIJZco9F15QwIIUaOu0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=A9/gk6HAQZ7Rx2nc9k5SR99QPgZmkJP6xl+BAa8NV9g=; b=kBagvYiMGVAsJtCfnQQ4QIgOelhHlcEFdjRb9uxc48UV99Ym5khmVep/2Za6t08Jpg/IM6E0IMqt0dWDVO4QlV8r4tAe+2hkADSmXk5BWN/OCBltfzhPCIoQkwHnJpgtDeFJQacaObTl0/mOml7meRvO8Kif61mvP2Yxm4e9AXVZ+8wXB8Z+aNadt5jsm75nYl7X2V2Zr3Oo+xaobLnM5ljhqL4YkCZO5Sofhgm3tT8FtGXetgCqOnc+moV87eQnwM4AiYz153RInW6qs3UnR3jWKZPVDZlZRqnSDqrSxFcqPBXSwnSYVgXgqIgzS1HQfPo0HwFqkr85et05WfSi3A== 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=A9/gk6HAQZ7Rx2nc9k5SR99QPgZmkJP6xl+BAa8NV9g=; b=r+MDMY67poozlFBRgwGdrtV2vZPPoqSXcsLQ5M13FQXQbxuL9J8kZARt62/zN7XZejSUg3HAUOOOH/QM+6aYuZefMaaW/e26JoBIkB03UG5w58CHTiO137wrD4419u6WR77vkVe4OApI1j+C7fJM7pGoZ9ZTZM94Xo+j4CTfmfg= Received: from CH2PR14CA0055.namprd14.prod.outlook.com (2603:10b6:610:56::35) by MW6PR12MB8958.namprd12.prod.outlook.com (2603:10b6:303:240::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Thu, 3 Oct 2024 20:02:00 +0000 Received: from CH2PEPF0000013E.namprd02.prod.outlook.com (2603:10b6:610:56:cafe::9a) by CH2PR14CA0055.outlook.office365.com (2603:10b6:610:56::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:02:00 +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 CH2PEPF0000013E.mail.protection.outlook.com (10.167.244.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:01:59 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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.39; Thu, 3 Oct 2024 15:01:57 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:57 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:57 -0500 From: Harry Wentland To: , CC: , Harry Wentland Subject: [PATCH v6 41/44] drm/colorop: allow non-bypass colorops Date: Thu, 3 Oct 2024 16:01:23 -0400 Message-ID: <20241003200129.1732122-42-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB05.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF0000013E:EE_|MW6PR12MB8958:EE_ X-MS-Office365-Filtering-Correlation-Id: a2281f24-c5b7-4891-015b-08dce3e63df0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: euOm/ts9XjEHMyXeWYoQskuIIUWn+c6WVCl2paNGXSKag0T0LpffrtmY3RaZyPKptuioogCDE+ziIukS92mnZzfjn2OBeUVcUgj6C1YwcsmC8KH6ls1uvI2q7hsvHUqwZvWbUqUIu5eg6OApQ4aTJqoQ5N6F4hAWHAj9pWwhOMbykS4LXF8t9jdewRthgboAd9PLd/qXHlUh19HwrLDfry4bhky9GlcO9n4N8MKcB3DcTIG9tovrSxKYhKML3LJiO5PzoZmNujAabf85XIW6AcPhhGOjJ3zzHJ0a3jLBMsDXeqY1x1YNJ64NHaPcxtmGQ6vO+S3CKv4zhhdPCkYDgN9usgqf6uanUbznBgAEQKvYPJIu5XCPLU2WLLre2EIRThcwqDPdWURcOX7n2DYZA6lXQCyV5JLgab3MQ4XmaH55EzXIbGDEJ/SeWI+ffHIjO0HrZd1omzibP3jAdQ2tbMZSqvHIaAVt8WjdVxuY4HAtnsYwiGPqPxUCb4+vg6BH+cCzOK4KaELdF4QANZu+9yOb5wUoNDW2BhHZiOXu9+bcsni/3lSQH3g3M5b/aDWnRP/FaBNMGAalhqwff/Xszwg5axTolvkyw1Vs3/0MgQIeC7gZPuXz15jMm6929ZHeq+YjhZ7snfKS0h60v0LooRsqsbvRHVXiOT18/jqDPs4qP9DXF8schGvXuak7m7eR4LzHYxsgCpWK1F8l9kxTFpRrmHqrBT5jLgW2XYf46sWENEf777jusT2eNAayiBtVzvvfllizNISoYZlOjFgcWlu+Gyqi6kj1JXFUnNpezmfAJYeWIu/72dk2M+eI/kqUN+bsNvM9BBUGLK7SasbmHnrk0jZS9FBXGb3XKwOk09CoxJTvbqvGYTRpbLlwbk7aDinY9jzRV437VeBeqLeQmr9LSrTOsUmK0qWQfihRyo9EdUEtjwmeeTJkBsuIuTlw+9wN5KDFz5qm3CHKJLK6TnBuod2Jt6RbJhsCZnQMHtUk5bGiJjRkHI+Fyf15svz4pAzBcH3ybFn0ZyUK6WhQJzRexpI1onqfeWctoP7w8SwUpx6w/sjHu4E9ZaHLQdE91BARLyDKyQtBe01/+wRuBVkLFNAMkuo3mzHNfxsEOAqRFb1CAnuD+bTQ9zvU4huN4KzqIU3KnIT2X46iKV6mdwg0Jr60WMGh97/RDg03Ej3nDYfIripsS64qPQz0Marf+z2Fm0n2Af8JPixabfWnGS1JuO3GyfVfPOQ5AjqAyDpPOX3fI5XQpDLtbHtotiB2F6FH3ibRp3IKkwLQLEO3HhCSt6gQd5Q/O+8CFBTuBhSuLhFx6upx7mbC97fyqbG9cT+yNb4JCKE0H2wO6jC0IJKJY9L5CDqooc6hdDNXaUC0RwL2p3+kxyW7ICq+QWML 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:(13230040)(376014)(82310400026)(36860700013)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:01:59.9952 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a2281f24-c5b7-4891-015b-08dce3e63df0 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: CH2PEPF0000013E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB8958 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" Not all HW will be able to do bypass on all color operations. Introduce an 'allow_bypass' boolean for all colorop init functions and only create the BYPASS property when it's true. Signed-off-by: Harry Wentland --- .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 22 +++++--- drivers/gpu/drm/drm_atomic.c | 3 +- drivers/gpu/drm/drm_colorop.c | 51 ++++++++++++------- drivers/gpu/drm/vkms/vkms_colorop.c | 8 +-- include/drm/drm_colorop.h | 10 ++-- 5 files changed, 60 insertions(+), 34 deletions(-) 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 f0f7ef6b52a9..22bddb45043a 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 @@ -66,7 +66,9 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr goto cleanup; } - ret = drm_colorop_curve_1d_init(dev, ops[i], plane, amdgpu_dm_supported_degam_tfs); + ret = drm_colorop_curve_1d_init(dev, ops[i], plane, + amdgpu_dm_supported_degam_tfs, + true); if (ret) goto cleanup; @@ -83,7 +85,7 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr goto cleanup; } - ret = drm_colorop_mult_init(dev, ops[i], plane); + ret = drm_colorop_mult_init(dev, ops[i], plane, true); if (ret) goto cleanup; @@ -99,7 +101,7 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr goto cleanup; } - ret = drm_colorop_ctm_3x4_init(dev, ops[i], plane); + ret = drm_colorop_ctm_3x4_init(dev, ops[i], plane, true); if (ret) goto cleanup; @@ -115,7 +117,9 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr goto cleanup; } - ret = drm_colorop_curve_1d_init(dev, ops[i], plane, amdgpu_dm_supported_shaper_tfs); + ret = drm_colorop_curve_1d_init(dev, ops[i], plane, + amdgpu_dm_supported_shaper_tfs, + true); if (ret) goto cleanup; @@ -132,7 +136,8 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr } ret = drm_colorop_curve_1d_lut_init(dev, ops[i], plane, MAX_COLOR_LUT_ENTRIES, - DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR); + DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR, + true); if (ret) goto cleanup; @@ -148,7 +153,9 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr goto cleanup; } - ret = drm_colorop_curve_1d_init(dev, ops[i], plane, amdgpu_dm_supported_blnd_tfs); + ret = drm_colorop_curve_1d_init(dev, ops[i], plane, + amdgpu_dm_supported_blnd_tfs, + true); if (ret) goto cleanup; @@ -165,7 +172,8 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr } ret = drm_colorop_curve_1d_lut_init(dev, ops[i], plane, MAX_COLOR_LUT_ENTRIES, - DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR); + DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR, + true); if (ret) goto cleanup; diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index e492a06c3a6b..29f8a8f402f2 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -786,7 +786,8 @@ static void drm_atomic_colorop_print_state(struct drm_printer *p, drm_printf(p, "colorop[%u]:\n", colorop->base.id); drm_printf(p, "\ttype=%s\n", drm_get_colorop_type_name(colorop->type)); - drm_printf(p, "\tbypass=%u\n", state->bypass); + if (colorop->bypass_property) + drm_printf(p, "\tbypass=%u\n", state->bypass); switch (colorop->type) { case DRM_COLOROP_1D_CURVE: diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c index 3ad3e22d37c2..df0266734639 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -84,7 +84,8 @@ static const struct drm_prop_enum_list drm_colorop_lut1d_interpolation_list[] = /* Init Helpers */ static int drm_colorop_init(struct drm_device *dev, struct drm_colorop *colorop, - struct drm_plane *plane, enum drm_colorop_type type) + struct drm_plane *plane, enum drm_colorop_type type, + bool allow_bypass) { struct drm_mode_config *config = &dev->mode_config; struct drm_property *prop; @@ -120,16 +121,18 @@ static int drm_colorop_init(struct drm_device *dev, struct drm_colorop *colorop, colorop->type_property, colorop->type); - /* bypass */ - prop = drm_property_create_bool(dev, DRM_MODE_PROP_ATOMIC, - "BYPASS"); - if (!prop) - return -ENOMEM; + if (allow_bypass) { + /* bypass */ + prop = drm_property_create_bool(dev, DRM_MODE_PROP_ATOMIC, + "BYPASS"); + if (!prop) + return -ENOMEM; - colorop->bypass_property = prop; - drm_object_attach_property(&colorop->base, - colorop->bypass_property, - 1); + colorop->bypass_property = prop; + drm_object_attach_property(&colorop->base, + colorop->bypass_property, + 1); + } /* next */ prop = drm_property_create_object(dev, DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_ATOMIC, @@ -153,10 +156,13 @@ static int drm_colorop_init(struct drm_device *dev, struct drm_colorop *colorop, * @supported_tfs: A bitfield of supported drm_colorop_curve_1d_init enum values, * created using BIT(curve_type) and combined with the OR '|' * operator. + * @allow_bypass: true if BYPASS property should be created, false if bypass of + * this colorop is not possible * @return zero on success, -E value on failure */ int drm_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop, - struct drm_plane *plane, u64 supported_tfs) + struct drm_plane *plane, u64 supported_tfs, + bool allow_bypass) { struct drm_prop_enum_list enum_list[DRM_COLOROP_1D_CURVE_COUNT]; int i, len; @@ -177,7 +183,8 @@ int drm_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *coloro return -EINVAL; } - ret = drm_colorop_init(dev, colorop, plane, DRM_COLOROP_1D_CURVE); + ret = drm_colorop_init(dev, colorop, plane, DRM_COLOROP_1D_CURVE, + allow_bypass); if (ret) return ret; @@ -237,16 +244,20 @@ static int drm_colorop_create_data_prop(struct drm_device *dev, struct drm_color * @plane: The associated drm_plane * @lut_size: LUT size supported by driver * @lut1d_interpolation: 1D LUT interpolation type + * @allow_bypass: true if BYPASS property should be created, false if bypass of + * this colorop is not possible * @return zero on success, -E value on failure */ int drm_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *colorop, struct drm_plane *plane, uint32_t lut_size, - enum drm_colorop_lut1d_interpolation_type lut1d_interpolation) + enum drm_colorop_lut1d_interpolation_type lut1d_interpolation, + bool allow_bypass) { struct drm_property *prop; int ret; - ret = drm_colorop_init(dev, colorop, plane, DRM_COLOROP_1D_LUT); + ret = drm_colorop_init(dev, colorop, plane, DRM_COLOROP_1D_LUT, + allow_bypass); if (ret) return ret; @@ -284,11 +295,12 @@ int drm_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *co EXPORT_SYMBOL(drm_colorop_curve_1d_lut_init); int drm_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop, - struct drm_plane *plane) + struct drm_plane *plane, bool allow_bypass) { int ret; - ret = drm_colorop_init(dev, colorop, plane, DRM_COLOROP_CTM_3X4); + ret = drm_colorop_init(dev, colorop, plane, DRM_COLOROP_CTM_3X4, + allow_bypass); if (ret) return ret; @@ -308,15 +320,18 @@ EXPORT_SYMBOL(drm_colorop_ctm_3x4_init); * @dev: DRM device * @colorop: The drm_colorop object to initialize * @plane: The associated drm_plane + * @allow_bypass: true if BYPASS property should be created, false if bypass of + * this colorop is not possible * @return zero on success, -E value on failure */ int drm_colorop_mult_init(struct drm_device *dev, struct drm_colorop *colorop, - struct drm_plane *plane) + struct drm_plane *plane, bool allow_bypass) { struct drm_property *prop; int ret; - ret = drm_colorop_init(dev, colorop, plane, DRM_COLOROP_MULTIPLIER); + ret = drm_colorop_init(dev, colorop, plane, DRM_COLOROP_MULTIPLIER, + allow_bypass); if (ret) return ret; diff --git a/drivers/gpu/drm/vkms/vkms_colorop.c b/drivers/gpu/drm/vkms/vkms_colorop.c index f0c264820a81..519521e9b908 100644 --- a/drivers/gpu/drm/vkms/vkms_colorop.c +++ b/drivers/gpu/drm/vkms/vkms_colorop.c @@ -31,7 +31,7 @@ static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_pr goto cleanup; } - ret = drm_colorop_curve_1d_init(dev, ops[i], plane, supported_tfs); + ret = drm_colorop_curve_1d_init(dev, ops[i], plane, supported_tfs, true); if (ret) goto cleanup; @@ -48,7 +48,7 @@ static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_pr goto cleanup; } - ret = drm_colorop_ctm_3x4_init(dev, ops[i], plane); + ret = drm_colorop_ctm_3x4_init(dev, ops[i], plane, true); if (ret) goto cleanup; @@ -64,7 +64,7 @@ static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_pr goto cleanup; } - ret = drm_colorop_ctm_3x4_init(dev, ops[i], plane); + ret = drm_colorop_ctm_3x4_init(dev, ops[i], plane, true); if (ret) goto cleanup; @@ -80,7 +80,7 @@ static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_pr goto cleanup; } - ret = drm_colorop_curve_1d_init(dev, ops[i], plane, supported_tfs); + ret = drm_colorop_curve_1d_init(dev, ops[i], plane, supported_tfs, true); if (ret) goto cleanup; diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h index d3a00296973d..b8c1c4da3444 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -333,14 +333,16 @@ static inline struct drm_colorop *drm_colorop_find(struct drm_device *dev, } int drm_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop, - struct drm_plane *plane, u64 supported_tfs); + struct drm_plane *plane, u64 supported_tfs, + bool allow_bypass); int drm_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *colorop, struct drm_plane *plane, uint32_t lut_size, - enum drm_colorop_lut1d_interpolation_type lut1d_interpolation); + enum drm_colorop_lut1d_interpolation_type lut1d_interpolation, + bool allow_bypass); int drm_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop, - struct drm_plane *plane); + struct drm_plane *plane, bool allow_bypass); int drm_colorop_mult_init(struct drm_device *dev, struct drm_colorop *colorop, - struct drm_plane *plane); + struct drm_plane *plane, bool allow_bypass); struct drm_colorop_state * drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop); From patchwork Thu Oct 3 20:01:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821534 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 A5CDACF34C3 for ; Thu, 3 Oct 2024 20:03:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 532E410E9A1; Thu, 3 Oct 2024 20:02:07 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="IyK7HqPu"; dkim-atps=neutral Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2061.outbound.protection.outlook.com [40.107.102.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8D48210E98B; Thu, 3 Oct 2024 20:02:05 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=c1qTiP+K9JMtuNatMGIXJAWSzS1zzUaKIwrQgdtWorXsPUPATsm9+Cy76RFd3qP2KExVBbm16ZAE24HrE2JeeysNksjAnW9aDvVnAv5zvzrrFvIudiF+mUd7+ASLVQvCYusKRqermjxiXJlflOetqL9ktceh3U5ATQz48t4OaWG0FVg5rDollyQgOg/wCgoiIaLzPWJcugRGhDfyMEunIHgg0lLv3quK8dk5yCzU7i3gSWiYpehY1Xe7BaZo1s99dQ5UKN8Xn7nFytdMjlh7JXf+pycXn14NhTtfRJic5sY1Kas+Gv8BojMGuv8oCFavKZ4Ad/U2idA7UiW8YHJ1vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=2YVpLzV285OdzrBrIoBMV1vm3xWISGuqxCGhWB8avZI=; b=s3SEer+Q0YTvlompM4/ONyNvx35Mz7PWLE4aDYzAfe8oyS3TUgBXmwEG5eoSK43XBQDtBDA48J5INmu2quNzqTDOz1AzVjVv8K1SLnJbs5kGF6DaGQjtMEN/0oXYQDF4CzSfCsAH0GPsoeHYSZcbF/T2cg2NFa8gIuOaHNvxcGuwIG3N3xAC2Vtj9GTtAiY5RidVdeypJkOeY1azaIg21UBNAZ63vrjjpIiY7YbdQVbmaNnt8XVctC5bA3/H9PxjHct01lXxIzbzWNT8dtMsTUqu4VT4ea5iUMe78U0Op+M8UW/jDGlf++fr6irka9UYiG7shcbt4w148JTGquEORw== 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=2YVpLzV285OdzrBrIoBMV1vm3xWISGuqxCGhWB8avZI=; b=IyK7HqPutshP6xFcAgEh7Y5vRRvPWAxjnlznhqyQ/e/1OA3/tpWXd4uSRNpeypYcN9Z08W4Xj6M1O9RCcmM87NCMmBm5P7/May24uLnrOHugbwwvw3WT4VOrHEVXlVbiemMvR1GNjzwnmVSWOc9W8UC4YGdXs9tr4yomZUG24Wo= Received: from DM6PR04CA0003.namprd04.prod.outlook.com (2603:10b6:5:334::8) by PH7PR12MB5617.namprd12.prod.outlook.com (2603:10b6:510:133::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Thu, 3 Oct 2024 20:02:02 +0000 Received: from DS2PEPF0000343D.namprd02.prod.outlook.com (2603:10b6:5:334:cafe::26) by DM6PR04CA0003.outlook.office365.com (2603:10b6:5:334::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:02:02 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.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.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:02:01 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:57 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:57 -0500 From: Harry Wentland To: , CC: , Alex Hung Subject: [PATCH v6 42/44] drm/colorop: Add 3D LUT supports to color pipeline Date: Thu, 3 Oct 2024 16:01:24 -0400 Message-ID: <20241003200129.1732122-43-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343D:EE_|PH7PR12MB5617:EE_ X-MS-Office365-Filtering-Correlation-Id: cb83c87f-c86f-4337-42f9-08dce3e63f1c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: GVRrtd6W3DbmRY7gTwwBkppgOO+xZbp+3fMtRqRaln8Dq/DGd2V4uQUQQGHYklJHN7qhyWc7oTz3dmIYaEY4CCB3FyW76EQF4Qy6zKjAzQUfBz9GS1/NUUrgq87oRSi5HYDm6twwTTE3K1PPEGyMOSTg1c5UXVJqnjBexZMkXHMinlfty0sW6WCGU6Lb+HumfBiRsScCx3IrCKeFQ/uTr2tdj7eWIJD8zcEQJLHinf/acf6yUaB5NhuTXxQvcSup4nVtgUiJhRVlGNQrNwFjcl+Bx3rQNblt/KHF89enoMM/3kzwH37sRQYC/DwVH7ipPlSMHkR7ij2LO/6BgY8jruEfECd9wrpiv25keMS0H194s2cHJ/26/ujLLtFearnk6zdM6PPO2Hq0xNr3ADaJjF8S6/cQt1yejZfrauStsTHfSYp/m2p+mnq1qXz4ngpa4uoVA4UxoZsPhK/lS28ZPl7J8vzY0f5E0Mv1i/IcTg/fseGzI2/lfr/rBCU0WprFKMK8eNgdj6SgcvAcAo6W76Bmf2xUqtsR+eRU8UJ9kb9/Ij/2BKm8mcuCb8YlkVPOKrLrVyjAItcx92Qo7MqWe3qdal1ZAG8zKLSAeW2vPXOylFgr4TVkVPElFPBNfor4EMgTexVEaIA8D0xyCjSJ+r2k23whwtko9qnvpJlf8QZHW1y1NqUZ87Zw8p1vA54OO2/RFphcQUSdmEyb+u/i1+J/F2tG0SwLO5hETQNidg8cQxGVNeoS9N1B2Y+bzLZMl7wxxOdMsqYRE8v0LaNTBob/2hYotF4t9R2zURv1xNgVKq5IgooIDPv4+sKc1Xcst4UDEqAHwhq/wi/OdRpVDK5B8AdW2hi3wdVY835o7EYJF2qVOqDr17U/+LVfKDGPtdrR/l0bShJzZT1qS+B6ucbohB9dL0lZqKJNNPg+mgjJuaTPA+pCPysPFwuySxHkqSASoq5SR2+pIXPc2yxvgyHDn870mt0TSrpU/lKm2M/05wkqI/8wdIBUj9HfeID+BVreqGiNq8U7awsWJOWkmuPI611DDTSlgrXsbIKUxoSOHDOmBFboXhiUkIvC4YcpD8f5ZCLyVBIouOFrbS+ky6AQyBdFH0RM60tBkTF/SMJAbucKOOuItW+P7TJo+YY5KqouVQ7EipfWPAaXjiyI2rVQZHO/T8PxYr9ehm1WqU7UU5s54wFfTX02zFMryLAMuLYzgVoT5udmutJ9iDCUGif3ZJ49TxjhBySqpM+DaciLn/VujDGmPdRNf3AZYnCNfQOaLyzuF0DvGKMaDsc0qbK5IYBTGMurhlYn3xsZpwsyPANPRb52ljhav8zyfHA7wXEW6JwwACvUtXUmAUBT3IvK/xWsCsieyIkGe8R4CYMrmI9l3eGR8lwz8iCUv6Mz X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(36860700013)(1800799024)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:02:01.9317 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cb83c87f-c86f-4337-42f9-08dce3e63f1c 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=[SATLEXMB04.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: PH7PR12MB5617 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 It is to be used to enable HDR by allowing userpace to create and pass 3D LUTs to kernel and hardware. 1. new drm_colorop_type: DRM_COLOROP_3D_LUT. 2. 3D LUT modes define hardware capabilities to userspace applications. 3. mode index points to current 3D LUT mode in lut_3d_modes. Signed-off-by: Alex Hung --- drivers/gpu/drm/drm_atomic.c | 21 ++++++++ drivers/gpu/drm/drm_atomic_uapi.c | 17 +++++++ drivers/gpu/drm/drm_colorop.c | 69 +++++++++++++++++++++++++ include/drm/drm_colorop.h | 42 ++++++++++++++++ include/uapi/drm/drm_mode.h | 84 +++++++++++++++++++++++++++++++ 5 files changed, 233 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 29f8a8f402f2..58f0ef8b2d1d 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -783,6 +783,9 @@ static void drm_atomic_colorop_print_state(struct drm_printer *p, const struct drm_colorop_state *state) { struct drm_colorop *colorop = state->colorop; + struct drm_property_blob *modes = state->lut_3d_modes; + struct drm_mode_3dlut_mode *mode_3dlut; + int i; drm_printf(p, "colorop[%u]:\n", colorop->base.id); drm_printf(p, "\ttype=%s\n", drm_get_colorop_type_name(colorop->type)); @@ -805,6 +808,24 @@ static void drm_atomic_colorop_print_state(struct drm_printer *p, case DRM_COLOROP_MULTIPLIER: drm_printf(p, "\tmultiplier=%llu\n", state->multiplier); break; + case DRM_COLOROP_3D_LUT: + mode_3dlut = (struct drm_mode_3dlut_mode *) modes->data; + + drm_printf(p, "\tlut_3d_modes blob id=%d\n", modes ? modes->base.id : 0); + for (i = 0; i < modes->length / sizeof(struct drm_mode_3dlut_mode); i++) { + drm_printf(p, "\t lut_size=%d\n", mode_3dlut[i].lut_size); + drm_printf(p, "\t lut_strides=%d %d %d\n", mode_3dlut[i].lut_stride[0], + mode_3dlut[i].lut_stride[1], + mode_3dlut[i].lut_stride[2]); + drm_printf(p, "\t interpolation=%s\n", + drm_get_colorop_lut3d_interpolation_name(mode_3dlut[i].interpolation)); + drm_printf(p, "\t color_depth=%d\n", mode_3dlut[i].color_depth); + drm_printf(p, "\t color_format=%X\n", mode_3dlut[i].color_format); + drm_printf(p, "\t traversal_order=%X\n", mode_3dlut[i].traversal_order); + } + drm_printf(p, "\tlut_3d_mode_index=%d\n", state->lut_3d_mode_index); + drm_printf(p, "\tdata blob id=%d\n", state->data ? state->data->base.id : 0); + break; default: break; } diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index 57029e5938f6..e978b1bf021f 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -695,9 +695,11 @@ static int drm_atomic_color_set_data_property(struct drm_colorop *colorop, struct drm_colorop_state *state, struct drm_property *property, uint64_t val) { + struct drm_mode_3dlut_mode *modes; ssize_t elem_size = -1; ssize_t size = -1; bool replaced = false; + uint32_t index; switch (colorop->type) { case DRM_COLOROP_1D_LUT: @@ -706,6 +708,15 @@ static int drm_atomic_color_set_data_property(struct drm_colorop *colorop, case DRM_COLOROP_CTM_3X4: size = sizeof(struct drm_color_ctm_3x4); break; + case DRM_COLOROP_3D_LUT: + index = state->lut_3d_mode_index; + if (index >= (state->lut_3d_modes->length / sizeof(struct drm_mode_3dlut_mode))) + return -EINVAL; + + modes = (struct drm_mode_3dlut_mode *) state->lut_3d_modes->data; + size = modes[index].lut_stride[0] * modes[index].lut_stride[1] * modes[index].lut_stride[2] * + sizeof(struct drm_color_lut); + break; default: /* should never get here */ return -EINVAL; @@ -729,6 +740,8 @@ static int drm_atomic_colorop_set_property(struct drm_colorop *colorop, state->curve_1d_type = val; } else if (property == colorop->multiplier_property) { state->multiplier = val; + } else if (property == colorop->lut_3d_mode_index_property) { + state->lut_3d_mode_index = val; } else if (property == colorop->data_property) { return drm_atomic_color_set_data_property(colorop, state, property, val); @@ -756,6 +769,10 @@ drm_atomic_colorop_get_property(struct drm_colorop *colorop, *val = state->curve_1d_type; } else if (property == colorop->multiplier_property) { *val = state->multiplier; + } else if (property == colorop->lut_3d_modes_property) { + *val = (state->lut_3d_modes) ? state->lut_3d_modes->base.id : 0; + } else if (property == colorop->lut_3d_mode_index_property) { + *val = state->lut_3d_mode_index; } else if (property == colorop->size_property) { *val = state->size; } else if (property == colorop->data_property) { diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c index df0266734639..fd1cd934df48 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -66,6 +66,7 @@ static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { { DRM_COLOROP_1D_LUT, "1D Curve Custom LUT" }, { DRM_COLOROP_CTM_3X4, "3x4 Matrix"}, { DRM_COLOROP_MULTIPLIER, "Multiplier"}, + { DRM_COLOROP_3D_LUT, "3D LUT"}, }; static const char * const colorop_curve_1d_type_names[] = { @@ -348,6 +349,53 @@ int drm_colorop_mult_init(struct drm_device *dev, struct drm_colorop *colorop, } EXPORT_SYMBOL(drm_colorop_mult_init); +int drm_colorop_3dlut_init(struct drm_device *dev, struct drm_colorop *colorop, + struct drm_plane *plane, struct drm_mode_3dlut_mode *mode_3dlut, + size_t num, bool allow_bypass) +{ + struct drm_property_blob *blob; + struct drm_property *prop; + int ret; + + ret = drm_colorop_init(dev, colorop, plane, DRM_COLOROP_3D_LUT, allow_bypass); + if (ret) + return ret; + + /* lut_3d_modes */ + prop = drm_property_create(dev, DRM_MODE_PROP_BLOB | DRM_MODE_PROP_IMMUTABLE, "3DLUT_MODES", 0); + if (!prop) + return -ENOMEM; + + colorop->lut_3d_modes_property = prop; + + + blob = drm_property_create_blob(colorop->dev, num * sizeof(struct drm_mode_3dlut_mode), + mode_3dlut); + if (IS_ERR(blob)) + return PTR_ERR(blob); + + drm_object_attach_property(&colorop->base, colorop->lut_3d_modes_property, blob ? blob->base.id : 0); + drm_colorop_reset(colorop); + + drm_property_replace_blob(&colorop->state->lut_3d_modes, blob); + + /* lut_3d_modes index */ + prop = drm_property_create_range(dev, DRM_MODE_PROP_ATOMIC, "3DLUT_MODE_INDEX", 0, num - 1); + if (!prop) + return -ENOMEM; + + colorop->lut_3d_mode_index_property = prop; + drm_object_attach_property(&colorop->base, colorop->lut_3d_mode_index_property, 0); + + /* data */ + ret = drm_colorop_create_data_prop(dev, colorop); + if (ret) + return ret; + + return 0; +} +EXPORT_SYMBOL(drm_colorop_3dlut_init); + static void __drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop, struct drm_colorop_state *state) { @@ -440,7 +488,13 @@ static const char * const colorop_type_name[] = { [DRM_COLOROP_1D_LUT] = "1D Curve Custom LUT", [DRM_COLOROP_CTM_3X4] = "3x4 Matrix", [DRM_COLOROP_MULTIPLIER] = "Multiplier", + [DRM_COLOROP_3D_LUT] = "3D LUT", }; + +static const char * const colorop_lu3d_interpolation_name[] = { + [DRM_COLOROP_LUT3D_INTERPOLATION_TETRAHEDRAL] = "Tetrahedral", +}; + static const char * const colorop_lut1d_interpolation_name[] = { [DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR] = "Linear", }; @@ -476,6 +530,21 @@ const char *drm_get_colorop_lut1d_interpolation_name(enum drm_colorop_lut1d_inte return colorop_lut1d_interpolation_name[type]; } +/** + * drm_get_colorop_lut3d_interpolation_name - return a string for interpolation type + * @type: interpolation type to compute name of + * + * In contrast to the other drm_get_*_name functions this one here returns a + * const pointer and hence is threadsafe. + */ +const char *drm_get_colorop_lut3d_interpolation_name(enum drm_colorop_lut3d_interpolation_type type) +{ + if (WARN_ON(type >= ARRAY_SIZE(colorop_lu3d_interpolation_name))) + return "unknown"; + + return colorop_lu3d_interpolation_name[type]; +} + /** * drm_colorop_set_next_property - sets the next pointer * @colorop: drm colorop diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h index b8c1c4da3444..bf5117f30c80 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -147,6 +147,29 @@ struct drm_colorop_state { */ uint32_t size; + /** + * @lut_3d_modes: + * + * Mode blob for displaying a list of supported 3dlut modes. + * + * To setup a 3D LUT, lut_3d_modes, lut_3d_modes and data are expected + * to be used in the following sequence: + * + * 1. device driver sets a list of supported drm_mode_3dlut_mode in "lut_3d_modes". + * 2. userspace reads "lut_3d_modes" to determines an appropriate mode. + * 3. userspace sets "lut_3d_mode_index" pointing the selected mode. + * 4. userspace passes a 3D LUT via "data" + * 5. usersapce commits to device driver + */ + struct drm_property_blob *lut_3d_modes; + + /** + * @lut_3d_mode_index: + * + * A zero-based index pointing to current lut_3d_mode. + */ + uint16_t lut_3d_mode_index; + /** * @data: * @@ -288,6 +311,21 @@ struct drm_colorop { */ struct drm_property *size_property; + /** + * @lut_3d_modes_property: + * + * 3DLUT mode property used to convert the framebuffer's colors + * to non-linear gamma. + */ + struct drm_property *lut_3d_modes_property; + + /** + * @lut_3d_mode_index_property: + * + * 3DLUT mode index property for choosing 3D LUT mode. + */ + struct drm_property *lut_3d_mode_index_property; + /** * @data_property: * @@ -343,6 +381,9 @@ int drm_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop struct drm_plane *plane, bool allow_bypass); int drm_colorop_mult_init(struct drm_device *dev, struct drm_colorop *colorop, struct drm_plane *plane, bool allow_bypass); +int drm_colorop_3dlut_init(struct drm_device *dev, struct drm_colorop *colorop, + struct drm_plane *plane, struct drm_mode_3dlut_mode *mode_3dlut, + size_t num, bool allow_bypass); struct drm_colorop_state * drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop); @@ -393,6 +434,7 @@ const char *drm_get_colorop_type_name(enum drm_colorop_type type); */ const char *drm_get_colorop_curve_1d_type_name(enum drm_colorop_curve_1d_type type); const char *drm_get_colorop_lut1d_interpolation_name(enum drm_colorop_lut1d_interpolation_type type); +const char *drm_get_colorop_lut3d_interpolation_name(enum drm_colorop_lut3d_interpolation_type type); void drm_colorop_set_next_property(struct drm_colorop *colorop, struct drm_colorop *next); diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index 5ef87cb5b242..290c2e32f692 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -913,6 +913,90 @@ enum drm_colorop_type { * property. */ DRM_COLOROP_MULTIPLIER, + /** + * @DRM_COLOROP_3D_LUT: + * + * A 3D LUT of &drm_color_lut entries, + * packed into a blob via the DATA property. The driver's expected + * LUT size is advertised via the SIZE property. + */ + DRM_COLOROP_3D_LUT, +}; + +/** + * enum drm_colorop_lut3d_interpolation_type - type of 3DLUT interpolation + * + */ +enum drm_colorop_lut3d_interpolation_type { + /** + * @DRM_COLOROP_LUT3D_INTERPOLATION_TETRAHEDRAL: + * + * Tetrahedral 3DLUT interpolation + */ + DRM_COLOROP_LUT3D_INTERPOLATION_TETRAHEDRAL, +}; + +/** + * enum drm_colorop_lut3d_traversal_order - traversal order of the 3D LUT + * + * This enum describes the order of traversal of 3DLUT elements. + */ +enum drm_colorop_lut3d_traversal_order { + /** + * @DRM_COLOROP_LUT3D_TRAVERSAL_RGB: + * + * the LUT elements are traversed like so: + * for R in range 0..n + * for G in range 0..n + * for B in range 0..n + * color = lut3d[R][G][B] + */ + DRM_COLOROP_LUT3D_TRAVERSAL_RGB, + /** + * @DRM_COLOROP_LUT3D_TRAVERSAL_BGR: + * + * the LUT elements are traversed like so: + * for R in range 0..n + * for G in range 0..n + * for B in range 0..n + * color = lut3d[B][G][R] + */ + DRM_COLOROP_LUT3D_TRAVERSAL_BGR, +}; + +/** + * struct drm_mode_3dlut_mode - 3D LUT mode + * + * The mode describes the supported and selected format of a 3DLUT. + */ +struct drm_mode_3dlut_mode { + /** + * @lut_size: 3D LUT size - can be 9, 17 or 33 + */ + __u16 lut_size; + /** + * @lut_stride: dimensions of 3D LUT. Must be larger than lut_size + */ + __u16 lut_stride[3]; + /** + * @interpolation: interpolation algorithm for 3D LUT. See drm_colorop_lut3d_interpolation_type + */ + __u16 interpolation; + /** + * @color_depth: color depth - can be 8, 10 or 12 + */ + __u16 color_depth; + /** + * @color_format: color format specified by fourcc values + * ex. DRM_FORMAT_XRGB16161616 - color in order of RGB, each is 16bit. + */ + __u32 color_format; + /** + * @traversal_order: + * + * Traversal order when parsing/writing the 3D LUT. See enum drm_colorop_lut3d_traversal_order + */ + __u16 traversal_order; }; /** From patchwork Thu Oct 3 20:01:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821537 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 B43A9CF34C1 for ; Thu, 3 Oct 2024 20:04:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BCBA410E92B; Thu, 3 Oct 2024 20:02:13 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="qG7H8w5Z"; dkim-atps=neutral Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2056.outbound.protection.outlook.com [40.107.94.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6243310E999; Thu, 3 Oct 2024 20:02:10 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LnohC1gyFIlXSmALGaMbv8SAdKX0mQievQYaOaNFuX8rfIS9zLYfbmHEfyHkuOgXYuNAvYCGUPSW9UI5ygZ/uxUuIl8z7vNmDy0MgnSqJwInSDT+6YGzxf2lQrif+VVzp6uGJXVxilM3qkdubssEzjAZRpYP/L6Lk3Vzx6Ki+HN6fYiXhYPZPYiZW1TVBDQnmruhWty4Z7r9ezYsHNr81bEe7+IrpRwY9qhXsR1W1kYC2ORG00/V9cTStg1hwEf5LVCbKB+WXPm6pH1O/ehu93MzWSqAt6RhBTsHzMQV9ccoy0HiI7h2hwea0TLO6QR6iv34krtAzcilMeTt0bioYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=qMZ3u+T7x38oaJ2wsoNIKpL3tRsotwfPOYjDt9F40wk=; b=q4QZQi+ucORDn6DxpfrnKaji7qf7LnITaWM5e+AroxIILatfHX2hExr9nIKYkKm+Cs0DFMBkPKWOf62Hl9XpqOfcXV2eXqW39iH8Isu9d58BlP+x6oEfNZQKY0qABxmDblbMf6UwYJGd0yEHiKOdn4N8JwrIBejtmH3wVOA5+hNS4hKOSdwPyTckN0z1H2HwPGkJdMhp4+o0DhLMIw2GmjachwXjGTt806OR8Mo26w4pCmHp4frOlEUudZPkE72z8fk9VaALUeSdAHLvg4AJ5FjauH5o2ygtRDgHTgY1rrFbB62MI/NW/5kifDIRFL1LHnitGQV/gWPcQ42BCKZQPw== 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=qMZ3u+T7x38oaJ2wsoNIKpL3tRsotwfPOYjDt9F40wk=; b=qG7H8w5ZtF+PIYgS1YJ5EfhKGSJc/mfDpKDRVGPw3X4GgNqxTJts7RFyKte6TKYw2mj6soVOo06nkopK/2IsP0g1gvG3t+ni0cWjR4RdtPrbPScM2vqdHW9gZh8rJ2SPQPeg/usLLDPpTx2AHlGVBdejc57oco6jwfH6jYLObR4= Received: from DM6PR04CA0013.namprd04.prod.outlook.com (2603:10b6:5:334::18) by LV3PR12MB9266.namprd12.prod.outlook.com (2603:10b6:408:21b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.25; Thu, 3 Oct 2024 20:02:03 +0000 Received: from DS2PEPF0000343D.namprd02.prod.outlook.com (2603:10b6:5:334:cafe::26) by DM6PR04CA0013.outlook.office365.com (2603:10b6:5:334::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:02:02 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.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.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:02:02 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:58 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:58 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:58 -0500 From: Harry Wentland To: , CC: , Alex Hung Subject: [PATCH v6 43/44] drm/amd/display: add 3D LUT colorop Date: Thu, 3 Oct 2024 16:01:25 -0400 Message-ID: <20241003200129.1732122-44-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343D:EE_|LV3PR12MB9266:EE_ X-MS-Office365-Filtering-Correlation-Id: 05f07f55-e9ad-4133-6434-08dce3e63f9f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: zWYbEb0KMoF7XJJ81qb4qyaljtyKxGfBLqnICZOmoiD0+6LGE9y/zT61BwNa6+RQbiIJCyPIgoENh953XikUHZvQJflIBPEG2HgU5HplF0JY6PCWRmP0dAn/OYmqulUAu6x+4XNaF8VBCJG3mAIxuB82VYECjhil5LZl7A1t60liPbSglizl2f6TTtf4z90U1SGGrkEXrLrxsj3i3qlL2LJQUZpbsk6PTRhumW0SHreozTCN0BRHgwB7Tcv0yVTLqmqHd44LBiJKDu8Jo8Hd2G2XbdAbHCA2r1zZqazbKaJMbWHxdnSv4P3naRm8d/56VSHZ1DayAdZW3p5PM8yjr5E45lZlWP0rYypnlb8VVw0ykC6LPDtC9slbtblYoIDipdvRo+OLA3ZTbjgv3Fj8KlzExW2vddE6WxE+EEcDmBzAe2fNCkKxl+u87C+kOjhx1/RqrOtSBYS70AzZRRWQ0JbWxM7PZhDUrJjxV4wlrPdLNUgbX1NQ/GoACYcuz9A+p7yTtsS/3edY9XLX2ZqlCW3B5NODcq87QQexVsZv+xMCNUY+GpN9etV0OYEZ5zqtRUd2Ow88lglVTj0qvtA2VEpMzWiXBge7Cd9wtte9IA4MhdsdFxDwwBPf13Hlt9vxw8UwWI3bur2r2RV4B8hQ4h71Vx/2G+v6h1h8ulWb+9zmO3ACO95bMuAqEBtdQPZeFXYbtmmoLOXLV/l7//wB0wiaMNA8hbzOR/zHp9GWR3KXY8lmL77TTMcYXgcmlo3cEKOPGVKYT9MQcrQMMqFZMv0vjqOg/60T8IaGU6TwRtoYbdmVQJCgZJ8zYXmk5zoLNGpPwyIvrCmE8WvTsHzrOli6gxJDJV2p3e4EIMr9TuZOgMz4j5VlYFGR00iLyGeXX+iZc6Xpn/k3Z25Qy41JYABocFTBryldUVlTg7AXw6r77Tim/jU+UMmmgdEjRTKBwl002PWg+0xby3uVJZok3obUVFar9aMI+Zi7n8yyt1Lo6KUFYJHx9jyi8gIxKD81TP+2NzyuWxBTrIoX0O8jh/JsOyHCTzEwpGenkL+O9kU3v5vcQL0E3CrcWNbaFWOeLUWsbNRHkeHgsmwjAYV+lMkdmBlQIBpHwQcL/PzaFz9dgq9oEv3m9A1DXeDYMUuw//fZ3U+S9J4jlmEujshbQpqVvnhqY3SnvkYsKgi8+iVEpfu1lR2JvSm0ewdTHbc1om0HSlcC4wSKXQazV+NBySjooQKsWqIg8vZy8YEyY0x/ApYXNfqb/ri9wgrT5XTQqDUqfzmyGg3NPh60UZWl5Ci5WpfOGUwxKOx14PYeMjqvzBD41jY6QjPaqymvOD1qsrtQ+ejqIBWORQmAwC3bgvQOLfhA/FQwO3loTxfqfVNTewY9yBfGN/vC3k1cI1ei X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(82310400026)(376014)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:02:02.7911 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 05f07f55-e9ad-4133-6434-08dce3e63f9f 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=[SATLEXMB04.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: LV3PR12MB9266 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 This adds support for a 3D LUT. The color pipeline now consists of the following colorops: 1. 1D curve colorop 2. Multiplier 3. 3x4 CTM 4. 1D curve colorop 5. 1D LUT 6. 3D LUT 7. 1D curve colorop 8. 1D LUT Signed-off-by: Alex Hung --- .../amd/display/amdgpu_dm/amdgpu_dm_color.c | 113 +++++++++++++++++- .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 27 +++++ 2 files changed, 137 insertions(+), 3 deletions(-) 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 e41329cffd9e..3814f6fce4a2 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 @@ -1283,7 +1283,8 @@ __set_dm_plane_colorop_multiplier(struct drm_plane_state *plane_state, static int __set_dm_plane_colorop_shaper(struct drm_plane_state *plane_state, struct dc_plane_state *dc_plane_state, - struct drm_colorop *colorop) + struct drm_colorop *colorop, + bool *enabled) { struct drm_colorop *old_colorop; struct drm_colorop_state *colorop_state = NULL, *new_colorop_state; @@ -1311,6 +1312,7 @@ __set_dm_plane_colorop_shaper(struct drm_plane_state *plane_state, tf->tf = default_tf = amdgpu_colorop_tf_to_dc_tf(colorop_state->curve_1d_type); tf->sdr_ref_white_level = SDR_WHITE_LEVEL_INIT_VALUE; __set_output_tf(tf, 0, 0, false); + *enabled = true; } /* 1D LUT - SHAPER LUT */ @@ -1338,8 +1340,101 @@ __set_dm_plane_colorop_shaper(struct drm_plane_state *plane_state, shaper_size = shaper_lut != NULL ? shaper_size : 0; /* Custom LUT size must be the same as supported size */ - if (shaper_size == colorop_state->size) + if (shaper_size == colorop_state->size) { __set_output_tf(tf, shaper_lut, shaper_size, false); + *enabled = true; + } + } + + return 0; +} + +/* __set_colorop_3dlut - set DRM 3D LUT to DC stream + * @drm_lut3d: user 3D LUT + * @drm_lut3d_size: size of 3D LUT + * @drm_mode_3dlut: drm_mode selected by userspace + * @lut3d: DC 3D LUT + * + * Map user 3D LUT data to DC 3D LUT and all necessary bits to program it + * on DCN accordingly. + */ +static void __set_colorop_3dlut(const struct drm_color_lut *drm_lut3d, + uint32_t drm_lut3d_size, + struct drm_mode_3dlut_mode *drm_mode_3dlut, + struct dc_3dlut *lut) +{ + if (!drm_lut3d_size) + return; + + lut->state.bits.initialized = 0; + + /* Only supports 17x17x17 3D LUT (12-bit) now */ + if (drm_mode_3dlut->color_depth == 12) + lut->lut_3d.use_12bits = true; + else + return; + + if (drm_mode_3dlut->lut_size == 17) + lut->lut_3d.use_tetrahedral_9 = false; + else + return; + + lut->state.bits.initialized = 1; + __drm_3dlut_to_dc_3dlut(drm_lut3d, drm_lut3d_size, &lut->lut_3d, + lut->lut_3d.use_tetrahedral_9, + drm_mode_3dlut->color_depth); + +} + +static int +__set_dm_plane_colorop_3dlut(struct drm_plane_state *plane_state, + struct dc_plane_state *dc_plane_state, + struct drm_colorop *colorop, + bool shaper_enabled) +{ + struct drm_colorop *old_colorop; + struct drm_colorop_state *colorop_state = NULL, *new_colorop_state; + struct dc_transfer_func *tf = &dc_plane_state->in_shaper_func; + struct drm_atomic_state *state = plane_state->state; + const struct amdgpu_device *adev = drm_to_adev(colorop->dev); + const struct drm_device *dev = colorop->dev; + struct drm_mode_3dlut_mode *mode; + const struct drm_color_lut *lut3d; + uint32_t lut3d_size, index; + int i = 0; + + /* 3D LUT */ + old_colorop = colorop; + for_each_new_colorop_in_state(state, colorop, new_colorop_state, i) { + if (new_colorop_state->colorop == old_colorop && + new_colorop_state->colorop->type == DRM_COLOROP_3D_LUT) { + colorop_state = new_colorop_state; + break; + } + } + + if (colorop_state && !colorop_state->bypass && colorop->type == DRM_COLOROP_3D_LUT) { + if (!adev->dm.dc->caps.color.dpp.hw_3d_lut) { + drm_dbg(dev, "3D LUT is not supported by hardware\n"); + return 0; + } + + drm_dbg(dev, "3D LUT colorop with ID: %d\n", colorop->base.id); + mode = (struct drm_mode_3dlut_mode *) colorop_state->lut_3d_modes->data; + index = colorop_state->lut_3d_mode_index; + lut3d = __extract_blob_lut(colorop_state->data, &lut3d_size); + lut3d_size = lut3d != NULL ? lut3d_size : 0; + __set_colorop_3dlut(lut3d, lut3d_size, &mode[index], &dc_plane_state->lut3d_func); + + /* 3D LUT requires shaper. If shaper colorop is bypassed, enable shaper curve + * with TRANSFER_FUNCTION_LINEAR + */ + if (!shaper_enabled) { + tf->type = TF_TYPE_DISTRIBUTED_POINTS; + tf->tf = TRANSFER_FUNCTION_LINEAR; + tf->sdr_ref_white_level = SDR_WHITE_LEVEL_INIT_VALUE; + __set_output_tf(tf, NULL, 0, false); + } } return 0; @@ -1468,6 +1563,7 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state, { struct drm_colorop *colorop = plane_state->color_pipeline; struct drm_device *dev = plane_state->plane->dev; + bool shaper_enabled = false; int ret; /* 1D Curve - DEGAM TF */ @@ -1508,7 +1604,7 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state, return -EINVAL; } - ret = __set_dm_plane_colorop_shaper(plane_state, dc_plane_state, colorop); + ret = __set_dm_plane_colorop_shaper(plane_state, dc_plane_state, colorop, &shaper_enabled); if (ret) return ret; @@ -1517,6 +1613,17 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state, if (!colorop) return -EINVAL; + /* 3D LUT */ + colorop = colorop->next; + if (!colorop) { + drm_dbg(dev, "no 3D LUT colorop found\n"); + return -EINVAL; + } + + ret = __set_dm_plane_colorop_3dlut(plane_state, dc_plane_state, colorop, shaper_enabled); + if (ret) + return ret; + /* 1D Curve & LUT - BLND TF & LUT */ colorop = colorop->next; if (!colorop) { 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 22bddb45043a..645b7a28445e 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 @@ -47,6 +47,17 @@ const u64 amdgpu_dm_supported_blnd_tfs = BIT(DRM_COLOROP_1D_CURVE_PQ_125_EOTF) | BIT(DRM_COLOROP_1D_CURVE_BT2020_INV_OETF); +struct drm_mode_3dlut_mode lut3d_modes[] = { + { + .lut_size = 17, + .lut_stride = {17, 17, 17}, + .interpolation = DRM_COLOROP_LUT3D_INTERPOLATION_TETRAHEDRAL, + .color_depth = 12, + .color_format = DRM_FORMAT_XRGB16161616, + .traversal_order = DRM_COLOROP_LUT3D_TRAVERSAL_RGB, + }, +}; + #define MAX_COLOR_PIPELINE_OPS 10 int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_prop_enum_list *list) @@ -145,6 +156,22 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr i++; + /* 3D LUT */ + ops[i] = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL); + if (!ops[i]) { + DRM_ERROR("KMS: Failed to allocate colorop\n"); + ret = -ENOMEM; + goto cleanup; + } + + ret = drm_colorop_3dlut_init(dev, ops[i], plane, lut3d_modes, ARRAY_SIZE(lut3d_modes), true); + if (ret) + goto cleanup; + + drm_colorop_set_next_property(ops[i-1], ops[i]); + + i++; + /* 1D curve - BLND TF */ ops[i] = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL); if (!ops[i]) { From patchwork Thu Oct 3 20:01:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13821538 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 EE0E6CF34C3 for ; Thu, 3 Oct 2024 20:04:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 53FEF10E933; Thu, 3 Oct 2024 20:02:14 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="CViii64q"; dkim-atps=neutral Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2063.outbound.protection.outlook.com [40.107.92.63]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0A6A610E933; Thu, 3 Oct 2024 20:02:11 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=h5che6DUmPVYAtLY/NxCAPKeDcV0a8uY+5yegAu+Huh9Kcl5FkIBkZwQ0OXab5r350RsguVBpI+Rvd1dwBYEQlZxQB56FJaKNjn49G9throkziB7cy+XUavZh3U6BfqQnzuuXAuo7HyB6+sKOSeiAcCFksokEGvKPSQU8gFdOxnMjvcL9/E6U14frgdImtmuBrj1CATZJi4dIWZXD8Fart4eOXBTKdF5OOzPaVj607MVueQjaG3ny/UETxotiEvpldulLLugdKxpgJpeylZmbnP7z/i90gZ/TuoPFKvQWniTBg+gBme1Lkf/rhuS45rI9G+21vCK2NuDVl5q7XVqTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=2MTGeOwN+W6NkQgKLazuaznTq/QunsfljGA2AwsDXHY=; b=iZAYzlp3ZNYH6IpYIBrtIViEEIML1B1OBFR5sd6rDPfI8tKI7aeAVkm/pOVaVNiWQuMb4k1hAOiF8V2cboMGFegYyhAttntnAGLgRvEo39cG1Ib6BBb38QOax0ElkA/rg25jGN/0vPwSYQdyAqcWVLZDsLoeGSxZD6rjr3/rsC/ewCyHrFD4UCzT0bI0cqe4r1bnpZEhQrZaHesfZZyn+pU1gIlWanGGiwPh2u0eEVlDqTGlLjN+CD1zlt9lplV2e0uA/PvD5EKIsH6FxHTroFjxIY54P7C9HbVL5dZ8PyhuJRPsW5KZimPL4RTU8skXBDT56+y0dltWnHzRvFPAoQ== 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=2MTGeOwN+W6NkQgKLazuaznTq/QunsfljGA2AwsDXHY=; b=CViii64qIMwGUAP0Q6Ye8vDmbmFjEas9cxBus7M2sCntitbwqoOWY7WL+CXZW8dBwI/N3CdXdAk9ZZK5+iwwthMZHQ7ZEb4YRwvoE9e2vYMSsbA/VSgdM/fo3UoICF+IbUs1N2jyKmCNae6/3UTSGeg8CA/46qsy/fODHSUrWmM= Received: from DM6PR04CA0020.namprd04.prod.outlook.com (2603:10b6:5:334::25) 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.8026.16; Thu, 3 Oct 2024 20:02:08 +0000 Received: from DS2PEPF0000343D.namprd02.prod.outlook.com (2603:10b6:5:334:cafe::da) by DM6PR04CA0020.outlook.office365.com (2603:10b6:5:334::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 20:02:08 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.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.8026.11 via Frontend Transport; Thu, 3 Oct 2024 20:02:07 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 15:01:58 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 15:01:58 -0500 From: Harry Wentland To: , CC: , Harry Wentland Subject: [PATCH v6 44/44] drm/amd/display: Add AMD color pipeline doc Date: Thu, 3 Oct 2024 16:01:26 -0400 Message-ID: <20241003200129.1732122-45-harry.wentland@amd.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003200129.1732122-1-harry.wentland@amd.com> References: <20241003200129.1732122-1-harry.wentland@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: harry.wentland@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343D:EE_|DS0PR12MB7728:EE_ X-MS-Office365-Filtering-Correlation-Id: fa488002-0030-4923-3ff5-08dce3e642a6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|1800799024|36860700013|376014; X-Microsoft-Antispam-Message-Info: oZABx1RfBu3XVK0LkknXZ2aerfGa9a4Wo0W3lNUnNzArBYHy+rDWJggwMat5lSMw733q3iKAGkuzUYLg2U3W8aJVzCn4VdzqUisxaUApm9DCXIk13VmtiW/fmWTv9/NB/rGYb+l3nvUjcXvpgmMbN1YzDKD/ohtamEDhq0o/eooYcJZBj3m1Dbj1d00Jn5K1E6gRXukOwdHSzRI4SAXsvDBlzVNpccoSm/yz8gafcm+ogqtqvPcZRQQeL6LdmPV+4n7W0zES7qC5UalTyEcJbOXh9GYaD5XxVJtnhRZz/TVlZhSGIfz0Jmiph3SWKhGVi0LnBaEGA49pHvF0gbx4K6Z1W8P8cwYtErEtJRbZZBYAGCtF/4CfgRtc8+6D26o4I0hAm4jwoewOskJxwoqs8ynqxJO3tQ7ly4m8CVF6cfQocbBlfaSOFNCQsUYshgEjifUq021qXPr/MXPTwEt/2QqfWVV3xLgQpsucelBkW+jOE4JIq7B9aqkm3gmK0LW+LqWDff2Dt5Xo05vP8p1LFCI3JN/F3w7Chm0H/7WjhnT3uvdhixYWBh3a/82Fd0Sz8CI3iRXzmbLLxmIfoUAKDcomhiZE44hLJuxznQRlaxfinnwEwqJYKQZWUxJPqyTqnk9GRFtiBstDSCcn8OlrvjxC+J+2tWdTnMoW2CgPvZmO/+bIDpNYAG/ynJTyTUy2TMNjZmuGHSkNrAu4QHIpjFRjhLpPtsBADo4zVnPco6uYfns/PAT4RGW5zy2u0RjJ2ysz5o9yM+g4Yo4l0bZ2c1fisCumDQU2LxeOxyjeJlNW4oJH7qlj6/mXM7GAfqb1NsHYWD6nvQskHIrivGJUIxn8+I0ryRTEvYgWQpeUC+KtRngd7qRWDcFJ+K2x2zj5GOvxO5ayYtmTTdfvkRy0PJIcMATej34h0HphpZs++kqntWLyzuyZpriNqEUlcLQm+xVrZJHeg0EsngijMWQIzXBGmyl1IJKraq1Z7zVNyPiKi+DOWz1xJyteki7IvWY4g6z++YqLQPH0sn+bIwUtDBtKnOkoXfBn/5seClscS8Y9E7UTUZPP5fEnK/wbKl9o+FRvt06sZmCbcJhxjGtPO3xfVA4K+Fxuf82/HYyvmKmsr9NDgGmpTaKDkIta9Gf8NgbUFov+F2c4Aw9rAKF/cIbssyHWc3FNffzh1eQpHBQgb2ok9fWHSHpZs3xzrBxQ2upKMKa7sxAkE/sCRT82/a+oQhpxJiUrctkF8FTO0EuST2ivZPnfNlftVzjxDmqVAugPOLpRiesaKjrmUGo3g5N/LKb3SS70AGakzFBiUIAwahXjzKujjFA6lNm2lIhvkxHtdrLMtsOiLgwCAuge9oCzF+hlUUgzClZOBuRM5jL/yjzMeuRyEpiHIsusAfpR X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(82310400026)(1800799024)(36860700013)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:02:07.9161 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fa488002-0030-4923-3ff5-08dce3e642a6 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=[SATLEXMB04.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" A short description about the AMD color pipeline. Signed-off-by: Harry Wentland --- .../amd/display/amdgpu_dm/amdgpu_dm_color.c | 122 +++++++++++++++--- 1 file changed, 102 insertions(+), 20 deletions(-) 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 3814f6fce4a2..8c5d91556462 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 @@ -33,6 +33,32 @@ /** * DOC: overview * + * We have three types of color management in the AMD display driver. + * 1. the legacy &drm_crtc DEGAMMA, CTM, and GAMMA properties + * 2. AMD driver private color management on &drm_plane and &drm_crtc + * 3. AMD plane color pipeline + * + * The CRTC properties are the original color management. When they were + * implemented per-plane color management was not a thing yet. Because + * of that we could get away with plumbing the DEGAMMA and CTM + * properties to pre-blending HW functions. This is incompatible with + * per-plane color management, such as via the AMD private properties or + * the new drm_plane color pipeline. The only compatible CRTC property + * with per-plane color management is the GAMMA property as it is + * applied post-blending. + * + * The AMD driver private color management properties are only exposed + * when the kernel is built explicitly with -DAMD_PRIVATE_COLOR. They + * are temporary building blocks on the path to full-fledged &drm_plane + * and &drm_crtc color pipelines and lay the driver's groundwork for the + * color pipelines. + * + * The AMD plane color pipeline describes AMD's &drm_colorops via the + * &drm_plane's COLOR_PIPELINE property. + * + * drm_crtc Properties + * ------------------- + * * The DC interface to HW gives us the following color management blocks * per pipe (surface): * @@ -43,33 +69,89 @@ * - Surface regamma LUT (normalized) * - Output CSC (normalized) * - * But these aren't a direct mapping to DRM color properties. The current DRM - * interface exposes CRTC degamma, CRTC CTM and CRTC regamma while our hardware - * is essentially giving: + * But these aren't a direct mapping to DRM color properties. The + * current DRM interface exposes CRTC degamma, CRTC CTM and CRTC regamma + * while our hardware is essentially giving: * * Plane CTM -> Plane degamma -> Plane CTM -> Plane regamma -> Plane CTM * - * The input gamma LUT block isn't really applicable here since it operates - * on the actual input data itself rather than the HW fp representation. The - * input and output CSC blocks are technically available to use as part of - * the DC interface but are typically used internally by DC for conversions - * between color spaces. These could be blended together with user - * adjustments in the future but for now these should remain untouched. + * The input gamma LUT block isn't really applicable here since it + * operates on the actual input data itself rather than the HW fp + * representation. The input and output CSC blocks are technically + * available to use as part of the DC interface but are typically used + * internally by DC for conversions between color spaces. These could be + * blended together with user adjustments in the future but for now + * these should remain untouched. * - * The pipe blending also happens after these blocks so we don't actually - * support any CRTC props with correct blending with multiple planes - but we - * can still support CRTC color management properties in DM in most single - * plane cases correctly with clever management of the DC interface in DM. + * The pipe blending also happens after these blocks so we don't + * actually support any CRTC props with correct blending with multiple + * planes - but we can still support CRTC color management properties in + * DM in most single plane cases correctly with clever management of the + * DC interface in DM. * - * As per DRM documentation, blocks should be in hardware bypass when their - * respective property is set to NULL. A linear DGM/RGM LUT should also - * considered as putting the respective block into bypass mode. + * As per DRM documentation, blocks should be in hardware bypass when + * their respective property is set to NULL. A linear DGM/RGM LUT should + * also considered as putting the respective block into bypass mode. * - * This means that the following - * configuration is assumed to be the default: + * This means that the following configuration is assumed to be the + * default: + * + * Plane DGM Bypass -> Plane CTM Bypass -> Plane RGM Bypass -> ... CRTC + * DGM Bypass -> CRTC CTM Bypass -> CRTC RGM Bypass + * + * AMD Private Color Management on drm_plane + * ----------------------------------------- + * + * The AMD private color management properties on a &drm_plane are: + * + * - AMD_PLANE_DEGAMMA_LUT + * - AMD_PLANE_DEGAMMA_LUT_SIZE + * - AMD_PLANE_DEGAMMA_TF + * - AMD_PLANE_HDR_MULT + * - AMD_PLANE_CTM + * - AMD_PLANE_SHAPER_LUT + * - AMD_PLANE_SHAPER_LUT_SIZE + * - AMD_PLANE_SHAPER_TF + * - AMD_PLANE_LUT3D + * - AMD_PLANE_LUT3D_SIZE + * - AMD_PLANE_BLEND_LUT + * - AMD_PLANE_BLEND_LUT_SIZE + * - AMD_PLANE_BLEND_TF + * + * The AMD private color management property on a &drm_crtc is: + * + * - AMD_CRTC_REGAMMA_TF + * + * Use of these properties is discouraged. + * + * AMD plane color pipeline + * ------------------------ + * + * The AMD &drm_plane color pipeline is advertised for DCN generations + * 3.0 and newer. It exposes these elements in this order: + * + * 1. 1D curve colorop + * 2. Multiplier + * 3. 3x4 CTM + * 4. 1D curve colorop + * 5. 1D LUT + * 6. 3D LUT + * 7. 1D curve colorop + * 8. 1D LUT + * + * The multiplier (#2) is a simple multiplier that is applied to all + * channels. + * + * The 3x4 CTM (#3) is a simple 3x4 matrix. + * + * #1, and #7 are non-linear to linear curves. #4 is a linear to + * non-linear curve. They support sRGB, PQ, and BT.709/BT.2020 EOTFs or + * their inverse. + * + * The 1D LUTs (#5 and #8) are plain 4096 entry LUTs. + * + * The 3DLUT (#6) is a tetrahedrally interpolated 17 cube LUT. * - * Plane DGM Bypass -> Plane CTM Bypass -> Plane RGM Bypass -> ... - * CRTC DGM Bypass -> CRTC CTM Bypass -> CRTC RGM Bypass */ #define MAX_DRM_LUT_VALUE 0xFFFF