From patchwork Fri Dec 20 04:33:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916197 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 CDD8CE77188 for ; Fri, 20 Dec 2024 04:36:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4825210EAC6; Fri, 20 Dec 2024 04:36:01 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="p2aXtkGN"; dkim-atps=neutral Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on20611.outbound.protection.outlook.com [IPv6:2a01:111:f403:2418::611]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5A9D910EAC6; Fri, 20 Dec 2024 04:36:00 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=J25mU238ENkzEEPJwueD34nBTrZeqH+Zws6+aMiFT78gKJ8ZgBpoqm8+VPc1rG5d1o3ZeqpXcRHjBNrFaIjtTFtbJ0K3418qB0ffCudmgdWw1tcCIZyLwteTuIMIGvMoHOCbNWbK/ztmJ/2+UoXmD9huhb/NP+TKbQUc6kVP1067+O/1U2qI4GkNUKNhV4Scs3ncmNZokbrO+HckvH9boyGtXOfj9r/YmOJ5SVyrRmqKw4yCDNc83sRPK1D6BJSDAt+Zv3RiOSMX5yPwhXJFzGjTCJtkIP20FMQCX6QKQXt/XOSqQXfhBf/2x7tafFoApSzCtGXgSvl4NsXD+bBB1w== 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=UE2HvkvPQjXnasl6XTZptxybD93JK74TUNlzsOJS/6A=; b=u4+2fdLatPE3C5UkQWsjgiiGNV0if9gicDn7vRcHtmSL3rBa4u5VVlxVqV8qmkzubjiM5gIwnDyvhHHtNvz80ZOrm0ZLqDzUeG3TF7MD/9yg28xdmqxupPZsOysZdCap5K41gEdZhfHEnAnpaUT/E40HIoZfGkv251dfFz9Yhp/TsJxNN5ebrB3epdVE5aSyRQSxeHDCa/mt0Gw3eDvm+8WAno85TslZp2K+buvtbOxKe4NVwfv+NemYIT2iysi9k+Mr/49cnG7tam2lbGLSSXAzk1yeADSSkBtGGh0igGg1Dt2oK/Kv0e7ysJkiQbkmFmsZuogkcV7UAGxbVBQGvg== 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=UE2HvkvPQjXnasl6XTZptxybD93JK74TUNlzsOJS/6A=; b=p2aXtkGNS+rs+tawWjs5FiNNevtG7Uz2ndYlUNVL5SiKpU/TG/NHg63Ct/cyjzD2m4OILeSMLWiZnOq+t77HiMNP7ubs77jBWx8sqyFYZnMCzNEF8fsGzzOtqzMdS+7Hlqgn2TPSh5TLxpzg3X+umVxHL2IfGKGuU3kbxYvL6PY= Received: from SA0PR11CA0048.namprd11.prod.outlook.com (2603:10b6:806:d0::23) by CH3PR12MB8509.namprd12.prod.outlook.com (2603:10b6:610:157::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.16; Fri, 20 Dec 2024 04:35:52 +0000 Received: from SA2PEPF00001505.namprd04.prod.outlook.com (2603:10b6:806:d0:cafe::85) by SA0PR11CA0048.outlook.office365.com (2603:10b6:806:d0::23) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.24 via Frontend Transport; Fri, 20 Dec 2024 04:35: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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF00001505.mail.protection.outlook.com (10.167.242.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:35:52 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:35:50 -0600 From: Alex Hung To: , CC: , , Subject: [V7 01/45] drm: Add helper for conversion from signed-magnitude Date: Thu, 19 Dec 2024 21:33:07 -0700 Message-ID: <20241220043410.416867-2-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001505:EE_|CH3PR12MB8509:EE_ X-MS-Office365-Filtering-Correlation-Id: 30fbac6d-66df-4961-303d-08dd20afc947 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: MJYzB+jt/Zsy4nmwUVAfLDlsJnbjiByuNG8JoGFla8eyu90VpSMBzeR6eKS9IEkbD+yZcTEwWNB17oXM9O48xca059JwhwBuLgJi6J8b1eNH7M/HOf4dRBR5FO5jpEG09EZeW+nVu2ic/uOlZ0suDGUFfyB5CLnHbOdlcr/8am4T2giofBNbt+qfkpxsnAvCl93diPvAyVp9cTRCA7JUnpii/n6frsw222czLzXf2E3irpGjdllWez9orbjGPZ5ExdJAtYRJFx9tn1JfC/fARb7gVm1VFFxQZjKvner6z9uiK1D/DBJrSILx64is1rUgQDotLH3gJkSK+7vEw7G6UhGiM+S6v3C9zRwtoJb7ASpw9DmgWbAcA7qn5jCnaFeJHOvFWLib2QOwqRcDtPJhxvtq4v7xCcmwMNIrQPH0RlMCVHnIBYQPZpelEppOmp8s6YwJJVSHM81Jq4kOLiOFLWQ2n7i8IvAQFsdtKndufqTZZrqzXjhxqIw2yxIkYSnEFr9NzQAg+BFnauIZJZYO1//T9QWkNeAGhssryr/ngcpbEVsmzU1fDYZRUvjCtDgfcDC12zmPW4GqbMvGmCv3PpyV2FdfLzCHbpXfIglh2NWWL2egTHnNe5PdE05rsG8j2tLSUKDmRwIuhV7LJRQtbL755ffSuZUS/fs3XVuTChCW4YfoadXi2vRBpFYIZJm/f8QgGL+febHdRnYberIntn13JWO7SXk1ZEYpHLBiGRbnpnXqsCCLZ45/t1np76Y6Y2v4fRQFDMb+FxuDJoHlAzpeiIIJLvta8RqOlwWcB8MHOJs8YQur2OY37zPHb54+dMIiYGf9ArhAqW0/RwNYmQLZYx9eCjvfPSsdl4YDFVaPC25Xc375EDYbpLdDT3MTnImbOmJnlLaZsTajRAUxzJpiXM7yjjVWnwr8JL6op+S+klsYx++EY7Sr6dFd/nzLUulDT0JMxIjH2TTzu6I+sUKSSlOOeKrPfdzIFhkcwL1fWkrxS8huQc3Km2ttL8wJol25gtEANV/XrwGozXJZaNFMy5viaPLytwV6CVAJvxWcRPeSPRwavfJaIG6LwBtx5l5E8uV3oqGihYHhPv+LFJG14vEWGUqUjnRUKb17zDNDKTxvFqIeMsJ38IqP4TQSP5OSY5IxlZS8qwbepnho6pGwt58FDaVfYoA9bhu0l8ya33yH0ABxKdFwqtLx78Tr6mZVdVOmVPMAWwLIzTQIU1Hdp1OXlD7oSdIboq0Rh5Mm3ZBni7JoVXybYxbay6eadjWLK7aXgZG+KKEyCgqmhgRfahfy4zLcoAUmRmUhxnbBbhFqYYidpKw/t51Zc+7NnO0v2BYApYBb4oOiiHZ8A+5Vp5AkiCzId5NEo7w9jGuYva7JOSxora/hScUbI7XHYBcK2fVWBQxHcg/XYOcQaV2R+DKOEH2UgblYyn1q20irfoZtYvqA36LXAk2FLBD6dO+AorU8e6b6PfFA2UR3BpQGt9KQOs7CLRuu0BDE3yo= 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: 20 Dec 2024 04:35:52.3948 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 30fbac6d-66df-4961-303d-08dd20afc947 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: SA2PEPF00001505.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8509 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: Harry Wentland 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 Fri Dec 20 04:33:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916198 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 1874DE77188 for ; Fri, 20 Dec 2024 04:36:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8CFAD10EE52; Fri, 20 Dec 2024 04:36:11 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="31xVGESb"; dkim-atps=neutral Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2051.outbound.protection.outlook.com [40.107.92.51]) by gabe.freedesktop.org (Postfix) with ESMTPS id 57BB310EE52; Fri, 20 Dec 2024 04:36:10 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=c4g+7u/U7rBf5U11gWgfKxtsUE93HnGLxVKqXBigxIiPjydoGSAEFrVbQCpMhrLU+/wPSwssRNswJ9pXhFKepNKuB8I4Cop/R3Y8YSPvUa9i9pZDI2S7dlt+08NzIkjozd4U8dcrkSZ27sFRUPzAoZw5rbxIslQjkGTAhOsMnAFlmNnYwf5q4nG2C4pcWtYgLIg9FE/dPlw2uWUi7fdYVEuO133uTt+qnpj+yF0IN9PgjgxdYeMR1DZleT5O+BxnA4qpURbkTTQKJtV3BFUqeLW2kPbsDJkgmbq5HeTBz8WLzqkuQAxq3qK2Rn+F3DVqFmAFg/AutqbGqomqZzH0NQ== 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=JJmsKdITpoHQX7Uf5WJlZaTbbEt2gR7WQlEOlkheISQ=; b=iQPhWVMtnTe1KYXlRLJEJgHRNI9F+ym62GzfB9Ki/xpZdUUhoFmc/hkIXa1t+ANal6kuMTXyskM300X0OLpZRqP5HsqGIjuZNYGe/LGayUNtcH+NO8WuQcW8SKmb/aqiwg5dsO4WVlnLl4NzaF/kj/wZ2WvnQ93GJr9H/yIC8T1Mm5DgrlI7XiSH1ddyfL7k5nGF672XRRRNkTChNlTbBZ942UwdOAzKx7IPe1Eqyk+7JB5xBlQkT+nfqDOEZaGkLQZLiO2MSE8bVtpuKGpRxph+PqsZHNfSqMxKIM1xWDfz92DLzQd28C5UjeRrbsaDPi5SoR8vPBWITQY20N1onA== 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=JJmsKdITpoHQX7Uf5WJlZaTbbEt2gR7WQlEOlkheISQ=; b=31xVGESbcf5joA486CN9feD2i5YMHyd3fkBfQw3ap24/gL0gyvzDwEJARPn3IVqtqlh3YbNnZQed5eZ8coQwd7NDJNvGfZg8GsLfALu2VzPqy9tRV0ozgLd8WhvVHBhP/AW8qTf6GF/H1cO9fQx4SP5YMTkTRIc8cppiQifTK00= Received: from SN1PR12CA0050.namprd12.prod.outlook.com (2603:10b6:802:20::21) by CH3PR12MB7499.namprd12.prod.outlook.com (2603:10b6:610:142::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.16; Fri, 20 Dec 2024 04:36:05 +0000 Received: from SA2PEPF00001504.namprd04.prod.outlook.com (2603:10b6:802:20:cafe::11) by SN1PR12CA0050.outlook.office365.com (2603:10b6:802:20::21) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.22 via Frontend Transport; Fri, 20 Dec 2024 04:36:05 +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 SA2PEPF00001504.mail.protection.outlook.com (10.167.242.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:36:05 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:36:03 -0600 From: Alex Hung To: , CC: , , , Louis Chauvet Subject: [V7 02/45] drm/vkms: Round fixp2int conversion in lerp_u16 Date: Thu, 19 Dec 2024 21:33:08 -0700 Message-ID: <20241220043410.416867-3-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001504:EE_|CH3PR12MB7499:EE_ X-MS-Office365-Filtering-Correlation-Id: 9c47f5ed-c27d-44e6-fe20-08dd20afd0cf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: o1HrAfBz2DQHxv12crIa6SKJDujkbUN8n6CDTNT3L1hyEI/2qKJJMdPtxOSawD0pbu+J8oN3hOvp/VwnVSFK+K8bTBVf+2Np4Tn8KH2pTJM1zlmYxkKF8qvNo1850OkalBqH//8ACAm1ncQL7cVbdibtkiTx4tIT9Xy58AkIUVyTer043mNwFcH7NL0shOrJtEKvd/HA36mu9/0CpMwNLROvm2T2UXKbj5ynWCSf6Hx4BFtS0Pgb0DGOSGJVdZJP+ZgnI5Bt437uPAeKV2s8unTzAEDhwc3U72kzxXD2GU0q4ei1ZuRm467HCklrjhiCntiqTYczOKJdDVIw6Ojehy7DLSEp9C59ERA666Tbhw0N7TC9x05BMrC9d6/nIIv7dQqMPSqsswrTit+2Kt7+mHbC9TzreP4y7ol0bKI0Od2qSYP5KfzECncMepM8Fkmo/eZ4Wt2vjPrukaD5weGiCBWxfRiufyOkeLRi+aSj3gPpY0OXK48R9xBO7qUH1f1Rx/dNEN1EeshmTQdFYOovoWmfb2OGvu5yBNiOwOjEtE3m5jAPTx+EREqhBJ4N7W54bUgvg2tibM23ESIUSZJJdqPiJfsf9UYw2PGx9dZ6qnQbIoYmy1ym9QyW5KkZMurKjG3N6GH8u9cN9QPl/YOHldNSLE7KtN7lZUBDLwhdhtFWpU4xAb3IVIqgvRcwMZ+NSNqqdBqB+tqKfjMf4Kt9uzz5fJk1IdQdYiDJ748HWruWngH/MgdoK73/O+NEkt+yEEJUUVHS9L/kuqZXwkbEvLFfVy4A6OqkPDE8PHl/j7xy7kCsK/h8edKhb1Td4exzlj8oni9dzs0+pPRXNwMVcRZS/+/c1HVY3QVN5E1DUroSC0TeFp5BnQk5zsjMuoa4Q2mG6M1q5SnqyzWQpWNrhvUG1gIZEC9aD5WWzNowpZji4sztjBW1FqZ6nEJ4dsIMOOz79CDKMd32VpcRYcQiFPhQJwZrN40qsMxSl1HIr7YHwwWBWLDyaoELLP6VS4KseVgT8ygKb49ND24wXhay1nPrFphbO9TmltLjfesxkTClQfZNk33NE6gADoyN4Cp0aWoruhhwx9Kkeatuzt3+HZRk0MV6eDV3vS+b3uvy3hNxwIXyKwbXVop9nMwlKWaoYiARUsyync2f7/f8ZvSgsKEVH5ghbq9Ze/JAEMU1spm/+LVNq2rAJgWSL8WTne5JwKd1hS5fdS8ZMfWOA+l7L0qtkHMt8QLRJrensrV5iXP23tb6kIf6U64956hELF6CS7pjO1efy64IxrNQcUQtqNcQQX8wldHCA6EXwdV9n9FxHD0ATjlNstBsYjaJ1GdoNcV1MmFBqJfUs9gHVwLY1gdae4yqXSbernyM563Qy+YyAqyEAAJVz/3tjK6fA0IfqH0OLWsbNIWSjXu+LuYTK03mYTDRBGWNtN9G03XAgLXmqD+eLEOQQ/j+zmjM3Cf6QeUKaSiBnpCe7SVZv9sT5WjLv98L7vMz4JoZo35RtVw= 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)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2024 04:36:05.0198 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9c47f5ed-c27d-44e6-fe20-08dd20afd0cf 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: SA2PEPF00001504.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7499 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: Harry Wentland fixp2int always rounds down, fixp2int_ceil rounds up. We need the new fixp2int_round. Signed-off-by: Alex Hung 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 Fri Dec 20 04:33:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916199 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 18319E7718B for ; Fri, 20 Dec 2024 04:36:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4F49610EE5D; Fri, 20 Dec 2024 04:36:25 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="joWRlLfx"; dkim-atps=neutral Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2044.outbound.protection.outlook.com [40.107.101.44]) by gabe.freedesktop.org (Postfix) with ESMTPS id B41B110EE5A; Fri, 20 Dec 2024 04:36:23 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=q+IhwMgiILFjQfPtuj6uNT5X7yKeuty5ZQXI9o/syR1usx8wU3PzB6awCutoZUm6JsBimPfOudU2fgqHZUynPAvJtcu2m2hfuf1QDyHit10Dd+IwIkYpoa6L0pe2XNm/aj4LRbJauWqG9+HEFmmUGYYliiK6vk7cfbVe7JF9dlVaE0Dda05dP1lMDPCHp2g5mvdXOgYK4Zb0b/INKTI+dNpxHnL+3WR20lvsGUXaITdgebTStp7g1rOYgqM2NdngLdr/0jTd8jvJk3oZYf5ukH3neRGut1ykdCaBBw6hF27me9Wbhy3+ywFH0SbEBy6vvSRMZW9SNBb7daqf4kFj6w== 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=a1rfNp8DNsQB1VbYHcwlUOHSgRBAYprAVydCupY0pdI=; b=xHycTK0XS1vgIYvLk2B8Pia62USn/tzjnis4lGNu3cCL5DDrhgdas8+rXMSOO7LpdJEr927ZKSItqvd4VARmPQS5xtQeQ8LOV3v5t7TgDq+AorKFhVH88EeqD4RWr8SrEaK5zLBiYAA32byM6syWXP/VY6FrKibgLj7YSHiKkIXRgBmOTSOdU3TTjv9Ig2kRSLFKnmwovRmulVASrcVvyUhA2d8n+AFKVBhLqWDX2UL4EU/oV6ZmrLrlOIPHT5Z1k6jPA01b2Lp4BInciQapB4vkqvvcaX/9SbIlNFWNyAevJ8ngz1RGv/HsBLPP+GIgQNkqbJhIE1Z0tiuC+UNLiQ== 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=a1rfNp8DNsQB1VbYHcwlUOHSgRBAYprAVydCupY0pdI=; b=joWRlLfxWCip10HuVZ5237JDK8pgJeHLmJ2PvTiQlHbY32n/hfBdlVsAwDQdj2IGDNEui+7rNM1P374Q6jcetxMbn05+DyPhEyfgUXUzkaWVpYOZoHmSK3ZpKXIESo2+ixLJKpVi5HORSQvaGLBhft6TOzLNsGyVeeW71VHde0s= Received: from SA1PR02CA0009.namprd02.prod.outlook.com (2603:10b6:806:2cf::14) by PH7PR12MB7890.namprd12.prod.outlook.com (2603:10b6:510:268::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.21; Fri, 20 Dec 2024 04:36:18 +0000 Received: from SA2PEPF00001506.namprd04.prod.outlook.com (2603:10b6:806:2cf:cafe::d1) by SA1PR02CA0009.outlook.office365.com (2603:10b6:806:2cf::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.23 via Frontend Transport; Fri, 20 Dec 2024 04:36:18 +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 SA2PEPF00001506.mail.protection.outlook.com (10.167.242.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:36:18 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:36:16 -0600 From: Alex Hung To: , CC: , , , Louis Chauvet , Arthur Grillo Subject: [V7 03/45] drm/vkms: Add kunit tests for VKMS LUT handling Date: Thu, 19 Dec 2024 21:33:09 -0700 Message-ID: <20241220043410.416867-4-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001506:EE_|PH7PR12MB7890:EE_ X-MS-Office365-Filtering-Correlation-Id: 6ce4d949-1216-4f0d-0785-08dd20afd88c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: HRWbv+yA+4bPnpEKB3y+IWzQkvMqTwNPKRWDzBj5lhfG6bR7SFjPJd3kfdhqmN0aFjX/XbioPzCemIOu0NNBiiOZkmA28MKaGutj5T0OKLbUX8UO3s/gQtt8h+ZcqxxHnfZnkVkb1/Z615hO0NW54XTOe6KwoV1G6K2PZSXx5HN40EZJe6JkcxcsYqF61LrDdTrH1ackf2QLPo6gD5CVrNKelvwpdXndyyMnuV1pAQPiLH1aJbbKq6XpEym+VUb14Y7o8OuQBpnY5hYcuo7etWIVV30WSWHklsZR3VjEqrSyvhja1rTuqdCa5pm9S4Yqw3wPEP11dnFRAOTc0z8LLRtn+RG+Jp8A5C91b7tu1eMUBTDURHTKbedx3COugUessJswONTuq2LkPYuMMz/Fpr660Or+qmA1q9pJnQvR2VBcsz4KnuSqe2+ZRFJRK1dIEJiO2iCBxVZhdgMmjJ9dTEnrUfp73f/Ljlyk1QdGSQyK6ySJWAP/vIc+gJM5tCWW+CLTCeIbyYfIkOyY3+sfPdyGtQcWo/eBiaHEuPD4Vfjp/a7GP6r1WQMKdIPEcSAnc2Bi1RXKwcr6rYyEL6hy5beKJhnvjwec0z0R1OsokNi8nTqi1l+bMkqPVzncHXT5jN1+NvJSbh3Vou1Sv1tWsgGmoWy344NTC2GUButOGRim4AA3H82AK/U/vGTR5nyuDH7YF3NY2AH9+NGks2yMCfbma02b91ykM2WhFL3qfHtzlm5Su3gB2BSocYu1qrjuVxCioT9uHUdnxJOB2Cnvsnka9v6I9usHN+cgGY2I85fOnYUiwsRo2gZXSUjN5oXzPPB25BsAFGAKlhHsgzcbOn2nSP0R4gFxpz/d3xrfZhUFLTAy58893ARDH9S0dyRqgiLarlUUv5matf/EjgihufFaOqo4OdfI7dNqgPE+EbvtQIKcjL0R5wQ+vhkLy8JaBCj4PiA+AqsMVio7xAFoitapl9Qp0yEPTmRvlCaoFPt+Pb4Y7k26dlhDALyeA5CqIwwj4SgR6Vr/LIws/BgmASTuVj3m5YhUjUl8/WzZahnWCLXeWD7kk3xujlN7J/pwI52YsLD+AipNcc2DmGGW5nomn4+jhpUYyIcZ9lQ7eRHOjS5YBAHhzoBpZ8TLdFQDTr82mtEMDbcxDyoXd3Q825/7oKFI0cdfUJihoEm8yIH3FnKPMws5G373mjtY7gFatLuGowURlj1zJCIWOsDDwfUlipsV6BjLDdnVq8yRviIx6PAljMx+ArVkkYymaZ8Z6YVx1MjkT+j3BlEil9a/D6GF1cyT0f4VPMWvouqKGuX/pNc40FWTg84kwiN+DrigfqK1wLaDBtSR80MGQWiu0dFbIVNL7TUKzUceneUD2HYJCGAkSlvg2tQLBJv/SRT55VoaNrM3CQ0nx0qWc2chzFSdC8jrzes4wegEMHDJFVwjrVLIz5slL7dsP2+S1vr/YRvgGI1MnspJjxoyFrHQsalzGFemtoZlImtvR5czmWg= 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)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2024 04:36:18.0118 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6ce4d949-1216-4f0d-0785-08dd20afd88c 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: SA2PEPF00001506.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7890 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: Harry Wentland 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 Reviewed-by: Louis Chauvet Signed-off-by: Alex Hung Signed-off-by: Harry Wentland Cc: Arthur Grillo --- v7: - Fix checkpatch warnings and errors (Louis Chauvet) - Change SPDX-License-Identifier: GPL-2.0+ from /* */ to // - Fix checkpatch errors and warnings (new line at EOF, redundant spaces, and long lines) - Add static to const struct vkms_color_lut test_linear_lut - Add "MODULE_DESCRIPTION" (Jeff Johnson) 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 | 172 +++++++++++++++++++ drivers/gpu/drm/vkms/vkms_composer.c | 8 +- drivers/gpu/drm/vkms/vkms_composer.h | 13 ++ 7 files changed, 214 insertions(+), 2 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 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..b53beaac2703 --- /dev/null +++ b/drivers/gpu/drm/vkms/tests/vkms_color_test.c @@ -0,0 +1,172 @@ +// 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 }, +}; + +static 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) +{ + s64 lut_index; + int i; + + lut_index = get_lut_index(&test_linear_lut, test_linear_array[0].red); + KUNIT_EXPECT_EQ(test, drm_fixp2int(lut_index), 0); + + for (i = 0; i < TEST_LUT_SIZE; i++) { + lut_index = get_lut_index(&test_linear_lut, test_linear_array[i].red); + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(lut_index), 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_DESCRIPTION("Kunit test for VKMS LUT handling"); +MODULE_LICENSE("GPL"); diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index 3d6785d081f2..d15ceac6c56f 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 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 Fri Dec 20 04:33:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916200 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 4719AE7718B for ; Fri, 20 Dec 2024 04:37:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7B66710EE6B; Fri, 20 Dec 2024 04:36:59 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="0SVQnbm0"; dkim-atps=neutral Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2055.outbound.protection.outlook.com [40.107.244.55]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1271210EE5F; Fri, 20 Dec 2024 04:36:58 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DNbBhQvOsZhjJbZ/HJZyj0qgPlbk0WbSF3hywQPUz3BrwhSY/c/syglGhJy/L+84sYxYmsBeQkhlN8lreNEUmtdRki4t7DhpROY+bUwLqXJOiVI0bmzrgkMOJUyOwH2pyCuqa4cO7Q2ukvpOKzO7karv94c3Uww0kag6zKIY5UDR2JGFrxkWFaxj+kEQP128+ANsOkoi7rTA/EfxPBUP55iMUHj6vJxDDD53sU9noM0OXQZkWxAPxIbChFUmcgvvinSUtRgWy45sLUHfla+U49L7Dd+nwiA9+P77LpA/czQ3qvNfMkZVBqHMO/YuJDznZdO+i+HrBpeX4F5QrHde8w== 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=6EOHA8qaQ4nxes8pMLuBZZdq56BLbXGgOO4Hu9ubns0=; b=KsOwzrqXmzd0kNPGAkn/9ZFWi0ae8NETngK6uyFP2DLSVciVe+hHCXzCJETloazYKIeyrwf2/RWiMzJ0r0jcbC2Y90xXRpKflVeHqLy+BRuq0A7zCwyfFBIEyaKt9M4mZUJNs07ReYMgszdix3i5oNQGE861ZCmBnY8GydO5Ab4LsqJJ0zX8Jgyx4ltjh6VP8UwALQPe51dS61DmXORDEk0SSNC3JIKWQXqOZgh8tJSxmzDV/jgDsotp8OfufqUdDTp9+uu2eXyL6RVeAp7j0R19k4VBwnvD8PY5NcDlG71edSZ76QGs7l0u6wiUDxF1yBGu5BaxX/qWFN7VXDP4Zg== 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=6EOHA8qaQ4nxes8pMLuBZZdq56BLbXGgOO4Hu9ubns0=; b=0SVQnbm06KnMFSg9L2l+0MWwGNY5rTq1GBESo5YIBIaK+ZHLxYhweLhO37woypcGaUBYI8DqKTzbJxBlAfWNMCt9nf0thOFGEWZIh+OFSdMFMA6D8P1XEutSi1AdSzSlVoixY7IP/sSYl1Z3tntemRCFB+E5ZdcwBOwQ+mAvMSU= Received: from SA9PR03CA0028.namprd03.prod.outlook.com (2603:10b6:806:20::33) by DM4PR12MB7552.namprd12.prod.outlook.com (2603:10b6:8:10c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.16; Fri, 20 Dec 2024 04:36:50 +0000 Received: from SA2PEPF00001507.namprd04.prod.outlook.com (2603:10b6:806:20:cafe::f4) by SA9PR03CA0028.outlook.office365.com (2603:10b6:806:20::33) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.23 via Frontend Transport; Fri, 20 Dec 2024 04:36: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 SA2PEPF00001507.mail.protection.outlook.com (10.167.242.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:36:49 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:36:29 -0600 From: Alex Hung To: , CC: , , Subject: [V7 04/45] drm/doc/rfc: Describe why prescriptive color pipeline is needed Date: Thu, 19 Dec 2024 21:33:10 -0700 Message-ID: <20241220043410.416867-5-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001507:EE_|DM4PR12MB7552:EE_ X-MS-Office365-Filtering-Correlation-Id: e1d18464-798a-4562-a00b-08dd20afeb92 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?b0M8yeFUO9zYuHrk3aiMLgygnq0wr/m?= =?utf-8?q?q0c2QaJvLpQfCPgcq9eE/pXWO0itC7rJhMWZzEuB6JTAi42muSh49VK8cwD7K6HPu?= =?utf-8?q?5I086eCJdq5W52dg4UsH5o//i3qQAws0YsY/8kiToLxP8YYC05kNomnFWz1ilLCSj?= =?utf-8?q?dIEddYjYgPBQxx8/k/m4vcmEKOzdaMScVMHg1TZzAinp0CIDB9kQZPLg2u52rMcUm?= =?utf-8?q?+jQiNjs0xYTu6oPx5zCdf81uYLZ9fMo01vPy9loKab0593h6JNo0tMgAqOD/Ig5UN?= =?utf-8?q?UmB3dHl+7cQBYFDbZHUubmGHsIq/kN6hNzrlhF5psVNIqBLn4ZiCGfBumOjvXETe3?= =?utf-8?q?h+f6zZmStojgTx6y+8a4EIbYH3KTKYov8ihb5DQumje5S06ZMyouO6TO48mu/KqSX?= =?utf-8?q?nYdL/3el0DhHHuCS4KrSzDp4Us8vvmAQ8bT5A4Z6ZLtbPH9JUG/y64MlSK/zNwyGW?= =?utf-8?q?6Q9uOe+3Tfq9mM54LFpo+69WGpgLKuEDD5z9t6ySt3wpWFUSE/F/iQiR7xzb6hXM5?= =?utf-8?q?loKq1+VetMyFw5ZgISyDw5JdWOqcOB8OO6NBqTgdp3H3axswEz2HYGyL6V+LCZsEG?= =?utf-8?q?P85KRz8irIEq2iL/bEQdtOkYnRJ8pOlkJBwsOG+3CaCcKoclngfQerv4PIv9fS+fa?= =?utf-8?q?cMSKuVh3WKr31HZa9TaQfcdkBR1YnlAyZzJZIOI0ra0fgqirjuN3/BCzJ5TrnhMZ8?= =?utf-8?q?YSlbaoS68m3wR5NDIZdjf7Y5llBqMjOCIVvuMXxVa0CHk0rXhn+JwH989ZR8M2rHk?= =?utf-8?q?jF9dODQ1cMxQ36VVMWH6Eo6sSjWJVkjl7/DaPlsQOz5Vu0RJLuCC7prF9tI0axZv3?= =?utf-8?q?tWXmzLxpsLp3nBHo0nf4KyaG/zXtPHs8svYNI3XxjIMvZ5GAw2JzlWap15y93+nat?= =?utf-8?q?/1hvZxnxQKaPOLn4YpoTn3qbnVbdW1qJpCHexSUUbwt6ya7acbGKcagihQnbmFCTS?= =?utf-8?q?/sr9lryTMFHibGX60OjNAMGovYvaeIBwnkkjol8FUrDkE9vEeMR7feHXAS+MpDP7W?= =?utf-8?q?ynRXN1qhw2a/lRqMltz1l9QKQ0YNj0yXPNaJ1lqjFEJN30e5SNcwHYZDGpFgB5YSZ?= =?utf-8?q?7kz7n38Wbb5NjIaaFXSQwucoAwt9gpk++jFJuJmJJOtV2A81b2Odv6swpi+NAnjsb?= =?utf-8?q?nIChSsSW2XA7BI4upj0w/y3OuDma4aQXiZIEdadSpf2k08WQPApK7//K04EmWCAHL?= =?utf-8?q?e6Bne4wCAVEkbQ/yfB1sjs0aK7ZZhtZhQ210BazZvxr6IJShDi0b4D7/MbjbNF6qd?= =?utf-8?q?UCTkiXHfRq1kK7jUvwIq+345E9JO5V7QKZ1jEofQHcul5wFYB+pPIILxyaPyVRf0I?= =?utf-8?q?8NvmnFobHn/VDQsP+1TotGLDJrx1Ly3Rn60lZonfN/Ppo9jvKdLAdBhtVGXUWWszn?= =?utf-8?q?GyqReWJxtmUPfQGb6few8xuMFJJ01DNKGxZYCe8kcL2Op6P78PPLSY=3D?= 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)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2024 04:36:49.9161 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e1d18464-798a-4562-a00b-08dd20afeb92 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: SA2PEPF00001507.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7552 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: Harry Wentland Add documentation for color pipeline API. Signed-off-by: Alex Hung Signed-off-by: Harry Wentland --- v7: - Add a commit messages 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 | 378 +++++++++++++++++++++++ Documentation/gpu/rfc/index.rst | 3 + 2 files changed, 381 insertions(+) create mode 100644 Documentation/gpu/rfc/color_pipeline.rst diff --git a/Documentation/gpu/rfc/color_pipeline.rst b/Documentation/gpu/rfc/color_pipeline.rst new file mode 100644 index 000000000000..0470c4bc1148 --- /dev/null +++ b/Documentation/gpu/rfc/color_pipeline.rst @@ -0,0 +1,378 @@ +.. SPDX-License-Identifier: GPL-2.0 + +======================== +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 Fri Dec 20 04:33:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916201 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 C31F0E77188 for ; Fri, 20 Dec 2024 04:37:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A3D9610EE66; Fri, 20 Dec 2024 04:37:07 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="Zmugp9Tp"; dkim-atps=neutral Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2045.outbound.protection.outlook.com [40.107.101.45]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6602710EE63; Fri, 20 Dec 2024 04:37:06 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CR37/22j9f692ngW/wddf2qaXW74V/dMV9rg0GM5rXsUhSMpOiILkpuwB8OPXR0HL1fi9URqAVrqtKFtGmzed9TR7ta6V7vsSM0fyp6659dwzVJji7O3b6IDdH8jQ+nltd1/8mFao0mEGXW6bayLy5abRLG4yr75a2NGR0ZR+JbyGlndUOoxawqa+XEZj1+Qs3iN5d8UdbNwRXj8y+YByfLUiAXtp1Py/HN4v+kgxvn7eqNIGWrx2Up5d43xrf42hNSuhIyR+RmKS1vozkEVVjxU3NMG/4KoesPNwIEwNfJoFfOjDJqqVHt3mLTKvr1OIv1Zx56hRMJAeiGwrECDGA== 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=Q169wOOmZzAWueGecZIBmRH1/FRK4wbRHF7IkMffhLo=; b=FrXIhk3o8ApnLwII8GmWRJ1aU6HdnB2AV6E6TkcuAht/xfrW6k6TeDERwTJJUWsI4+W6T0QcZWzu/+BOcg67POgqXNffYlwqlJG6dH5u0cffdmyPgqcpce39ozXhAAglcCYIHZSDFiaRoWaf57cqH2H2GimblHulcB9JckYGSF/Izvmo2G440IYIFLI9Rx1FjeQbb1TR4RB573LdcyVNVyzd5Gg4x84ROJtCjQ8wGN51CUzdhc0b7XzQwwzSBPip6kMoKTWBv4TAbIsqpaGp5yMJGStPe+rYpnWpFx7jHq/7gUvj2YQK63w0oqh0c80Vs4oATm9jwX11+Vc2I8QHwA== 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=Q169wOOmZzAWueGecZIBmRH1/FRK4wbRHF7IkMffhLo=; b=Zmugp9Tp4dXjaVbct3rAqv5lyeu6b4jA8akJHq3IrCJVMQHPhhEGxDe5I0SLuvzKduJmnJVSKP5gEc578xmkYPy3vZog8vFxekQyx+zAR6MRyOup/8ZZwgKJ9lKJRFk/Abwz6tSElbFOJYDvIW6l7TkVG27+Ud+MfmdcLZVNyxg= Received: from SA9PR03CA0022.namprd03.prod.outlook.com (2603:10b6:806:20::27) by SA3PR12MB7806.namprd12.prod.outlook.com (2603:10b6:806:31d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.14; Fri, 20 Dec 2024 04:37:00 +0000 Received: from SA2PEPF00001507.namprd04.prod.outlook.com (2603:10b6:806:20:cafe::c0) by SA9PR03CA0022.outlook.office365.com (2603:10b6:806:20::27) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.22 via Frontend Transport; Fri, 20 Dec 2024 04:37: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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF00001507.mail.protection.outlook.com (10.167.242.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:37:00 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:36:59 -0600 From: Alex Hung To: , CC: , , Subject: [V7 05/45] drm/colorop: Introduce new drm_colorop mode object Date: Thu, 19 Dec 2024 21:33:11 -0700 Message-ID: <20241220043410.416867-6-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001507:EE_|SA3PR12MB7806:EE_ X-MS-Office365-Filtering-Correlation-Id: 9f88e124-eba8-4a3a-301e-08dd20aff1f6 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: ZwWp6DLepgHpQ6hJ5clfP29zc5SopBx4n+GptzuYC6UCBHBKOD8zmraNvcBDPALZEAV2FuTvhAJKGvpHEMTxnlLEzwVtg6it1ufyIXpl9y8i4RxycJ5dlQ7MqvG8UhGN0uB43v5KWMf5Dtv8eUXwv2+I1w/Xpy490X3XN4+Gy5+NfRHTvWdGkJyzAHULhAXR4fKR0naJWqRvg1q6GGP+CUAoU/p0sNM/HhIEsxinCHFYhWQ0HZ0ks11cMwxx/dkSCSFGTb0ghd7uH/bAjKAYjTVUhHxXxQCdBvCB97secH3/Sh9DJxFLFoku4sg6cM+tOOgpmDnIN+t5AHaqoN6DoMKwoq2UaU3ak7nfVQHQpBsT8YJDuhgES/c/CSSLq6hJG4KMZZyD7FlPGiXVFtIzB65h7hG7dqB5KkChi0XyARKu96+mX5lRaDxlg04IdRV9zU/89f4pCBjL1gCPwWLMWoAFtVt6h69grBtgc0ZHWZ+PYeiAdPJd3ckQVqrnhsX1aYgxqr5DZ8W9NeiS1zwXpibkjfHL0l7DfFk76JvLCoJBz2K912X17HgzSAqtqgBy2m/bCqsp5Fp9VlbWTJnifxWUpte/F1RqA4WQUd4e6cyBGSDBf9wzs2dPeeddNJunIh7ecaDdaGCvodTzGskq59P4UnMX37vp9EzDUV1hvhLecqjBWD3f5lIvfnFtdNEPcse/V3UmaUGhBOdut+O3ItVBR5Q6UgBaqnTlU9d46M2LfXAFRyLabC1DmnXd7rnHeCnTnGjqli8zQraNapcIcmURyruZWKhuLQwchYDNLONSs6PLQ9+WI/izE663CC8YO6YVHkh9kfeSJ/aqrFz79ahSPDfqKREHvn9Mpui8vyEey4cuFvBcCuzo2f5iUo9RAdRnAcTj7shHgA9j6lEZV2kUMnSzywJzgWqvERrZDuv4M56bfwNnTsxL997fEFU96qWn+AaAjD/H9au2JnkDZ++Gdl5IbsPu6orZ/VbQAoMCbFbrkM631R0w16YKieGvSP48lA023hoqSfYLaAYEqXB8ivFm4Tj2e1xoQ5lRU9lXUdwhxbfyy+u0+B07ZUTjlVHccFYx3JbBTSaLTip+12piZTZPKg0TwPX0VhZidrVVaOLdbsjyzwH2Su4eCp+kNC2hdDAMoV91PmgQlRKTfrMoZyE/PWArxcp7zDK5/mzEGeFEVFkdJy63LRAIvbrmXHyJMytedrBYd6hqsapqaBfPz4a8bIHHZ8cEOKHAplH2KnzihNGpMGss87pMOBuK/eWu44LlMLW9YeHw9Ks49W9C4KgC0HXeWGGT5AZqzKaLqfl3r/U5aKPchkG+qvB6y4b5rN4+JwARXnSx4yuB5CiSEAGqO4Iq5zP5bC/KFMwJ4JrPltReHqj7qFMFrNvTi8lI1H99+fFG5PnrLM7Rse15Hgmwnj6l1+THSgt90CcFkCJy7kMoimRy2CJ66hOHggcnczixNv4/45e4Oxe6Ptqq/qfoW5leMROa2rVSaYA= 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: 20 Dec 2024 04:37:00.6349 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9f88e124-eba8-4a3a-301e-08dd20aff1f6 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: SA2PEPF00001507.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7806 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: Harry Wentland 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: Alex Hung Signed-off-by: Harry Wentland --- v7: - Fix checkpatch warnings and errors - Add a tab to for_each_oldnew_colorop_in_state definition - Change unsigned index to unsigned int index - Fix a checkpatch warning - a new line after variable declaration 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 | 104 +++++++++++++++++ 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 | 166 ++++++++++++++++++++++++++++ include/drm/drm_mode_config.h | 18 +++ include/drm/drm_plane.h | 8 ++ include/uapi/drm/drm_mode.h | 1 + 12 files changed, 525 insertions(+) create mode 100644 drivers/gpu/drm/drm_colorop.c create mode 100644 include/drm/drm_colorop.h 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..d215e22c9d20 --- /dev/null +++ b/drivers/gpu/drm/drm_colorop.c @@ -0,0 +1,104 @@ +// SPDX-License-Identifier: MIT +/* + * 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..effd9302c979 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..cc3e94dcf085 --- /dev/null +++ b/include/drm/drm_colorop.h @@ -0,0 +1,166 @@ +/* SPDX-License-Identifier: MIT */ +/* + * 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 int 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 Fri Dec 20 04:33:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916202 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 1BA05E77188 for ; Fri, 20 Dec 2024 04:37:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4984B10EE65; Fri, 20 Dec 2024 04:37:19 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="NmU50ekn"; dkim-atps=neutral Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2069.outbound.protection.outlook.com [40.107.94.69]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8538A10EE60; Fri, 20 Dec 2024 04:37:17 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bjKvAs6xxkVvMBPfqGURNtzEKrmA1pi1u2ottAXOz1szukjbqShJr+NEpQNs0pt5qFRt07QwZ5wUALb+ddHkXV1BDAqGUABa7PDGVUAluJrAEE1RZ3My/Fv6BvGy9hyiIqidQWLKJZLsDS7Dkp5XUB+SJkTdLDOBN1UJPpqu+ZB2WSXzTFzVXpaAGB/yYaA34Tdpd2GwR83NwivI52RFH0ngADoaRzY4G0U2J7ZU2vR3SwJwPRgsDy+p5lMjuhRZg0YsYmlOL8gBHA0WaTKqDdoMant5hQywB2aLnyXwFGvk9CqF3TYW1jWxC77FJGRX183KgghaWxB02yZ9arlQXw== 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=WJfk1mzfhykdPpM3Yto8HWxCfeiBufNMZ3j7c7BcLKc=; b=JoiZ4Xui0gw+p4LkZFD0LxBkd70PH79Su+HZhjUe7fy+n1/k+cg9JPsbpm4E60ODNXzOvtbfd4ufl3kqTgcv6bl3grqj0yyPKW6rKPxHUXGzRZTFppLgoxr+px8s4k+lhLgHOPAoMXDrXCo/E6o0/+KTTsA2k1g+aKJwLDXOt9HI0Jfs4oPlr6MI50pfAtzrVn+McmM5qlj4kxIWaQxxLDKoa7Q3uYrWu7SW8VXVyjjDRS7gARRPGtO8b4X8cFLZutBZ1lGHM/5/i/8bj5T+VKkPO9KMOodatLvUjV0HaIt2CVC0J2U2ROugAxetUF4oUuu5VCCFEKsuAOSrMa830Q== 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=WJfk1mzfhykdPpM3Yto8HWxCfeiBufNMZ3j7c7BcLKc=; b=NmU50ekn+lXLmssqfrZ2MW6N1q2GXVmesxCVAV8DCPm0nJVp4uP2cW7CgTxF/HCC3JbqqjImFWK1NTUOjNIXWR4vbtBPRsozxTd20tUT5hLDpJG7wG81JDNKjTEr1q+eSuMejAxxs3pIfkQx8URrQKJ0UE3AC0HMhNGwFyaDVeo= Received: from SA1PR02CA0021.namprd02.prod.outlook.com (2603:10b6:806:2cf::20) by DM4PR12MB6592.namprd12.prod.outlook.com (2603:10b6:8:8a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.13; Fri, 20 Dec 2024 04:37:13 +0000 Received: from SA2PEPF00001506.namprd04.prod.outlook.com (2603:10b6:806:2cf:cafe::87) by SA1PR02CA0021.outlook.office365.com (2603:10b6:806:2cf::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.23 via Frontend Transport; Fri, 20 Dec 2024 04:37:13 +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 SA2PEPF00001506.mail.protection.outlook.com (10.167.242.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:37:13 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:37:11 -0600 From: Alex Hung To: , CC: , , Subject: [V7 06/45] drm/colorop: Add TYPE property Date: Thu, 19 Dec 2024 21:33:12 -0700 Message-ID: <20241220043410.416867-7-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001506:EE_|DM4PR12MB6592:EE_ X-MS-Office365-Filtering-Correlation-Id: e513f919-1588-4b90-5d57-08dd20aff97f 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: hfPxj5niiaCYtTm+IdKddMnB58b76AQ3imjrmhj/a4rrnFGIk4K5F1/A1I3Qh2EvXkKKIUxVqdyAoRoVtFcylpltkSphv/DFoJXAYldkDLLn+ovISQsVgptdJYyEvhwN6HlACiowco/70YmPHR8CvQFQgsYadccs+8Bxg4TtvNC3B9dWPpEJQBf+RXkO5DY6Wq5jmYLY5jXPQp1ruryS+gmV0hK/5r2qD1ViPrEgZHY00w8yeaOnRQzTRCcN8s7SkLxA/+//mzCQArLiBt7Ka7oCT7XKmZTldK95AOoduQjCcNFBcbABWezTQbVHJanfgYolgwTgW+BSvktvby+lXZR/K2s1A8cIFVUbYfyocvKM25GRaPXwyLuJjiQC+/DtsBv/alcvnlPsH9KMa4wXC59Qcc+tFvQI4VSz5DHzxkw0hvLCr6tbmHEXV3/0I2EPBPJSq5RzHg3LlzqpoisaepFW8euvbBZ5EIO+Zzn8CYLjDU1yH4aPms3Xd0niFD/fqEPGN/HVTzJdJgWwoovowCoxY8Gq4lqr7i79N+0LdpPuDW+fJdal5v48FJHpFlSnmicLfkZVtVin2HSbeZokGarW7TaF3BEuWCpSJBt0OAlCCVU6EsIr/VSlwRqjh3DYEB9hv+CUrpOo7ZajXQ7lp0OTzm0cw32JFbFRNUbG3rR7Hkm+Bfu0X/6WU6jd8mWeglBO3lx2/hB8mgEJiSekpbBd6v3oa1zevMOv8F/ndxmlRooullo5d2cUuEB94dv2mxFSaafVMmjlgV1ZvJ0HelsxqYzV0h0xzIGZiCMFlKSJ3i1a47MYJ4KbL5yr8EojsKdruSYU/1MtsclA5DyubW65qz12Swx9VFU5ivI+F3Tc17+pXs4VWE8so1N+4CodqsgnOgHaGEdol8Agve7zR9Zeqh1AcsQyc01/Lzku6hBrW3jxbscNNmS9l2okL91T5ZXc+DwZ+L4eNaTFjWkxgdMa9dRCJFJcx2ImtlJenAYUr5f2H+cDxkiLQNC9HOkhoYFEtxd/WBOGLoC4afHLXO7OdPtBk5CmyQpsoWpTSVPnP+2CEU11HybvP2L4x5ZolkUsBPHz74B2nu9ap9EsBcbOcR9WtryhUx5ps8Q4brT8sI6QyDS3d7ETqsFg4LvC+yGdgfhwckmgf8s/CyiHEA8ylOSijaxsK+1pguGwnrmDmfEYxGxP8S0CZdmRD4hiNPmbGAzoeMLohmsfUiW6FJYeMvMgqBG1ptPpqaWwWJiE0021GdP4vhPM81gRxHS/3PHdA7Lrn+Wb8em2mo3Gavzgl0HWrCyqJzgXl8doeODVIUp6y53BPXuR/AYJh+q+kyRV3SfkjZop7kK/625QhXZRZrFpUR4tB1STsCEkG7n8H25dYJy7+pNYMN54XGGLKzNgKkCerpyKjCcQEIuW0BzxWE3Gzgw18N4/wT1sUT3OAr3zQUh6Cav6s74Ry4YGr5QxzA0ByUFLdgZW65rSjrRYAF+LANqCaA+vv9sY+Ic= 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: 20 Dec 2024 04:37:13.2780 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e513f919-1588-4b90-5d57-08dd20aff97f 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: SA2PEPF00001506.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6592 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: Harry Wentland 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: Alex Hung 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(-) 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 d215e22c9d20..1459a28c7e7b 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -102,3 +102,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 cc3e94dcf085..579e72e0b6b5 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -107,6 +107,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) @@ -162,5 +177,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 Fri Dec 20 04:33:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916203 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 164EFE77188 for ; Fri, 20 Dec 2024 04:37:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8E02710EE6C; Fri, 20 Dec 2024 04:37:31 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="o4C0KTzQ"; dkim-atps=neutral Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2045.outbound.protection.outlook.com [40.107.243.45]) by gabe.freedesktop.org (Postfix) with ESMTPS id 998E110EE6C; Fri, 20 Dec 2024 04:37:29 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Zx3BAPOScBqxwa6iVP4TRe+wvlq6z6aHRx/w1SQrZYN1R+OUQXHUd/TjsQEwvrnThWeMsCP+LlpYNciahiOVWqxiaXyxD6bTyDl8y7+CDZDDejJIGr2zqCzlbZv3ASSRzJtxav8gDm6KW2suuSJKZi3kFShpDJ9/gOIlUPPsVXj4Ca1L+W9JW5UECwleBdcYuWu/ivtDq7dXn0t4G89eEElAsIW14LabHuuqrEuwS+jtxf74hyl/RTOfgkm9Rea4BDAT2NXkdZhvziROwCBLyRBEC8bq7FEBGYVITGS6/6z7/nJdXRN37MIs+3nqTKmhgGP+XVleYBFaoc96NiUO9A== 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=43wRQF/ZlXVsYorQP9ecXCepAFkYBzkmolWpiaKFJIU=; b=XWwD4UKKajEF0tsOcrpyR+0Tg5Exa0h2uKMLgeGiTvbRsSAIjjaWgrJ7GB8YompiA0jsGwvEYAB3DpWtzaHdfhwKW9Y17Pc/zjc3U2aBT0bQ3jeYQNCkHtJmHdOzTfOj8pgVvjl2S5VMyf9fAHLfqEIL5DbQGdxhXUlbtP9szJ4U+bLosVapUrJaAAOO/zaIzLxZpCeXsgVJPg6z9UmcCJGEe/SiTiPuaaHVDXyF138HJeY6SIfF+0VF4NBU73nysS+M3ZpIZ40hniUJ/3vo26l9lRUG/gdobWD7A6sHdOVz+7qlEMYtTaFXKeurI/riba4fX1iNN850CQ9Z+oZeYA== 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=43wRQF/ZlXVsYorQP9ecXCepAFkYBzkmolWpiaKFJIU=; b=o4C0KTzQ41Gz91Q7sYKJWmh4QX+2Vx2KaMRYDusbAvIee9KXbElJ0ZYJO1Fgjn6poScEyx/S7bPCxDkRckTSgHcdJwy9FDC4TpqDbnXYLVQnpaEl6BvDfw6q/zzxC/p1+RES2rCURcgNGRMR8nunm1FFbM6D12yoqnrJnEIqYko= Received: from SA9PR13CA0146.namprd13.prod.outlook.com (2603:10b6:806:27::31) by IA1PR12MB6065.namprd12.prod.outlook.com (2603:10b6:208:3ef::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.13; Fri, 20 Dec 2024 04:37:26 +0000 Received: from SA2PEPF0000150A.namprd04.prod.outlook.com (2603:10b6:806:27:cafe::8d) by SA9PR13CA0146.outlook.office365.com (2603:10b6:806:27::31) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8293.9 via Frontend Transport; Fri, 20 Dec 2024 04:37:26 +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 SA2PEPF0000150A.mail.protection.outlook.com (10.167.242.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:37:25 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:37:24 -0600 From: Alex Hung To: , CC: , , Subject: [V7 07/45] drm/colorop: Add 1D Curve subtype Date: Thu, 19 Dec 2024 21:33:13 -0700 Message-ID: <20241220043410.416867-8-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF0000150A:EE_|IA1PR12MB6065:EE_ X-MS-Office365-Filtering-Correlation-Id: 966f9385-f0f9-4575-ef56-08dd20b00108 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: VpyFVbPm7VmnJU0FSfZi4cGrPVgQp5OPxSRmmPHojVKuziMOVagsut82lfhXgImHUAsUNxWm7FEUkP8bxRi46V4dDrk3z/OdQ1KHiq9mGmtDu9ylzlpxBpraTBKCkAeOqVSTUpR34yQBnVDbnyogQsdd2ByS7UOfkkpIfLVpmwMWtLN2JmYDw03nekITkQzu3CYLyVHeCaPSMAMsgoVI7307wTwUxnyKfCf2Yka+I4WwsdBG11fYOm+AX/V065fM1KX3hEnedKP73uc9FrUfN6Akjc0h9AR5c5cfxYMqSlAjHT9wHrxBZpD+kJF0ZRzdzVclY4XLRprTEBGXm5FqYlu3ts6ZVSU6qivQwkk5YxNFgzoN9zI85p6zTB0yRfLIB5OTxUkbYg5KJWj0m7XJwDAtSrSfgWWIldCYxMIn4sdrdklHoNOd6CFxAR+kekpiFMkGyDXe+UuNZbx8zMABDKVyL3zRrkFPXyjE4a1Gg0eWhFFJjWOislMdJCCuSTE4FK6WOxSBjcsqol/9/HlFXjOlt+b1CteYx3likCHlcf10QMJ811OCEDmENNekxqApGPV313SN82u9j0/NJr9Z17YaW+N/WHE7RHZvZNBD1cf6Lp01R0rPWDOQ4ZDY+lEbA+8Z5k3q6M4g/g0waIvW6u09CdXosoqx8tSFNqtx3dJ2uU2WdQnOa6CDH4iALjD0P33+7PoTsQy2bnSPd7JsDTYHCxjh6WBsKTklCwjH7mUG/bplBja7ugE86HhOQ0oyKzhDMzV+E6wB2WARP0esfkZEmOK+ehCFsTAX4Gtjx6DXYB00l33zsRcXlqJzDCiwiq4lsdCTMVXuwOiAiaoHIz7iiE413DM08obE717U3s4KtYNkT/2yB0daYniX4Z+GkCGXTux/nG47eC7xfSeFTY1VN8nr/NpWjzV6B7pYxAurOlVh3mD8GYBRrwO/m0uLdvcnIQnuQbqGFe8sij5L/Yltgv7FZBu7V7k/SFpT7d7GN/ktKTVM1IwZUe4zAC4AmXKNhl7fsgZC7gjxFs8Rd0RGnNuQoAAUN0EH4BAm4sW83b1fdR5YCcQm3V96ymuBpP95/Zd2H4SECJE1lPLx5hHDfYspmMQqklQPqvYkX1GieYGCEci5+FT6MAv6o0TR8fkfStzCZraAO9M8R4GeBSn32AF3s6sSX+/+9oz9sV4rBbnRIRZ2VNa1S6N/5YZ/PPpbZKLXpPUiB2EQL3RI9QMzrhEvmpFn6BVRjy53H27NJPPJcbIEz7qEeVwm1crSZ4aYD59IIDRNHOVilY/tITr+y2ZY8VGA61TfVkcd6rbG7TX7zvPmI1VNbOKIcBR4focvoT0jQokWCWn7x/P+tHeOtn+mRRh4Ep08YCVRXqB+u2vapYNY2/NrHpnOQYkemhC4/XZBhffwDUAKQ19pAko2sda3Wfbo+li2aEMkNSriWbAQh92NuSbDNhoD/tDp74eFE/7AOtxqfs0b3iAurx19p9LGk04y07C9/FoOYCA= 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)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2024 04:37:25.9236 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 966f9385-f0f9-4575-ef56-08dd20b00108 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: SA2PEPF0000150A.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6065 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: Harry Wentland Add a new drm_colorop with DRM_COLOROP_1D_CURVE with two subtypes: DRM_COLOROP_1D_CURVE_SRGB_EOTF and DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF. Signed-off-by: Harry Wentland Co-developed-by: Alex Hung Signed-off-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(-) 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 1459a28c7e7b..a42de0aa48e1 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -31,6 +31,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) { @@ -70,7 +187,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; + } } /** @@ -114,3 +240,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 579e72e0b6b5..cd5a754e5d10 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -31,6 +31,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 */ @@ -46,6 +79,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; }; @@ -122,6 +162,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) @@ -146,6 +194,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); @@ -186,4 +237,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 Fri Dec 20 04:33:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916204 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 F3DC3E7718B for ; Fri, 20 Dec 2024 04:37:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0EAB410EE73; Fri, 20 Dec 2024 04:37:43 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="f156kTZe"; dkim-atps=neutral Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2068.outbound.protection.outlook.com [40.107.220.68]) by gabe.freedesktop.org (Postfix) with ESMTPS id 80B8710EE70; Fri, 20 Dec 2024 04:37:41 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ToNTdUoLvJDJfqhozYDh9krz3rKnV5GTPj0iMefYOvsUWuXhTeiSz27VoxDCAbnBNp9zdChmgWoMaigpNQqbCIgZTejjWrnskv2ULrApEtgZmPjSXh9GWNUhLANFpoOLip+uPMve3y+IRlLcGURFoGQ6BybYfxgbjPeDrQiSOUUOZQs3DkxdaZY1nvcd9HCcmyomuZ3hSRYpyFDDtix993bN1JOM6DeH9n1fp1Q3jcUI82zVoOTgLLJOj+WjwJlzBMH90z1FOXCwdtgMJuYnn1rgyJCHBYFAoNwqFxht4S1mgE+ksEBYOdsdijOLSCbmvuVtWzeFBloMrNT/ErTfjQ== 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=NTlyZLU3JTT0zOSWqu4zO4IwXBi2qBFlRsK6dAuzRLE=; b=eNY3pFURFRPF33luLFSFyfyBL4DcLzvCzmA3b1C1eFa4o1ezkt29wjRRrQSQA3CrIi4bPbY9F1z/VdpJ1wUh0jYnSXjlieKOb4+ldHZd8o0f8k/P7PDGLj6vRWQDI/Ex2oBe/Sdj42ewH7jNuFu14KmzCQYcjV7Ie5vvPFGd9uKKfDQ15liSRm6EtJiPM+/PAtc6PQrF6G/LD4jom2S6L4ew1DLybbOpTMBaqg3xINMIRReywuXBB3bwMGzTm3rqSko8nxkFppkpupy9XbRRnDqdzN9RUhIxwNgH2I4n/UupbHWfWV94Xggp/UgeTco1Wy6MFntW/QKPewifZEuonQ== 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=NTlyZLU3JTT0zOSWqu4zO4IwXBi2qBFlRsK6dAuzRLE=; b=f156kTZe9zOiiA9xQty7iyGLWfoysR+ax1Hp/Bq+stSWrIlNkFLMhk5ij5tXA2SZ/m0csNX+IrzycyVna6PNPti71FhESuFtNud+k3ZFODLUUCKH50YoLPuQMP/WZHcWsRblzcMmcTBvR6cO2AoItne9Mybv6zqdD9sQJ+HZ4Yg= Received: from SN6PR08CA0023.namprd08.prod.outlook.com (2603:10b6:805:66::36) by PH8PR12MB7279.namprd12.prod.outlook.com (2603:10b6:510:221::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.14; Fri, 20 Dec 2024 04:37:38 +0000 Received: from SA2PEPF00001509.namprd04.prod.outlook.com (2603:10b6:805:66:cafe::65) by SN6PR08CA0023.outlook.office365.com (2603:10b6:805:66::36) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.23 via Frontend Transport; Fri, 20 Dec 2024 04:37:38 +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 SA2PEPF00001509.mail.protection.outlook.com (10.167.242.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:37:38 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:37:37 -0600 From: Alex Hung To: , CC: , , Subject: [V7 08/45] Documentation/gpu: document drm_colorop Date: Thu, 19 Dec 2024 21:33:14 -0700 Message-ID: <20241220043410.416867-9-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001509:EE_|PH8PR12MB7279:EE_ X-MS-Office365-Filtering-Correlation-Id: 0aecc49b-32f1-472c-ff1f-08dd20b00889 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: S94RBBM+bXvb7dzLDb3kyUIDc4tPk0BG8wiR/zei+sYgINf/bzKLOYQ1DqhPrZ+caolvRzRcVwMnb7zsKN+X4lqYAsYPVQyis/CiuxEJaIe6SHxAWv5WxaFY0grjMMlnw2IDn0J3Rr5GwLjeJwIfj1vkSYvU9IvIYQYiXXAixrJvAkHGkVRMzI99hLLK++vLe3ciUm/qw3Q71Q0/J3qTdcDWcmyeKlfuSgv47ZVF7e75ZvSIKnEjsLANBP61GkHNLYTonUNDsWwk0xnCF1y1oVnQfqb2YLexidyAnArtMXx5Ucf3stocsOY5SARWbnCiwbNb1uhyX+g8asRu/BDwbCjUp76OuYMy2sLEKnPR/Vtpz1OG9UGWAIkoff5LiNP8v9HswdVigh5fJe5k5Y+HHsL3suhQZxb/GWgqX8IqRE7zr9o7YIFRJlU9sV6snTTEu1Q6el4ppVxgfBeufqNzP3zrPPWusIf052pS2Xax2Op8n1btG1pW6EZENUAP1tRIe9iiJ14w9AdMj9yqnHfxc9lGEAnrHr4eATNnFUgegtz+6an3GT8aGXm4MZvRljzadNNx+cH2KlEuO5AD1MG73QV1c9KDJDYwrkZTbDDS+otZJIsJI8y1FAeFiASaeU/4CoPY/GnFY+5aCXz6VJS4lL4dQol6LUlQKZ1cKJAsVWY1RwQPmoTqWk8Rx9UNUosqu27AiwG9ghDRpnnLlxfn9HdyMoB8EhfulXAnFpjvFLDsw4yPj/ivZ+y3qEJW9qD8s9zn1n+YvbeBr+mm2wVHKBosTqFu9r9P4TQY3BEBubIuE59S8KCRPxC+WMI7dePSfdwy2vkAIcbKpg4u72C1mN/FI9TSFDIx9QAuHEJdPvFDEz7DWXG0it3Afdr5eSxv3o8Qc4lIJFDWDlf30UKxz8JdZqVLg3NOv2odi2KVxFoMSyzCIni935or/T5FBwMDvLFROE+3fHAsY5EtjmfTWhe7esP3OSncSTuIsHT0DHQLVB17E9QHAq9Q/upkh+lSq6OvEBkVIeC4xJDG9YxN7bfbS4tHFarA7013TRULHnipgVx5kFe9q0lpCR6JfktCyW6fGz33j7/FQoaYlAVPWm+Y0pWML26m7cpAjxmigl9dU9DuEMij8vVs7KEQjRkMQJH8+0XHGbUOsYtO+imbefR4YVYqwMJy7tPyPGxnsVqxRKuCBmwTNnI8U1vD7gSnHnzvgkvxYLFf7MNC+foaQHrZfenKtpzpjylmvoLh7aeLi8PuNNEgyarM5Jof8h4swfQLXLm03lTe7hM6/fE5fWomgZ9dr2cXpJv2Ne4zN1QQ0SbZoAQrAuYTWFy7uUWOFEVA9S1Di/jSW5DfRA+TNALUJNCauBM+MWby6Pj2cCu2SX/89Cq8b2hHufuKiFd2vZ8/ddMPvkt0eczA3aIir+I26wyt1Q1OOXeLj8m//reTML+kvg5STVpRSh8B8tn+i6zQWrWjLtS7iR2IHvyKpSFfTV0BeQFqlWSuQC6TWu0= 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: 20 Dec 2024 04:37:38.5291 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0aecc49b-32f1-472c-ff1f-08dd20b00889 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: SA2PEPF00001509.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7279 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: Harry Wentland Add kernel doc for drm_colorop objects. Signed-off-by: Alex Hung Signed-off-by: Harry Wentland --- v7: - Add a commit messages v5: - Drop TODO Documentation/gpu/drm-kms.rst | 15 +++++++++++++++ drivers/gpu/drm/drm_colorop.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) 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 a42de0aa48e1..aaaf96d729b9 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -31,6 +31,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 Fri Dec 20 04:33:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916205 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 19BA9E77188 for ; Fri, 20 Dec 2024 04:37:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 45E9B10EE77; Fri, 20 Dec 2024 04:37:57 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="D0OCuOyI"; 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 7EB1010EE75; Fri, 20 Dec 2024 04:37:55 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kweS/lyE4LtDviBY+v0U3HLrLjFWE6BP5Ysc6kmmoorqKcY81KuxVVao8Opej4/m0PpjRGzQXE124i6MTehIE04BoiOcIt4aCFuFEYUB9I2+B7OzwuR2iXDfYrHsfWvlFZjtTK20VJ8sgQRush1CGPP3xhagYy65eFmXbRjdUII98osm0gzDQpjrwx7VoqBwd1DgsHjyWkP9EPdWbaLa0DqWB2oDQ+UoRmdxitsYR/jXZsR4uzFyQPovF11P6Y0mYxtWRn49GiPg+OdF/jkBlWvWJaefeoaIyYaXz3wmDycgmOAQ3mh+AmEdLrk0/ljPMJljpjL1kgo/DN1rvR0ozg== 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=IQSskt6l4Mzcn+K/KjIlAonxwnZrSWt6TRBkLn6V06o=; b=rj5XuJKasz8g8SMnAwvWz/vce+GLePQSMmA2slmpncGRnwY29LoOFEeXcdsb0XsQjqFSC4BcH6oynrqvon2l9IG2UNAM+9X+d3+1GS7CS91NK7llaZDnNzYrdCckVVID++AnyKR3ChqDbY1aQXyfJaHIBqdvLRmlvxV0k3xNKNls9ImG6FrR6LuLJXRoTXRd0meUm3v1NNXlbJrp41cVKWpI+/pMHT35pIKZP2Apxe62xeJPtmWNPvUYkPnvWFGte9b8X78l92El/ovb1UoEhEQZok3AnyVQN2tGAx/ti1/HI8UgvHQSDBhL0AEU90r6jdUK6bl9EApJ60Hijyb/dA== 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=IQSskt6l4Mzcn+K/KjIlAonxwnZrSWt6TRBkLn6V06o=; b=D0OCuOyICCZiBnnnr3Pq//0JPTWWm+wnhvdhb4XQkGQ4l5HjoYuhCo/S4jZWxGGw2EDH12mrNwDmCKBjt2pVTt6snZufVgLuTJGExjTUX9Rq2utiJmlAkrlAyI83sd2MkGmjDbEx9sbrqjzvqNAkYsAULuN3eBCGFFwwhvoGFnQ= Received: from SA9PR11CA0010.namprd11.prod.outlook.com (2603:10b6:806:6e::15) by SA0PR12MB4349.namprd12.prod.outlook.com (2603:10b6:806:98::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.16; Fri, 20 Dec 2024 04:37:51 +0000 Received: from SA2PEPF00001505.namprd04.prod.outlook.com (2603:10b6:806:6e:cafe::10) by SA9PR11CA0010.outlook.office365.com (2603:10b6:806:6e::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.23 via Frontend Transport; Fri, 20 Dec 2024 04:37: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 SA2PEPF00001505.mail.protection.outlook.com (10.167.242.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:37:51 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:37:49 -0600 From: Alex Hung To: , CC: , , Subject: [V7 09/45] drm/colorop: Add BYPASS property Date: Thu, 19 Dec 2024 21:33:15 -0700 Message-ID: <20241220043410.416867-10-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001505:EE_|SA0PR12MB4349:EE_ X-MS-Office365-Filtering-Correlation-Id: 79002163-0975-4282-8a1f-08dd20b01075 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: lUgHnfhw2D00oyru66/RDeZv1iuTW+7qX5xr36q3aTDhUR+Savw6DQvE7Eiwpk/U4jrTYe2dEEMSUmHnmr9THeB2yxBRkSrCA2nR3WvxmeTnAv6mwwtxOn7dMnILgBdshmKC4avPtfpYE81zemK8daq/2QhTSjTgzdwqGc7ut2pmc0Sm36nlTrFZvlpoMp1i5zpr2irTy3dqaNL39CYjahyC+LBV/fUm/0ju5N1Y6q1KZeTCl72sqWAKe7zFNHbIemeAhA+KHpjtJwEW+yQVNaIXJ0a6m25LUO3J9g1UK+DGxYNh6gk/DtmdfUiyqbNdHELRxDZtWeMxrVURlF84ABYYAq57u1sAHx7x1v+AqJV957GiuyIr20NAVK/RUG2CuVFkwnSm0uGdaoeDhDsXEntsXC1Gwqno2NielO9aW75A/dCmavKtPluc35jlHEE8+eBzWudWRR8JHxO9dnIHv1k1VTKJoih9ZmCymDcAshBxHDj73voOTVCfOQVu8NzDgAygCCCjePHFloJzpoQGH5qRKMhYJAHjcv77l69o8Fg8zQ8aTH+N1Pn/BnxYYwLxeilMmq5jMUFQ/ycgiMS15/khbQbsneK7iQBeF5tDUUAB5lrfrJzSYQu/Uo0vYbNJTWoxnGXaUtT3zK8Uoo9vXOBuarHwHfKSJOeC4SR33FdDLMnXSki+NBCgqAxrLqMmZx2hzyCBFE+xi4I2nyGvfVJ8IzqtvvyCagmAhwT+Ll6PLIyZ1NSZrLT59HspP1FMk+XpGi3qpDj7lh1hfEK9LS06v/76E0jQBqMKC0Urm34vKuoXTaMceo8ctBSnDo8YNziCBZ4A79GilpoNwec37FKS0vDnwOsFZ0L4z+xHjlBcaCVOTX36+dBLtjERXwfHqFA25zbNLYBmpQ76LRfzTdkfUmqC0CIJ0o9PnLPX1TN/hInTX8MeUgOeqV1tO2i4MgcwaAQonalpf0vg/HCy9UrtIjW5P7uut17vwK/ic3Q3qCGiPd/Q/b8z0uCWUKl5DI1omoM3V8Wr8HSBNDUah1zZdzP8N0j4rlJZYbq25owNs92fzkDceYtiH6wtk9dBeCiWHLfT4gN0PvWPxMKpy/Q+a5ACKJc5p5mxL6OKZiWBz0JOmuT13ZfLymat0l9xSBDOp7DLJic6yAIvE0Kl0zw64DJfKKXpis9UsbT6c6Yjiex4u7Pl51Av9NeZhV960YB91ZQ/8ptFUbUKqByt+wTu262YdbLCy8VY0ZAVejfef3jEI7l1IfQlmZMOoEDwGrqWBWPtXO+r5/bkz6KeDSwhBMwUnqehPekLvAp3TnR9oAE9rFtbDz95lyVQBBDKpkLG/aYwDDZSxNLxDdFU2n9nTsf2g1Ao9zlVwUSdlDbaNVt7sv1D/fq+zxmLYMvq9yahLiXizgx6Hgci/remEns/kp3ehAkLSnU/oZJdEyr4DqNQSMNsfd1ZFGc+CL+M8R11ZP9pG/3I0BtwVpv9bA== 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: 20 Dec 2024 04:37:51.8012 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 79002163-0975-4282-8a1f-08dd20b01075 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: SA2PEPF00001505.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4349 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: Harry Wentland We want to be able to bypass each colorop at all times. Introduce a new BYPASS boolean property for this. Signed-off-by: Alex Hung 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(-) 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 aaaf96d729b9..01cbe90635e8 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -110,6 +110,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; } @@ -167,6 +178,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; @@ -183,6 +195,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 * @@ -221,6 +235,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 cd5a754e5d10..5ed24d60a99e 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -79,6 +79,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: * @@ -163,6 +173,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 Fri Dec 20 04:33:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916206 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 1372FE77188 for ; Fri, 20 Dec 2024 04:38:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8D9CD10EE74; Fri, 20 Dec 2024 04:38:16 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="iLikSWV8"; dkim-atps=neutral Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2075.outbound.protection.outlook.com [40.107.223.75]) by gabe.freedesktop.org (Postfix) with ESMTPS id D381910EE74; Fri, 20 Dec 2024 04:38:15 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=F5CwMBgQpG60NdfkAyZT1PG2dHxCdKPVJDmt57er856ouPk2M+pChYLBpNk2O9tRyZc6u4q7a333iz43663OdGIwEtogSaBrvACx6EpVUDOsk4olHccjlEKh2oR+1WpDdWdOEuxPy+48UUUPuXiBr5H5Dsppugrzh4Di0KIwxqpKf5urwNvAI+y64W3AO/t53ThbV8nG9nidYK0p3xNIAFRbRlktLmyv1sUmkf/8LGZVRnZXhctbVWfncKgRlxxG9bANanX6qcejwWlQcATEblTWvIPyDTcmAUnhm2lD3kwC740Eb2KMMTvMny/dspUjii9k+ZrfP31Ocnw9p8104g== 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=WhZ2cxLje/C8wfGl70LOTg90GCpyqLKr4KR+tYWElj4=; b=OLsosaZmOmmlnSDa1uChTGp/Pj0li0MSmhFCgckFRyA7FvCiDJd4deldXncy5Ab3W7ORvxnjB/HY5o3TNFfJ/ZQjj1OD0WSMlH3NTX9WGCCiykClrlHBucQHhTZ2DIBkRFQjkWxwKdvjtWScpF1ftfnFDkCCJD8Spx7c0uUel6UvDBE4rEoz0cptRW8/7bnCWkWfrJB4pRgXfeVGXMsw1b4pu2aIH9VmJuIW+peHy/InpyH2lBT/L+eaFMAq3b7QPQecoZtZbRfv9kHMbij4FlSGneodNnd1oxYqMdHTruDo++wxDhQNjZdgmniWYLZt83HVIbNkIpVBhK/tLlDkJQ== 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=WhZ2cxLje/C8wfGl70LOTg90GCpyqLKr4KR+tYWElj4=; b=iLikSWV86LSz2mML9Aa8gdT3CqL10usw0yTyu+WOvnyvpfJuPdwgvwgSnEjwtPci5V8KV3lYJIoPwhQ4udRdWfHzTGde9BvHy6dZqt2vjUMSzvG6Lul1MXs7WedYz9gSJUIb++tET1PlEB8WwdkZk+eanQKEZ6ZKt+7hLR0wPsg= Received: from SN6PR08CA0002.namprd08.prod.outlook.com (2603:10b6:805:66::15) by IA1PR12MB6484.namprd12.prod.outlook.com (2603:10b6:208:3a7::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.14; Fri, 20 Dec 2024 04:38:12 +0000 Received: from SA2PEPF00001509.namprd04.prod.outlook.com (2603:10b6:805:66:cafe::8b) by SN6PR08CA0002.outlook.office365.com (2603:10b6:805:66::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.23 via Frontend Transport; Fri, 20 Dec 2024 04:38:12 +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 SA2PEPF00001509.mail.protection.outlook.com (10.167.242.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:38:12 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:38:02 -0600 From: Alex Hung To: , CC: , , Subject: [V7 10/45] drm/colorop: Add NEXT property Date: Thu, 19 Dec 2024 21:33:16 -0700 Message-ID: <20241220043410.416867-11-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001509:EE_|IA1PR12MB6484:EE_ X-MS-Office365-Filtering-Correlation-Id: 532ec76b-2e76-43cf-4f34-08dd20b01cdc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: Nai9qPPHFvH3BKShscw8Q93m1waobmUF6HA1EjDBvinXApt+E1x25UubtrkwH2MYKxWk1PmipJ7vvkf/t3/d/c+L0Oj3AiQCnnphuktCtmBlO9m5Kfo2LfyjgJPSjmuMXLrsvhZ/e5u5W3Rh8Au2YUL1tqHXtYNODfGMXvw7I2q79aJDUxLuutYk6DFEHmX3Yb0SrNclIoOh3zHHEE7PuIcK4MKJH1c5Y4gBBJjmlkKtCvcRQwi9Kn5Imyfjgxtwiw2XuUCLEaCGlB6P5Jaz2CK9eyzjRqxm//JEXWbOg0OmLUkQKTtwKFPF3wt0Bjvp06mnCqbiGNWudKTv96yR8EMqS+/dbsaP5Kj/wO4Fy0n9M5p6Z9J+1bjqi/BHmPqi8Q2qYZdESe8TQcxeihoUQ6ZAuDxzxJPYcyHSrZuMu6nigo3FQOv8mOHazZalzCrYSBN5pNlJqjKprV6aR9rYR3dzlscVJ3peMJj16s5WfJPEEPpcvyboWM5pE58zFsH+xq4skhO8iLNiFxE/Mfwl9nUxlmdBw9HDzSnIrQnBz9XOkVg2o0+UYpwJ4KpGWfYrM7/DxOJWC5suP20kP0MeTxGyEMuF+rIdE+jwVvXb3V0pAfSIQYpZ6833mzb3MkvrwmGPWoh4VmIjjGeCy3aJTlP0X8eVKZSaMvZ7asfC4RlPePIFU2251PaH8BHHa+bMML8puUqlyktHNANJBawym6dHTSLc1rOnvS/t6VegGnTvD8vNEY1tU6jd6T0CqpG3t2KIeZbJH1pwKzvGZuBWVcJkFESdQ7inhNAGB3NtrwMAoVf/+7faxIsqBTGHqYsOI4ensVna+B/kdNzEEf5rFXpJiUSEkJYuoxxZ/n0QnqbCroKr7/73PMl/ZnWGAXRnwXlcHAvRMrSFrfM4JFBji610rOoePfAd4ecO6D7XpnEJT6VmZJiqlErCm1Pkk23y31vc+Nxf6kXyVrUl9NCGfpiqxBGSQ+Rm9v7197f67Kn1psjHiMhHXLvYpiIb9iJF7BjxLTdjXInWR8zlDiaJzktFjIOcb0izFtX61WJJ5gTPhsSMptCZR2ZNvbiGklF+perbSiRP9jOxMBxX5xC+TON9T9QeT2Ki3umKAHdGwkslPnBLLNTb4wvAsrbkvqSSELGCDIS45e/gYP9hUIjqTwhm1rxfsGxq0lpKahgFZC63ZxE2nozM6izft3dLA2DoHE9OpLzr9I5qMt13gybViuOzVFoU00XWtK5RDIs/Po1R1PY+8g8xng4PEBfqEGW9d4F6+0iG1JbfUwPqBSag2FHvGV39fA80ZdMY6pVBtIogu28ThYQgfEpeoeqTgbQsK8abN68z3NcAu+txC9VZ+VLjw46bBgmmK3//Zwqdzl0TGH3juv4c0XCCp+d2jMbrYYvP+n5rf5a7czNjSQSaaB828qui9EwnlCX+MMndaypCLK7pqH0COZelwf3+1zfMWEepFJw/5dRBqetr9v+/VSvJYZQ+x2AnkfwVaH9HzXs= 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)(82310400026)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2024 04:38:12.6074 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 532ec76b-2e76-43cf-4f34-08dd20b01cdc 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: SA2PEPF00001509.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6484 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: Harry Wentland 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: Alex Hung 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(+) diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c index 01cbe90635e8..954acd09673a 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -89,6 +89,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++; @@ -121,6 +122,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; } @@ -294,3 +305,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 5ed24d60a99e..2f0572be37bb 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -165,6 +165,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: * @@ -192,10 +200,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 @@ -268,4 +286,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 Fri Dec 20 04:33:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916207 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 43502E7718B for ; Fri, 20 Dec 2024 04:38:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 58EBB10EE7D; Fri, 20 Dec 2024 04:38:28 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="D1iiRMt/"; dkim-atps=neutral Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2061b.outbound.protection.outlook.com [IPv6:2a01:111:f403:2414::61b]) by gabe.freedesktop.org (Postfix) with ESMTPS id 748EC10EE79; Fri, 20 Dec 2024 04:38:26 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cX9MH5mHmvCYJW3xWLWZU/FoXpYGWf8Ed4j2F4dl9LWaNG8WILcMJBrxns69ftcYPJ846uYvqrrOxaejjpTGopS4PlHXKHmRbnabsLNAl1AlBPfJPd/qT+Wk0DvUuMCR+8Co1LuHVzKQMWAw5TrfrP190Cc9jefs6DYlBNSbjcGVaarDTFkNi1vr/JgnA+8LP6nonckwJfBboty/MXl1f6NnmdjJ+FhpTkpBYBxMLwMXGxzB7UJbf/sj5IKB2EqZ8husClAXGVWhhhOv5tzGqiNfulhHttikrm8tokULsMZ/DVAh3kmE8vGeMLI0/AzSO/fYW8XnnPJjvapT3KkjxQ== 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=o7Nq8bGVLWWw3BeYCxdq1Ji+TV1YSD0iD1bqUbpIbVQ=; b=hp+R9iUYnzwtwqjlIO8AzUS98dxIpwHbKoICHtWqYmd/SNsh9gz4Qaxtm2Ohg9AHLR1ni7kA7Iub00sgwVzv3AwzO3kAPvwYYpEHfPBZmuZOadRWlLCdtiXWuOqYHsOLOnqE2QzhZpsWomcHRhUvQuSbrW4V0hG9AFHrHMyLnoGTJFVqWlC9rQ8KSofZKPBiKNJ1jM8VuXkkKkji15X8bnY0oFexXpkPPRwRoRmwjt9akUN4MzViJ0F6EJJrqJx+7vcdbJZyf5Zjo4VaN2rOemhHIxtwmB8gARqI/xyR15/JmtVzeJ9rcuPsQ5Lm9Mmd/TJF++a3zLCRwc/dGsvl2w== 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=o7Nq8bGVLWWw3BeYCxdq1Ji+TV1YSD0iD1bqUbpIbVQ=; b=D1iiRMt/urHNPmmOyM8/tQjQJhWxhZwUg2LJw68SE7TW1emFHesT3mvAgywKvQui5SrKNjqLIjtqIL4Jywl3FR4UHofNaCK7A4+K+TWHKRrYFMq/vGRrWpuA1I1d6yPXqFeDzwEOrD0+UCLzA1B2HduBtnSRoXA+C+PXK8a/YO4= Received: from SA9PR11CA0005.namprd11.prod.outlook.com (2603:10b6:806:6e::10) by DM4PR12MB5916.namprd12.prod.outlook.com (2603:10b6:8:69::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.14; Fri, 20 Dec 2024 04:38:23 +0000 Received: from SA2PEPF00001505.namprd04.prod.outlook.com (2603:10b6:806:6e:cafe::66) by SA9PR11CA0005.outlook.office365.com (2603:10b6:806:6e::10) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.24 via Frontend Transport; Fri, 20 Dec 2024 04:38:23 +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 SA2PEPF00001505.mail.protection.outlook.com (10.167.242.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:38:23 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:38:22 -0600 From: Alex Hung To: , CC: , , Subject: [V7 11/45] drm/colorop: Add atomic state print for drm_colorop Date: Thu, 19 Dec 2024 21:33:17 -0700 Message-ID: <20241220043410.416867-12-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001505:EE_|DM4PR12MB5916:EE_ X-MS-Office365-Filtering-Correlation-Id: 8e1d42b0-ef98-41b3-83ee-08dd20b02370 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: BZ+ykR6E0OSOJ7HlYwTu3zh+ao1ig2Sh65KGvvVgBa+TPi07LZ1usBVMEkONW3nXH5VLYXLfaIL1uGRG09vok9ilWSP3nocN53dCrPkcZs81LIoDInuieX3ZO4XhS7H5nvYywOqUD++mG4i+XqQg64KFdT3TxgCXYGI11jo50CFGm7TAOQpq58e46+vQ/ER9CjwBqsx6DmQjiOiygO/WbJIvihOmUmTAHpBGAlTBYIRUBLSeGK1uhmM7XPZ3pz41BpGT6OyJHGwc9zCFiilT6dLrF5ldbmhsUyISGlxizZnWDxDQTA/Of8RSvarx8MxtJqfwpQg6iMMBlJp2LbIPQcb97IQahiq5WD4wsO3R1yHis3/mv0T2YEfZOZ2838N8MrvCVLPv33EDMUkxyG2kzFb3FVKBo2F1S7/SnVFF98nClghNSlJqdrHkofeCwjgTf/0zO7ftgkfROT5hfv3Ddbir9QIE563uJGX3eAECj+Gwrn6aDpgS/r4sw8siwuOe15ErpczWBwLELDSyqqAhxrfywmOoZjFmP2qbQNeLHhnPItjQQduS0kVtAY2UxDaeIFRGfs0/ay2h/vKfLsIFmFV3jyomTH9ggbCw6gZcjaryJs+EgsKl4eMKWiiGEoIm4ExnU6LFNp1mhgovj8Fh3STwp0PRJRpbc4Lg/rwnAs1CIvggzYt4oHbHGz1dHqu5Ul9Z0BbYbgaqKQkZLGfJe2tFEyDHWgDWIgE3ZAc6qCOpDtINj57YzQfU8S4mfwr/4IrSyrtmoC7omE3hdt0dnLs+QbuCOw98sW6ib50+AeX8SamaMtVIEz7eYEL/tuCdYSvYKsqUg2A9Vpm3BUn60W5zR2PG7CdV3X7xibE3NOqBRKtOUm3EqkFvAxUuPXP4wcG5yCOnOFB5IcQ2E3GtXYZmTsJ2d0NSVX78yc1Ua5mYC67JnazIrtEv8rQ3aZyS/ynC/DHSFzKd5pBv8+8Qa2mQCTiP4N15rF1I5p35hHwuVQpD8jF9D/kn04uYO3w/rPQCzTIi+Ohr8g9t7+jwROf+ODAnlX2jWGOXX4QnJ5RuwxguJSPFXNp7mm3+NH9pKEDXvpekJLGyN0yWREETVow4//eW/2qoYJ0ycLzwZeRS4msLPBgL1vURiN0V9j0NI+E4vrPFEi29hmyMZ2TCDbZxc9TmYqwJNay9QWsFMGHilrSC1I01U203emC0xKJud5pZC3c5RtuKKciBCm2GpNJZ5iSYLMeqYjYhpkw1StrBoFquDUJYPfGhM4w1RR+rEllTf55VRfXFFDeQpL+8jhPwaSne6JNP7MJsLQAlx8i/DFcJ5wE50baCIaZ3iwzvMKck5jziNSrDB4nkTbB5G5TwE33kX+JTse6nRb1r5AtcaK3NbX8G4ydW7uRQNlio21GfrDlwAvwpUDh+/OMHym/P+ZYSqjZWozNJuZnx6AWQP8rFJjhtpftqbirTw/nFhF52aTllOnoJsyUz2Wv3YA== 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)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2024 04:38:23.6450 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8e1d42b0-ef98-41b3-83ee-08dd20b02370 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: SA2PEPF00001505.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5916 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: Harry Wentland Print atomic state for drm_colorop in debugfs Signed-off-by: Alex Hung Signed-off-by: Harry Wentland --- v7: - Add a commit messages - Squash "drm/colorop: Add NEXT to colorop state print" (Simon Ser) drivers/gpu/drm/drm_atomic.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 44c5b5dd8b33..736fa6a11c08 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -777,6 +777,20 @@ 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)); + drm_printf(p, "\tnext=%d\n", colorop->next ? colorop->next->base.id : 0); +} + static void drm_atomic_plane_print_state(struct drm_printer *p, const struct drm_plane_state *state) { @@ -798,7 +812,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 +1857,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 +1867,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 Fri Dec 20 04:33:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916208 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 77176E77188 for ; Fri, 20 Dec 2024 04:38:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EFE1B10EE7E; Fri, 20 Dec 2024 04:38:41 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="BS4o/umC"; dkim-atps=neutral Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2070.outbound.protection.outlook.com [40.107.223.70]) by gabe.freedesktop.org (Postfix) with ESMTPS id CEB7210EE7E; Fri, 20 Dec 2024 04:38:40 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=t/wuI5oefmdnnHXjmvAaRno03Tu0vFbrHjCLBbuaum6kQZCaSMY7KoMkDFDC35qI54VU3s/Dy/+0jUE8yGlP0rs4zXayD6eKcB/7gNtaeiKonqw8Wlv3EDmZ4zC8oenAeVI8mSHZZ8UFQwU7B89RrGTUge3SYplpJ0cUyJ/wxYcxtMxPwoBOCesSIS1igZHy9rjBtlseYPx/MA+ORjGX+4KxlxXh9hUk5W3TXZA6w+XAO2F9JpDLkV33PwceFmlS5YPbCug9p9QJqPEK6yzI+harDsby3Txy5wPGi0xqiXhBRflN9UN+7Wy5pooC1/NgI16elVVLRjUgBxZHyTlSDw== 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=d2lqsUGQGjT7GkBuCjKv+83YJn/yzZQclgGS+jlBsZ8=; b=PBLH7DrXgdAY6/1P7joIMFHkEP6LN2tbg9JFsEqX6QewBz4ub4cGfajxyZvIYd1v/coxxO94TCiOsYAeyC7ESxVxk3WnFDhfXLpR18XLqJR4XolHqeWEd4VyfydXV3Jz+536AEjdnPZQiqLtO3DMiTIBGuILLIk/SvbNSen6vHuaY1tmf/hEzt1XHRvpVDBGCIv4Nmi4aTNk/2q22zh4tJgSWlFUSyY3/ReJfFiP6G/lNHEA/1SApOJR2ZyL6vByyHA+91P0/hTzhweKfqNO8Y3fvDzQ/ABYvX4lftyx4EYJ9QXUz6NnRkRfQ/czfOiygmW3i23XWMf8o6/11sc35Q== 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=d2lqsUGQGjT7GkBuCjKv+83YJn/yzZQclgGS+jlBsZ8=; b=BS4o/umC7pcUYyzXUPOzDRHfkNgQOONB//CqirpptUL0CSqI6qv+CmlYwFl9d9UQj+0ZC3VVVYEAu63WQHB1Ag+SOBJQG0QhAVkx+0Ro9vuDl33rx/x56rZL2CcDr+NtA18YLqkeOkuWvPoSo1//UOXfuiqCU+ZFP+n2VN/tok0= Received: from SA9PR13CA0132.namprd13.prod.outlook.com (2603:10b6:806:27::17) by MW3PR12MB4427.namprd12.prod.outlook.com (2603:10b6:303:52::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.13; Fri, 20 Dec 2024 04:38:36 +0000 Received: from SA2PEPF0000150A.namprd04.prod.outlook.com (2603:10b6:806:27:cafe::c7) by SA9PR13CA0132.outlook.office365.com (2603:10b6:806:27::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8272.12 via Frontend Transport; Fri, 20 Dec 2024 04:38: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 SA2PEPF0000150A.mail.protection.outlook.com (10.167.242.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:38:36 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:38:35 -0600 From: Alex Hung To: , CC: , , Subject: [V7 12/45] drm/plane: Add COLOR PIPELINE property Date: Thu, 19 Dec 2024 21:33:18 -0700 Message-ID: <20241220043410.416867-13-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF0000150A:EE_|MW3PR12MB4427:EE_ X-MS-Office365-Filtering-Correlation-Id: 1f50ff43-d75d-4031-1ced-08dd20b02b1f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: QLd93Q8+UeQEb9m3oJr/WVwKjIVV9MM/czLxkeYg2GAJq0RHXWPM2cDZLmblmvt/BW6SAVbgwsvRxPzAzT8n0zivkYXjMhf7z/XkV+dA0efC0wdanBCO0SfxfXHPgzfwvrgjkl+JDjXS/cJkNOgrBq6IFjscWicZtEHySbN+Fxiq/n8YCviuUHbUdVaYZuWQPG0xOZ1olbN8gnk2QN4ucPC21/Y/11N+FpkwUOosaUT2j7fOgpXdLBHD56uKPz1IMjJezff99G9ODfz/g8zkgAu//oA6rU6oqvWRshCSih3/YwCEe044So9qaFiY5FYa4B546vAK9/T3llMwKtaU7+aT2oFsr7ivjL9h8HqaFj5JqwobOR76Xxj3s0hqZGEuEXLs8k8fci+CWrIea76o6w3xIXh4CBYFq0MwRyI+IkSmDAL30U0+ELoC028M7gMIpp7Hap1Fp8qVZfvzAhgJnZpLchtCJ92hBdhfF57aOV7QFYFwfR21JNr/0CT1YT7vn3WFSES8kKVxZWLBpG/RzFP1Czqttc6Hbs/3gLQ54kD4y1WsrlBgL8SBKj98RTz1RPmnvTmccusqEqZfXdL0Gcrus1HksV4SUUtTlzHAjtmuhe983nzUv0sNtNbSriOHWih4uhqoAJZxA3q/yEqrWOmQv3p9BLUoS0jn6/ZhC/16PpZWG2TGdMQj+Gr5hz8JHyryUHR7qbtTpVsk2j6htsCvjpYdj1hSIculyKFfdIhIecuMal+yW8VowysZjoF4cjQG0lyvQH7bQmTwNeJ56lzgKhTePDRL8Fut4C18vYSFLKuDqdOHKuMh5wk9jB9pXefXUfgcGu+1WIeHJnbCFRbWk8GvhMV326/1tWEZ2dM6TyUN9XTyaKrcEzAUYt7OZ1dck9VvTBGNSADRG5LgABiObviBS9fsB7RkTfzYQ6Ji4J+cJTKY9nAAjfDeDWl+598InfOyXchzBH44bEoUuNc4ZTqVoiYeKV4J7OxohFFmvD88xFsyY3EK5y3YAA2U+r3eRHsMpmzOCJ0x6jumVLjPper73xfCfA3lg5X8pARUakIs3bLTyUCpWcPaGBWAsMLQ16G3+jJHjL0ndZGdXmBUrJfbu90tuMtCnPzCbpJmdYNDaAGTO5RHfhYZE3SBagOhyU5mM/nZijDHfFYy/T0r9md1pRoBW+0F70Kj3HbEVsEF1OTuc9vcOJnyLcW7SZ8W3gNGZ8fVorF/uguy01mZP3roS6MTmb6Sf8WCyU1KwVNiXM2gxJHPAMebvWDrc/xIQxWvf+IR0gGL6uTmJiJqaLvyeXf/1wUlNxYIArhc39EDVfY6i1We4HdEGSFyg3NFcEkWfaBr5zwNppQPesObOZamdsB2xpUCGYpSrmuyc9y1HocUO1mgAHntaRDhT7AQwwQxtHz5SDA80m+fiUxD/r5cg3M66JIb31UO5XXVxHbJtgBbONiy20LKXKA3pkq0Q5oiGBc+rB1+n6E6ynWGd85tr477fiPDpiVY5vk= 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)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2024 04:38:36.5333 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1f50ff43-d75d-4031-1ced-08dd20b02b1f 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: SA2PEPF0000150A.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4427 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: Harry Wentland 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: Alex Hung Signed-off-by: Harry Wentland --- v7: - Fix a checkpatch warning - a new line after variable declaration 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 | 43 +++++++++++++++++++ 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, 162 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 736fa6a11c08..35136987d5e8 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -1461,6 +1461,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..f2503f56fc82 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,17 @@ 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 +662,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 effd9302c979..feef16fd89e2 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 Fri Dec 20 04:33:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916209 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 C6FBDE7718B for ; Fri, 20 Dec 2024 04:38:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EAB4110EE83; Fri, 20 Dec 2024 04:38:53 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="EYVoD2kV"; dkim-atps=neutral Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on20611.outbound.protection.outlook.com [IPv6:2a01:111:f403:2407::611]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5FD1110EE81; Fri, 20 Dec 2024 04:38:52 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vBDzwV2uvvBElxHFtWjQg3FX/f5qR3mDyajGwYhYsxrMrkL23i4rTVCr3EM37FiWX2z+4cu8fmHJA0drhUWiSv9zI1R7i4OtKWFij3YDuEI/OwYpNMHPxDcGm9w0fwnlPg9DPOA3yqtFPEkZOZGqriQYZ+nlYMLfZqRJOEN50UjxI/KEAhOePbrjrka6JV39P4D+qAbh6DOJ/1y1k8yHT2Srt5126+rW0+0APi6SMUWN+U0lsONjhMFiuAoAcTmjKAKCty3R+SIVXGjaiJsYWPN1cvO3GfabRZKnWk94MWCEXjFP3V3CQYzwmIoHjRW4BKFrxZGhAGodLrujzqIZXg== 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=v8zvYcnxPCxVFJCw4Qe7YPUWHBYxRVq+nd67ibSPFUE=; b=EXTCFm7qXickzxY+6/JV8TGPj/27C+vg0tHW24OfedKOjDp1jxn3U6xVSrEweLMLI5QQiE0O5yB6Dh3RixXoXR9ZR2xCIf0MwNgPw1SEWlsuVXOMHw22+pV479nv44L/3q/IZ9V4zSUTNFFqzYt7YJhQ5aLzxaPitX3zyLEp6uckI9OhxInMZMBlJYTaUHLCRJafX4v92RwF4O7ReY7VuPJxDXEwt8JfCZ8594Xbbwk4TB5aM6108lUD+HBSNlBF7OXcnSIqSVufQ+HFDQBY8jssOEfYLz8st9gFHmOBfiK5CZR2UF3Qx0zoiZhES9mljl+z6aDaKvtSIMuwPVOS1w== 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=v8zvYcnxPCxVFJCw4Qe7YPUWHBYxRVq+nd67ibSPFUE=; b=EYVoD2kV2qD8ReKT6nUnM+YQRA0j2GzCJOHLK/U1NXU3UIpZ5U4HE7xUkPrhPONU0MpaLcSjK2yBr8lj2vfjfSsKXlU4QpOyGMO+9H4cuR20mY9EO0hnrYnVOmCCyTVXQd0AHnQ/cAh7CdIL/VO5PVuU2xfvqm8PHJOGHC571Yo= Received: from SA9PR03CA0006.namprd03.prod.outlook.com (2603:10b6:806:20::11) by SA3PR12MB7949.namprd12.prod.outlook.com (2603:10b6:806:31a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.13; Fri, 20 Dec 2024 04:38:49 +0000 Received: from SA2PEPF00001507.namprd04.prod.outlook.com (2603:10b6:806:20:cafe::e4) by SA9PR03CA0006.outlook.office365.com (2603:10b6:806:20::11) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.24 via Frontend Transport; Fri, 20 Dec 2024 04:38:49 +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 SA2PEPF00001507.mail.protection.outlook.com (10.167.242.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:38:49 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:38:47 -0600 From: Alex Hung To: , CC: , , Subject: [V7 13/45] drm/colorop: Introduce DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE Date: Thu, 19 Dec 2024 21:33:19 -0700 Message-ID: <20241220043410.416867-14-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001507:EE_|SA3PR12MB7949:EE_ X-MS-Office365-Filtering-Correlation-Id: aba98038-4f74-4fc4-dc59-08dd20b032a6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: cB1xzbkGADeR5elYa429AQv9FnVe3DEI3KkjqCH29tfgh9vVu/NAdzzoyTchQluOMv5BJK0HyZ4Y27wBVR/6wxFHrNDhtgk8UD1R7uYRpej3HEl1vaTbtF78BTuG47zTLI7Ue+hOvGt+Le/DI2xwEGYXPmWX8QQNP+uu+fhQrPg35yhZrClB4zOzRU6o1w/ZaPGXyg+GuX6waw+MN7ODIkV6QFn7RaD33RLrwvdeJP35nL6ACXHXP+HR4CKPnaWEZDLaqkmlu3XmleggQUtumCC2qQGpyQUL5UOg+H03k23hlOOYWOJzKKz+vN3wMG2FqmXiRcBZLGbL1BjnqX10UyWL/ct0p1f36ukP28f22+kJtAQiVWFMPsF8aqazZx8tXMr+X3Hmvo+FpCrVJvSenhp1AXiNAVJ5QJcnBss0GGItBcgGPtYDoKpY6eX2HD+UoUXILtPnubr50jwPwFSG2F9PvH7mJkImqpVStDs4/b3dRL9j2WXqvpGBIqBFkV4qG4xRLPb8lyUHhyiUKcNe0MPFolJO0LE6/vI2j5bkkDAjb9YPbd6EIP0w3JCl7xoMDCkVzTgmxdTP8UUwRsx5x4+EhxUakbaQFj0kSsjRtSr5pEPVmj+ZuKEpRadACES+8Q/INZLtKzT/h2RqI/I+Ha1FhNOpnhW8d5yyrBR16I6YfrWNSpETRekHF53+TujR9dDmIkYnQlzhE3Ti0w5QQ05yUimLVPMJ4ybZJC1VTrTpLnEktqeBloj5fBRaPQwhint2tu2SNckxvR2E/WaDbfcX5ftWbtsdSks/gEX+h1hU6QYoGx9jurflYugrqB8l8cT+UF7ToDmf/laccT7sA+MpNvhTC50vXkAS+OFD6TswuaxSd9nZxJhjjzkySiP4laZHj1zCuKA2dt129NaVbDvTCTbKTuGzP0YnjqloJ56GFCmzJcJd357UFCmgT8Y+evx8efsCIg+CSGEvNw7bRQ36MtQWvzcvSMkkcsMLpeKY3a5/qzDcQWDpC8clcK6Lct3g+02svLU3wGqRYIwfRJayV8gsyLW+jJRLxmlR6XjelSw4pa6X70vTJaEIjKCpBQfnoiegzrkEJN8vThl3p24IE7nCL0oxpjNfQeNbzXrvSg0xqeTpSK6QTf0kVcaWt+S1x9jFoEP1PiQcw5/4e0STf9GTI696vNAAjqucZN73bT6Bka+uJ6jOrtR8pGxB0fZOk+1l+cq0cHLeowdMQ/mqsfKn9ii5XwAC6ONwz5WkED9PwJ35730jbfnXRk5rPCo2GhAEQoGBC65aV+PY0pLiwxA3heuxs+vyNfvKkMMF9l7x+GaxMG9v1UliRTuUQ8JmKO36qZXGf8hrqe5K0jUtnWS68/+NShKQkJxQMnmy6cpbDWnOeTQRrXY0XUZwCApMBU532CeUDKjoDxgtJDN9xkhMhNKHCgwtbkw4jZIxQoHXd+F2kqYmTSXyUujvB8pa53pN288sdqx7TFy0OyFie/oxM25FylC3T1x+e78= 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)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2024 04:38:49.1670 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aba98038-4f74-4fc4-dc59-08dd20b032a6 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: SA2PEPF00001507.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7949 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: Harry Wentland 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: Alex Hung 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(-) diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index f2503f56fc82..f0c22abcc28f 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; @@ -1180,6 +1186,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; @@ -1192,7 +1204,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 Fri Dec 20 04:33:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916210 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 B4E28E7718B for ; Fri, 20 Dec 2024 04:39:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2BC4910EE87; Fri, 20 Dec 2024 04:39:13 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="nPRLHCHE"; dkim-atps=neutral Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2054.outbound.protection.outlook.com [40.107.212.54]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8940810EE85; Fri, 20 Dec 2024 04:39:11 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VHCBjgcP6aHcmJJimp4c7qHWRlIaN6o37boh7J/dtei/Ya0qxMAUeDrX0hhv0s8n8ZoT3w9QlykvHITXuWzpOEDwhIrrihKyfh0Zmn8MqEKtOMJFFDxJeEDH5DQKleo8BcTUyP4VZDz/khesb86LeWOuF7C+U9akU+9v0tWKLLONq/ElC1SkMHOzRatvMKvBKSLoh2vbhCsnfdAGxVJTrsbuBxI7NkWUobQ897jed6p78vnoP3lm+DP3eY+kIGW4VtjBG/AWQ/Ws780iXcv4zDQzDpCz0iIEMle/xJwi6Erv6kT0yAxMGobRzUEHi0eMeVPDD6gyq5REQsg2W2oJzg== 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=/aFdUrtH8Ao5NiYI2VCAdLmPmGole9F34I6BEqg9k1k=; b=lRO2pekEYSj9QWQ5F4PgV4v2Abi4ES/WA8o3D2T5mi/S6LpQ3JIukCURaRhi6QwmuF7BBbFkJOkbtjKI2krvUP1oIKm5TMliuv8kMcT18nR3yoFf+P8GUggavxtSastKhEv1CPgYYNLtMboXyPZS5a9ymOsar7wMysarYJXUOztS+u8wsOZj6+W3W9+O5Gc0oDTCniBWSjDxWK01vNMO5Xr8YOdH98JaoP1i9CPdsfbHYy6TcBV08YkdIebZYwGfa5+X6swd1XDigwBwTTgNSvZ2RxjRk2Elur9nvnYryw6Jq2B/hXpBj7drHmZc2YYGRgxS1rOMlSY019iIcnqCfg== 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=/aFdUrtH8Ao5NiYI2VCAdLmPmGole9F34I6BEqg9k1k=; b=nPRLHCHEIt4E9faZXNxa/JvtHjyQmUURnJKwTpP+wNqOOwKO6osBe0wHTiRSqrIjsTU70tYwoj5GxUHMGHdaV4/lC5Q8+snK4K/Xa/NIjXLmYyAa/r/cRcvEHvVBybZciMqW3ItXby2b/YxbgYxnxbXi1DVtecpf6GSEW/CjsYA= Received: from SN6PR08CA0019.namprd08.prod.outlook.com (2603:10b6:805:66::32) by DS7PR12MB8081.namprd12.prod.outlook.com (2603:10b6:8:e6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.13; Fri, 20 Dec 2024 04:39:04 +0000 Received: from SA2PEPF00001509.namprd04.prod.outlook.com (2603:10b6:805:66:cafe::25) by SN6PR08CA0019.outlook.office365.com (2603:10b6:805:66::32) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.26 via Frontend Transport; Fri, 20 Dec 2024 04:39:04 +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 SA2PEPF00001509.mail.protection.outlook.com (10.167.242.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:39:04 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:39:00 -0600 From: Alex Hung To: , CC: , , Subject: [V7 14/45] drm/vkms: Add enumerated 1D curve colorop Date: Thu, 19 Dec 2024 21:33:20 -0700 Message-ID: <20241220043410.416867-15-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001509:EE_|DS7PR12MB8081:EE_ X-MS-Office365-Filtering-Correlation-Id: a598a5e2-5e5a-48e6-7236-08dd20b03be4 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: QK/a2NPidPBLO13+ovS0gTZWNDCNodB0lvO0Hl/4JZAn3BX5guV+tVNkiUq5mzwGG2KZxfNr7y6Q5CM7uwEJ92OM0NjHvCBmc0viLzvf5xXUfVX3aCWgE+KmUwRPf+Je5gDLRElmKo3kWu3CVho5BsBG9oxvaKeiFYZixwHUvteoYicfBVelHKkbblmMNbiEQ8YTnCUacuGpyF+nxCtcWUa0YoQo3z7fKgh+KbpbjBXAk5ryNhzgVgaUolPP7mvEUvyVXojsB9QnDxf6FzyH4obTBoGH5vi3nwommOWTUgtCJcI9nYv1sz0IqZsuOywLUjLjAzgxHdTi1j1MFj26FjCC+ZEpV7UXi/9rtzQcOpssu1QztCivlxGgxG1ruSbKA7u18Daxv8nNP11SSJsy2iiatZQ5KDde+9NyIcpcr7A7BuMWgnEV3Rsyk2qJrjLqRds0Ylj3PhVrjdjP3TvUHdlyduPwAfJoBPmzhI8SCFz/XSg3ghBTo0/D+n9MATQYHfZruEB67myFxg4L2UYXG2Q3lxivrRXdf5VjdXjLhasPQkYTANWds9prP+U7voRQm3NWO3NErKZZZLYm9F6ZSCFTWekWRJZkJsnhJbVS+epHflA9v1jxopwEkZBEUb9IDRrifhisa+GBahORqUaeDsC6JWaVBqtskUIDFQqglowQHKLwZjMyJMhVSkxEFeTRVW4eAaH4zOoB+OfiX132WGROPkuK9V3pOSFLfd1fCNIv3d/cQwnsJYfz9OjtLqlnOllTYmp7KoxIpEow0f0wI7+iKTTtKK5s/4avZa0LvOd6Rqwwp4CT2uAcRbWG8djEnYE2CdtHJK1IbhN+XfKmnMm1XzIFNRnFGh8lENGBhqTQkUIoBs/RV0MWGUYpkEPMzxRnYNaaD9r/18OuEe+p6NV0Naw+NfVUKluNouq1bqt9J7ofj0DFtmLTofZUQQetRyHsPPeBT3cpFd+WarqdcaaVPg7EWF6cmHrJWs357b3mmSMgnmdDpJ5/xtuMwFt9yKKrrTiJoSfsIN2mSIVjQwxQZVpTsd76FLcbCxk4qpadPW+FduAGaKHftWdiVZeKWYR1tf5cpXXpQY8QIpyGpf2gg7hJQ4yhxvfoRMcsseag1bBqhHTBnO99FYt4drRLxOZjtkLXjBpPkdfkQUf0iplhQAFqAxnDUHtHhkuGgBe+FErqGKr1jQ/2tQBoosXGSdjUnk8QHyQmabjKpcZ5b2x9jJ7PqHs1+GdIwObZ0PF7cKcErBnRCfUVmMl7zXXVmR1pFlzVwN2tXAEKYu5k0MgPQraNkU84jaq4/ltyF1M26yCvhtpZio8UTc93D1LNFdIhH8E4d0xD43hCLMt/G4u8DZpoGIv5OZT3UOs1HHTJJvM+bJrxlghe/pJYNf1aG0CV2LkctugH086fzc5pc3P/akQPIIK33YTEPTDynBxx3faKrRWXzZe1L3K2OYeRWcmIY2CpYDBmFb+zV2VdHQbeA+xTdRM574wtcWRCGTQ= 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)(82310400026)(1800799024)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2024 04:39:04.6857 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a598a5e2-5e5a-48e6-7236-08dd20b03be4 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: SA2PEPF00001509.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB8081 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: Harry Wentland 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 --- v7: - Fix checkpatch warnings (Louis Chauvet) - Change kzalloc(sizeof(struct drm_colorop) ...) to kzalloc(sizeof(*ops[i]) ...) - Remove if (ops[i]) before kfree(ops[i]) - Fix styles by adding and removing spaces (new lines, tabs and so on) 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 | 82 +++ drivers/gpu/drm/vkms/vkms_composer.c | 50 ++ drivers/gpu/drm/vkms/vkms_drv.h | 3 + drivers/gpu/drm/vkms/vkms_luts.c | 801 +++++++++++++++++++++++++++ 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 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..af319cd3de23 --- /dev/null +++ b/drivers/gpu/drm/vkms/vkms_colorop.c @@ -0,0 +1,82 @@ +// 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(*ops[i]), 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(*ops[i]), 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--) + 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 */ + ret = drm_plane_create_color_pipeline_property(plane, &pipeline, 1); + if (ret) + return ret; + + return 0; +} diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index d15ceac6c56f..983654540ee5 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,52 @@ 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_WARN_ONCE("unknown 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 +251,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..c3c8f5ac81b9 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -169,4 +169,7 @@ 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..9bfcf03275ae --- /dev/null +++ b/drivers/gpu/drm/vkms/vkms_luts.c @@ -0,0 +1,801 @@ +// 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..925a4a7b84e2 --- /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_ */ 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 Fri Dec 20 04:33:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916211 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 95B7FE7718B for ; Fri, 20 Dec 2024 04:39:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0966610EE8E; Fri, 20 Dec 2024 04:39:20 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="cQI5ujrI"; dkim-atps=neutral Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2089.outbound.protection.outlook.com [40.107.92.89]) by gabe.freedesktop.org (Postfix) with ESMTPS id E2A2910EE8A; Fri, 20 Dec 2024 04:39:18 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WFpJ1d80dVZBgJhyMHAEJ6oJiEPMp384GrJyjL9rLxNkVaBWzxGvUHtDKqAfbE+yuNQiVkAt8HVoVowGTTXvlBeXR3HqOhhqnX0r9C43xyd7UfjZuJ4sadBFGxzFndRJTNtdBEClshkrsXev2OIEkDb+o/Ma9O3AeRdk8pQK78lNFa5qglM8Z3Koq+KFzmWVbB5Y9USXRuP+tea1Y5ce9rFFv5B0MHtASTPCJoBIQpFJNy3AdlfHwwE8YbfS0IR3+geGjMimujtM37ZND4zvbYioccy1rwy1c1cRlx5tauBImgwJx0WGHcMYjE99D8srlAxHxTDYJM3ghfxPlPQ8DA== 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=YfLJfG7e1juPOAlHiOW0eTf2/dDqJEEBPec3eUlHgAE=; b=F6rCK+FBDBQCX9Ck8VeWszf9wxL6KMMgZll8TN9GeUT6pOjTNtxSMnqEbsTP+vbMO1ztw7gsyOeABYfMJAjeTix3hpOLDnsH7iwvFePP0ZzSU7SbpzJqmq3fmqj/rhpdS3I2crenRYSe07m54pe41SqxBdzC9G5zqIeeLCaq0kAj5Vtt7pFvbmGTFT/IsRDVNYd9SZhmiDtLyowQFZmqe2rFqshgljk3pWjHJ7VGqt6lZL3AvVCLpm6ef3mW5Zl7td2oWjsnKEXwiVpC9mIY6ab7uzaT7lYB2O19gRdWJeCbvKKCKzMZC9uBP17oR0M5FczOkD35xcFAsBZxc5UdZw== 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=YfLJfG7e1juPOAlHiOW0eTf2/dDqJEEBPec3eUlHgAE=; b=cQI5ujrIxXc0paAOVkhFCYrJbXtrWeila6F6CQqvLfK2cpNWlkN59u4lKubwLNLc96XyXKntaUYSgo2n8vBDn7ll+fECkDhLQOCjrS5R/DPJyoVubGS82209/aCj7NkhHPpbfAXCkn6kUCrubMyu0rLQvyP364wTTIektMYPdeo= Received: from SN6PR08CA0014.namprd08.prod.outlook.com (2603:10b6:805:66::27) by IA0PR12MB8930.namprd12.prod.outlook.com (2603:10b6:208:481::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.14; Fri, 20 Dec 2024 04:39:15 +0000 Received: from SA2PEPF00001509.namprd04.prod.outlook.com (2603:10b6:805:66:cafe::58) by SN6PR08CA0014.outlook.office365.com (2603:10b6:805:66::27) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.22 via Frontend Transport; Fri, 20 Dec 2024 04:39:14 +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 SA2PEPF00001509.mail.protection.outlook.com (10.167.242.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:39:14 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:39:13 -0600 From: Alex Hung To: , CC: , , , Louis Chauvet Subject: [V7 15/45] drm/vkms: Add kunit tests for linear and sRGB LUTs Date: Thu, 19 Dec 2024 21:33:21 -0700 Message-ID: <20241220043410.416867-16-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001509:EE_|IA0PR12MB8930:EE_ X-MS-Office365-Filtering-Correlation-Id: dce7ddcd-a9e6-4cab-4091-08dd20b041e6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: tuPervfxnjm8HwuJTHEQOij0BsY3w/JSivdew7guzBmNK9S+4kxAeguJQzwHTdPnAoLOQMVsrmNKw4EmEl+wr9zTjhVIVpRcKbYB2ZJzgy/BH1wl46GwbI1fbU/biwaCCU8Cv0/gPuMSQgEckfnau4HfHJdlfqIgBGmoJAm8g0IIMIutKaTsf/3N3CEYQLCvkVD2JJLeommln5sfKmqAi0sUnd/bfVusJsdYg7LJC0OzjAsJQvi1LehMeJ4eXORsTD5r/on9dJGAQnh5XnYTERjH0mxqWQs+ZfZxOCoijmGEf/cTaE5iTk5gC7xbvLAuwwX9p9YAmCxe/32kh1Dk6umYoRDUaGaZWm6s7g4z+so8zwWimE3hIkO9hqmBss1FG2nrX6DA9N5Hw31iozALDiIxUihyLMcly9sVunOGGYgQHJcydEr9a5Dp5cZvlWDcbxUDRh5B3F3hKDx9DOtDpS0vqrj+NQm1SRpskbsVUb5d57vpKZgRsa2N6BsHDuKmQUPzKUxvosBo5HclMxARWjhZmDg93Ut26HTZUJMjAi1Qe+T7r5+l+Un+ViBQb2ZRLL4YHXQ82CrP/Z3v5eqYlvL5KspsouI4MAEaA7ACcgsRmwSrCsMRdCzn8e5Oa6fr+UhZaWep5Bkj5Eq3Hol4xZw86i6bI30dJfuMxIq42RANrUnNkygsiX+5XRlB3ntC4svFQ378PU1F/7Lsx119/r1FIOL15ArQm8WRI+bmUJB7Lpa44ayrZ9JsxRE8U4/l30iI06Oiko+9ELkos8npoKtGAoyN+mRXTq4yEbec+cZWRvOGI2g83oTKn4SxsuiICXIW06h9NCVBZjFe0Ie103szD1NW68jQiCo3AcJ7gWtWbp6uUV4OFA4BhPErk6c0ECFZg1LZm8fu74N5Uq7k3SJwftBqd3jWd9HRfxKy3BZiTIOmkUvZSVd/YqrIZCcfWO4mOKcBIMK3shjGnGPE2mtOSCwPF6LwmUwfIxa84ardC9GxHppDZE8DE3/YJFfkN7uudVE/I65leXjt67bXMuDCID1IWQU5t/SJPs5uLD46I1SJSKBFBjzXlpI1HfSdERuXXM2KdaIIfQlWsVS418zTBzP9jgYr2B6ZR2VRo/6+dpZUQZ9shE9rU+zv2hLQBRu3Co/wHQOb07dmyMLRaE6jQyr2cmiBFwB29EBNxKv8cbWXjkX0Lg94YVfPJ53ajvaISzt2lc64B9ieVz6OHR8UjJznJsS3wS4uol4O+bz61JYehDUboBez27EXWrm+hK3SUD+plBBNOB4L8RkqelUuVOMAdW+FtRrOzlW/nJ/R9iZbg8+wCVz+RIxJCR0fvrcUN0Gb5dDBUH8Do4aWHI8Fviu82gxf7vBSvGndbLF4GZCxCHAaN958zGtuFJuTrtY3m7uZpHmhqth+vDjqothOYe5S2Dv0mafFyC0URXLmDP4yH6LzsK48hGuVKoUkIJFghoVvbeMZrX/+MPsLfQOTj5XPdAoPvfKdnJFvyBU= 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)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2024 04:39:14.7638 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dce7ddcd-a9e6-4cab-4091-08dd20b041e6 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: SA2PEPF00001509.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8930 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: Harry Wentland Two tests are added to VKMS LUT handling: - linear - inv_srgb Reviewed-by: Louis Chauvet Signed-off-by: Alex Hung Signed-off-by: Harry Wentland --- v7: - Fix checkpatch warnings (Louis Chauvet) - Adde a commit messages - Fix code styles by adding and removing spaces (new lines, tabs and so on) drivers/gpu/drm/vkms/tests/vkms_color_test.c | 39 +++++++++++++++++++- drivers/gpu/drm/vkms/vkms_composer.c | 17 ++------- drivers/gpu/drm/vkms/vkms_composer.h | 13 +++++++ 3 files changed, 55 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/vkms/tests/vkms_color_test.c b/drivers/gpu/drm/vkms/tests/vkms_color_test.c index b53beaac2703..d765c5eb5d88 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 @@ static const struct vkms_color_lut test_linear_lut = { .channel_value2index_ratio = 0xf000fll }; - static void vkms_color_test_get_lut_index(struct kunit *test) { s64 lut_index; @@ -49,6 +49,19 @@ static void vkms_color_test_get_lut_index(struct kunit *test) lut_index = get_lut_index(&test_linear_lut, test_linear_array[i].red); KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(lut_index), 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) @@ -155,9 +168,33 @@ 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 983654540ee5..ee3cfe153d8f 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -113,19 +113,8 @@ 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, - enum lut_channel channel) +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); u16 *floor_lut_value, *ceil_lut_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 Fri Dec 20 04:33:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916212 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 C2826E77188 for ; Fri, 20 Dec 2024 04:39:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4078210EE8A; Fri, 20 Dec 2024 04:39:32 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="ypbJCBby"; dkim-atps=neutral Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2070.outbound.protection.outlook.com [40.107.93.70]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4813610EE8A; Fri, 20 Dec 2024 04:39:31 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZmyPPs3HwKcHY0rKGtFktwFTDGro7FNCUW1BprHzApnSPa9/6Q+/oBiW4x7f3uV3HpVkZkZxJaihHJxt7ILJ3sBGV4UfKi1rfR1aA6QtLHF17YKVojcKx6SV8c7L028ohHxXu2Uw0r8kC+mZTTXpvMYa2pDXxW0/9DF0gmlbxElo4CXCku7WrDDI7Q9s3N/WlqvkxZH+4eFkBgCvOoqQ7kLRKylSIxYYh3Vb7YunFBcxOx15al9UVWRby6ZcpK85zEQz1WKbgwBF+IxDJwdcICrHamIn8RjpVt75GAnEBju+I2W6EMPSpl4Pvdj18s0kacF09BFHNEBi9to/WX16jg== 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=4HX5qS6qftlf6gtdZnz10EirOb+ZpvnVxbr8oRssH/Q=; b=tYE6dZzcuPduHIjZ1OgGX955I8U2878bWaTnD73SsA7BpLGxcXwmaDGZNecnrbKP83FpX8b21+wiH0t08dcrthlXOrOOinOdXm3zok17fNckF85wz56ZBp8vMeeC6SPNTtwkTXnrZMKWPoD21IKBsyoSzhy0pKyrr0vMiSqWXx7ihhRfru562FpUG5yNASMbxY74uA988g36ZoWwqRWFBpUAyS0ayFZzAHW7SiRgrNBpfHfXoNYfjaizYy5l8nptMzW0ZWyvS1OJK+SJvtHSdqcjz/Ic/rk9gBbGi4tMK/bPeD9mrbolTi6jcoF1deHUMsSptiJE2HxKfdVF4+e9YA== 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=4HX5qS6qftlf6gtdZnz10EirOb+ZpvnVxbr8oRssH/Q=; b=ypbJCBby5m1pakiiOIag1Dsh8RYOJTpkfjNDAruDZ1NEu6+0m6/UauhZRSr1Cq7YY/OjQSBfRaunK7ShjXrk3DPsiau8HTunSyN28Lmr3uW5Z2Ak2m54UBcCtrBt17HV/b8LIPFZgGn9oaH9l7Z2aqRqlRfiNiS6Ir1fJKoxVwE= Received: from SN1PR12CA0052.namprd12.prod.outlook.com (2603:10b6:802:20::23) by PH0PR12MB7486.namprd12.prod.outlook.com (2603:10b6:510:1e9::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.15; Fri, 20 Dec 2024 04:39:27 +0000 Received: from SA2PEPF0000150B.namprd04.prod.outlook.com (2603:10b6:802:20:cafe::81) by SN1PR12CA0052.outlook.office365.com (2603:10b6:802:20::23) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.23 via Frontend Transport; Fri, 20 Dec 2024 04:39:27 +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 SA2PEPF0000150B.mail.protection.outlook.com (10.167.242.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:39:27 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:39:26 -0600 From: Alex Hung To: , CC: , , Subject: [V7 16/45] drm/colorop: Add 3x4 CTM type Date: Thu, 19 Dec 2024 21:33:22 -0700 Message-ID: <20241220043410.416867-17-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF0000150B:EE_|PH0PR12MB7486:EE_ X-MS-Office365-Filtering-Correlation-Id: bbad5a7c-6ca6-4476-58a1-08dd20b0497d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: hq/51fR+/oQGA/Zt2UBisRguRPZoNhaz/adAouLG00B3P8+u4fKD8b4PXXX94od6l6zfCUfSZvRBP6I9OWzraIL5GZwPOAsY3xRg21gn2LMFxNu6RPfehH7VUa7yLouoT2ZuKRy9uVuiJdttlAlzht5QTn1KXiPU33ztKsuPsaqwgHhSGlpf3h2bME3j2G43wa/Evn9ywTz4XI0B8PmFhZGiYjKSTqJ0cpJHDHP7yGOPiuqSXdzvu0wQAWifCY8WfE20BFlU/oGg/WXafuSsHgePo1kGNhfKgJZ7k1HYTLwH1HUFLKg72J8b+RnFuSAQk8+CDs1jfPeO6XMLtBwBWcd58g1mrZWzTSfSEjkNmL3D9DhpFDbQE5r3MHJNNrzQFg0IfNxmC4iJoZ6i1L3RkBDdVec5iueeyAtnRfCeUReGTHMrKxCtx19BxTTK8LMOt1I0ELeU3f7YV8evRto51LyHLfaOnRgBLv7aWonia7UlRjzsyNtR13Cotk3WqAA2y0UOLkDAfYmKFpj+50lb6AQ+lhW66qE56gHNwOYgOI7b+nDh8tPgCM9cRyOHBz5MxHe+ltqeDhGZHA78oGZQMXWsqqTZUjg6YmgRMn+cJ0miGunFdvaQ1yuz85/izgvtO0BZabhx2okFKGfWmfJLLrhZzzGzurF8YAZ/tun9KpqAgE3jV8a7Ude5q70ZN1/+3h3ewDm6ELHKDVhkSwP06SVv0kTOQP90kCbxGsM7MZah+DZhYyhyPiomLskuA63PQd5EydrMbp4XrZc/2qDTNsjaqNPbKdQuc/eEteXoAT1wKD4EhtEIWWH2zeRJQFFhQ7rcDFto7soQaqiYsNKQFeN9L9zoIU78pA2+r4bN5VEQm5egoBG+xNNgDZXtGYsdwIB7u+VyXzYUd9Yh5Ru3Oqlnma4QBouYaWDnT2xrKP65wvQW0MHWiyy5npwB4vozHslUUIxIGvq9RS5c2zDa3D8QlJX9F1NwHFejzAG1i1aInvYEKDXdUPMd4Tv7ZekRhArhvwa95oyCuZD99Nn3trjq82PdXp6r9NXjgwgzXQtNM7w+SAqt6quRB+FAZ1INCvXoxbYKZa5j8hM9QfUulb+P5DP4QIhHc5SIiD3owJtZzQeuY9Op8NzBbqA7M1DLnh+dUriL0ZTgho94bymXX7SMnEAmgsM+o4rhQzQ+JulA60aqztn9nFpFrYb+IEaqMfA5Abv2QUjhnAL6sAYVfR8/SfDcdcvz7IrwDS6gInykr7/S2A4HtPzsVf2tyQUI36wt/MmsK1nAbMXcPBRd6dG/puOCdc3UfJDUbT5Kejy0wplwWuPR4xXLNwIi2r989ltaYSawGRdgUqf1lefWmafTzwjXzy1rph/SwCS5y2mtQpwJOxFYEE3Smi0ArTMDhNHyAKuwc1TCH+SmWRKghZo9rhNl43Mk/uK4xD7PehvNqt+RUdgGV9WyNziUg8PgGmlSo1WLJJ6yvNKbZCaEyN4QSnY55arvxi2r0cHBJQ8= 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)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2024 04:39:27.4825 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bbad5a7c-6ca6-4476-58a1-08dd20b0497d 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: SA2PEPF0000150B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7486 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: Harry Wentland 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: Alex Hung 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(-) 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 f0c22abcc28f..7bc4978e5441 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -692,6 +692,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, @@ -701,6 +725,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", @@ -723,6 +750,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 954acd09673a..7d4b29c0a0cc 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -64,6 +64,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[] = { @@ -202,11 +203,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; } @@ -288,6 +329,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 2f0572be37bb..e9f5c1adc2fe 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -96,6 +96,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; }; @@ -200,6 +208,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: * @@ -236,6 +255,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 Fri Dec 20 04:33:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916213 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 7A0C5E7718A for ; Fri, 20 Dec 2024 04:39:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 08AB710EE89; Fri, 20 Dec 2024 04:39:44 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="0VNU5se5"; dkim-atps=neutral Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2063.outbound.protection.outlook.com [40.107.102.63]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6CCE710EE8D; Fri, 20 Dec 2024 04:39:43 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IRoGIyGJnuMPjofeII1ppiwViiOyDtEjQ7bH6kWzeMCqJY2c/8S5yZlAGuVMCFSCgh66a/AqF9JR+CbtCTUZDwvq3r6toL+25bwQGXghySejsL87ZGmUj4zO97VtZTmGD3FfGsNFGPVqyJ+x9yrOfyYnnmKohii7FqX1Ngf7D2en1OrGdm1jx2O37CWLRM6GI/ks9BW3PEL/zMXZlFX9z1jIYKijlwY4xLyMZZNuPQ6LpXeFPoFDCiccQkFFnKDsLyReMzzhauCL9cTMCh67NZSPIvlwS2K/p5xq31xYm6B9u/nL8AhvJeRVlQnSZBYl/15YBm10X7pkltfq/rFDuA== 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=4j73OifFfd7GCUI/ca+IZbkUCQaX8OvEau7DW8hOoUU=; b=VhSyq6lmUVhm1bHoY9kCVBfnQXEW9ZbBNQU6YP2dGGLmD6TnJtKHLKOINfSScXj0Y79dTN3iAXx2xUqaFibpY8lUoB92X/NOaXxv8AFDN36l7dxqo19RYhe7qVacb40osykQM5Hvybn+hNe2oQRuVPhJ9yeEyVgPuc6glGqILyDQkR55k7P8hgsk7RFg6GAqasNO8iVP1Y0IRLPtUZriBeEnzSztFnE7g5WV9YdzRghQCE9M6c0eUQ+F/QTbwsQCmvRp0XgWFcwPuPi0Ze3l6YxO7aNTUWf/ZZJ9KuNzaUeP4K6B6ghQQvp8mp5QV0VCNcLIAqRA0vku4rF6ovmxqw== 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=4j73OifFfd7GCUI/ca+IZbkUCQaX8OvEau7DW8hOoUU=; b=0VNU5se54X1O6xF3YsLMA5YPLRi3MT0EZ0dyzm9USR8coHqZvJmlzRrhqzbWgGzqDvVLq71mGlt7Mc/HBo76oRS9zdEzU1idjgYxGKxCvM6YNxugKFeSYA0Whj6eChsQvoSxJ367DXujMMZkT7nGIy4mjdw7oK/INkvKVuCJ2WE= Received: from SN1PR12CA0062.namprd12.prod.outlook.com (2603:10b6:802:20::33) by PH7PR12MB6811.namprd12.prod.outlook.com (2603:10b6:510:1b5::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.15; Fri, 20 Dec 2024 04:39:40 +0000 Received: from SA2PEPF00001508.namprd04.prod.outlook.com (2603:10b6:802:20:cafe::d9) by SN1PR12CA0062.outlook.office365.com (2603:10b6:802:20::33) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.25 via Frontend Transport; Fri, 20 Dec 2024 04:39: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 SA2PEPF00001508.mail.protection.outlook.com (10.167.242.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:39:40 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:39:38 -0600 From: Alex Hung To: , CC: , , , Louis Chauvet Subject: [V7 17/45] drm/vkms: Use s32 for internal color pipeline precision Date: Thu, 19 Dec 2024 21:33:23 -0700 Message-ID: <20241220043410.416867-18-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001508:EE_|PH7PR12MB6811:EE_ X-MS-Office365-Filtering-Correlation-Id: 324d55d1-8c68-4118-8d0f-08dd20b0511b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: Su2pm6Pw/osLw/MxwCf9n5pI7rybPAluNZx7w6iT11fLXzgg5v4raRtxge8d8uZbQb0iiRxRdR9GlDsbC13QDpI9uCQtrcVlJ9pxZAJsaM2/i+vC6Xj3JDvFtU20Bd3uO92lh4ecsYV+18LE+2sXaDyDKbu4Kv/DcDP4Gg5ToaJNDNwOc/wq2y8Y30i1zZ8TJBlnCnYI44o1JcwySQi2rM9yp5Fws5qKTdSUEUTfmhUz1k/Wb+l99ps5R5Ixr5kqshie/ddERBABn7+NbswrbrfTemYcG8scWFYMZR0QcCO0HKbfHZwM/3oA/IhMPVLs7ROeRaxP3BZi3AXCPxWgqfYvZisbXAECv93PdjIWk+hgjcTfQ2edEyYPFpknWZuYz993Q3dpdyWRWpC6dPdkPP8qpz272L4sOFRh4QuBTMlFiLVTESRBSRF09pnI0QzqeVs0jKYNJBatpYAEf/gUM9EJJgJuIquurw8SJdr6wyOX+/pDU+K4RGKN4ZD8+AdWXrP27sEgaeFK5fvcz4hyyqK6RMwvYk9+BHrM1Ae4I1Z/BI06HWlpI+PHalMp+g/Vgt4+AIKHKg+L8DxAWMxiU0Gq9MvcrgKxHbXJl8JxmLb3YSp3O01/nx9ezW79glQlOWijjynBlhv9EYXhFtunlirwAfNQLKMi5wLvM1KyGSu5b5Rrz7t/S49HmQOpjMFtBbGamxdPkxZj3Op2SKgWCpaznrBX7LDtg7Ky8VK5u9dtl4yAov5vYHvuJ5NRRyBcHOoPOWJ2nDQRehd519xog4AGvc3llAXR3tkoiQzuFmcDkdyIozDKcXqNhAqc3SwJCQVUbPhHcybPKuxq/3cciy6Z2NBQ14fw36NGKNB80HneJKQ+/zIJMeEdYfNslRlFKlZL/FZ/fcjPA6xt55WUItwWMiovoJO3E8logjPjabwP38kQl0VTfLOLtteXHAkqyr6a0MTTyaKQ/D9aXEaceUt3nDrq0QLVlJMBPZFJP3iD7at5RAaXGo+l1QtCx6Rz09A/N7ZTC0bs6ddNy4jSOp71MFYtQxMsfMvPquXeaB5YMBCXR7o7ik35j3630wmPiXpdnwmNkLVizqWMlfGq8c3nCL8unQmTCacc7OiG9SWCePn09hxrve1+5MOeS4l1M+u8UWJiA5GpcuQDeilT4dB6pH0enWo+QKwwKr/TJECJ97vtT5km3WRmncIMZTJmDLRb+0RAa1Rq1aFe3VIcnVljsl2/bevY4XORPfLx8yQkSqiHAli6xRiQGR0AqqPXXhNxHB1sb4hTq9KGjR+rTTgFINtC0Ue4JoxD0H2/h+tCbbabYAr1K1gZy719e9sWkv5QrMg+fTKQVqlwM+UY5NA2lbSt6hL9Qx5+RctdMkUP2ZQPfY2f4ENeVr75f3OcHAyffus77F/ejdO49dkB23Xm+GB/jamtoE1rhLXx4mzG34fSp43v/YcOcJS014LNpU5pOlYmNdwK5GsZvlynfiFfRAstMa3PsymCOEWa5wU= 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)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2024 04:39:40.2790 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 324d55d1-8c68-4118-8d0f-08dd20b0511b 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: SA2PEPF00001508.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6811 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: Harry Wentland 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. Reviewed-by: Louis Chauvet Signed-off-by: Alex Hung Signed-off-by: Harry Wentland --- v7: - Fix checkpatch warnings - Add a commit messages - Fix code styles by adding and removing spaces (new lines, tabs and so on) 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(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index ee3cfe153d8f..b009e607a310 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; @@ -186,9 +186,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; @@ -198,10 +215,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 c3c8f5ac81b9..5e24c02d5294 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 Fri Dec 20 04:33:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916214 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 BA7F6E77188 for ; Fri, 20 Dec 2024 04:39:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2DFDC10EE99; Fri, 20 Dec 2024 04:39:58 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="T6tAVkjt"; dkim-atps=neutral Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2083.outbound.protection.outlook.com [40.107.94.83]) by gabe.freedesktop.org (Postfix) with ESMTPS id 343A710EE92; Fri, 20 Dec 2024 04:39:57 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JeYaxm0GhgTORCa+nbQ+x/W/P8GrN0FhExSul4ocz6xA9Ca5s0aiwGKc24XYtlwKBtIvc1VzbvbxOh/iHw7IlwAbN1vXcFyVgEOgQ3U2lN2RcggmuICdu9z6D+RA8KDnUjLr6xAytJZBqXM9bLUvrULjnVOeh22dJwfI3Ic9HyNzbykCF+REJGyFbOTh/lcc5Rsv+tCPPDXlvA1EGLgrO39WS9paYC82aAD3eGvBtIJcW7gF9qaJwAQlLcbUQn6VX611jeL9hIb+eFmmOWWrrSiI+R2Akdw52pFODKUjnYh1hKMUR3U5upyUGgf3k1MZXbAglw1XT3ICG7SvhgIpvg== 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=DZOlLeiY4cXoI7elrlniD1wJBiQlfeceApv9mklfuzQ=; b=qdCVCCp4NVZbZcro4+3exruKMZ7iCOTeAF3u1GTXLf1rW2v4ZAWeRDk1qyryP28b+Qvpahgl3c+PAPqTPuVt+IVux04Ndozm6zwu/KsixQMK3CoPp6Tm96Rt7L/BJw1/WEu6zi5ZMZHJ/pTD9ywryP8MHA/eKeF6+dpXZbSouh0y/ZX7mgHu3z636bgIkh0dLEP4zXhDQOUbjXy63ciuqjTVemGG9Cicldy70sgLgAvfhIV7yR5IOVida0lZxQzW6bAwTLT4TXQr7N1lSRgjLz8EQ9zRNZ4H2IVsS1A79YQE3n9gtZXsWEWMk9Ss2FQ4WsBN6CfcenU4CK94K5qSNA== 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=DZOlLeiY4cXoI7elrlniD1wJBiQlfeceApv9mklfuzQ=; b=T6tAVkjtkMr07X67er8Cxosmw4Ns8wB5PQe/w4EqhdXrd2cixH0DOoiqu1MITnz5lY+tFU+AImtKhlGtIOeVnxnajdcaRb+1vJow47vicMLJydYie9BXKlRA9HwCIW4t5eA1PvmO160k/KouMxuKiKtz5BUh806yxQDoKwr5HD4= Received: from SN7P222CA0030.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:124::25) by SJ2PR12MB8928.namprd12.prod.outlook.com (2603:10b6:a03:53e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.15; Fri, 20 Dec 2024 04:39:54 +0000 Received: from SN1PEPF0002BA51.namprd03.prod.outlook.com (2603:10b6:806:124:cafe::e9) by SN7P222CA0030.outlook.office365.com (2603:10b6:806:124::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.25 via Frontend Transport; Fri, 20 Dec 2024 04:39: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 SN1PEPF0002BA51.mail.protection.outlook.com (10.167.242.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:39:53 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:39:51 -0600 From: Alex Hung To: , CC: , , Subject: [V7 18/45] drm/vkms: add 3x4 matrix in color pipeline Date: Thu, 19 Dec 2024 21:33:24 -0700 Message-ID: <20241220043410.416867-19-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA51:EE_|SJ2PR12MB8928:EE_ X-MS-Office365-Filtering-Correlation-Id: b0992a89-9d5f-464c-3a74-08dd20b058fa 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: 9k9X9J5dK4+rLFuwUaOcYoLx5A2yiC0aCAzvbTIKT7x5xXWKt780ndJsUgRZgXFTZbm5tEyHhN2GiJDex+jBgS/l5pfuBOYHcbbpl+Qua1dETl+IOPSk5bYo1uYQYhZWlAXUJMmpdpGvemjMamHqthjJi6nK/JuTBlOMJPqkiv0uPODomDBffMGzxH1R+JvYIMnwBeE4oIe5gtbej6dfB4NmpfLIs/dYBuU5OD8L/0F1MBUFyDjBCpR1+NOn0rOLi8XAosH2l1N6A8YJOF888tMAnOYMiBpbww/+XMd3x5J6f0Z44sqHOFE2McQvLySfkT+pZFnUl6X4K3glEQYD6VD/J0sNA6Yq5fTN+SgcQCDwH28rw1VxB3nngFxUgy1wHWHbC6U8UrP23NTNreYmeYEtgkvlB1tRUXDP90o2xyiT45g2b1pl+Rz6epY1Cv4wm9ReTpcR3huOFOeJJI4mQHqvq2m16G4Ej58weP8aUZjcQA0jFSgmC60caUiuPLut8CPLz3NxgTdfO8zMTMY+G85BBDsu4qN2VTJg5Q15CvIZ727VJ3qenHWpl27TnUGECj3SYXumGD7Ks+kJJ2aEZO7u0reR393p5XdTA+JhBuitUzuknFcj5igOXgetiLeO6FS9dC22KomwjFpq/qdXES5RmMW8GYZ6VxsO1Ulo1lCybxdgv4oolWM4RAPce6+7HCsdBHy0IbFJVH7z/cjnTQZyh01rwyLIBh1tHR83adLQAU6Il1FZa2aCN2pKKrTFhYUAedxNx7LUe5TuFRNrw9UD9uFO96u3AYc2qad0d/cEXA3XOeWm9KtwnhEU1SPEhslMh2QfD9hrhKRhGLeSMsn/AdNCwjUZ+L/rmtPNVcKd7+Rdo+TyDVsjKabpg4/7JfSKLVuiMsgmNLDK9o+APzUDbMExSBocH2661ZZSbwF2E+fihhdrjt1UJ/AWM2oLwhpALYt3uoofksomuzZrkRRo3Zmqt49KlIKZAZRmPMXwMeuw2L8fGjWWoZTIMzo6WhI3cZOT7sLM0U9MQ0GXkJ41eeBbYzArHXAxYU5mM/fHTMuhzG4+mJeWzys2QOEcXRY+mocX5gYlTIcEDPJb0qGwNzZotGcUQaQzpJgE9ACSt3rLY2nXAvzURDiOUwCQVNCvG53ZOeF21HM30+qCEjRZIGvMQJmupexD+9B7R/12bzXD/6Q8bCpVaDUHF+SpgFsPqGA5w64FyR/a3njZ5ProdqpNXrjVDpacAVoejMGKDsa4OsE2qXcOxu9UUvzuj+BflOv5jESKUf9JpkJ/36h7DFvIU+Nvdka/f9GwyFu2zEQBO4DVzLYC8tZY3dLmmt0b9xYYQpL2fMy1mp2eZ5Ui4HDSiTtfOqfjl92YpySJzVBL+RtTDKf0Mic5UvPAST1eupC2baaKQ/HHeb9Bx5NIdCfx52P9Ug/zR56fAYyyXOyhojaCJB9p1GacWcg1zMyGoCMlNTtrYuEBPq9/z8VgwsH3z+je2EItrweo098= 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: 20 Dec 2024 04:39:53.4824 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b0992a89-9d5f-464c-3a74-08dd20b058fa 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: SN1PEPF0002BA51.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8928 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: Harry Wentland 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: Alex Hung Signed-off-by: Harry Wentland --- v7: - Fix checkpatch warnings - Change kzalloc(sizeof(struct drm_colorop) ...) to kzalloc(sizeof(*ops[i]) ...) - Change i-1to i - 1 - Add a new line at EOF 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 | 33 +++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vkms/vkms_colorop.c b/drivers/gpu/drm/vkms/vkms_colorop.c index af319cd3de23..b407f8ae758d 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(*ops[i]), 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(*ops[i]), 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 b009e607a310..cdcaaf8cdb68 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; @@ -180,6 +209,10 @@ static void apply_colorop(struct pixel_argb_s32 *pixel, struct drm_colorop *colo 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 Fri Dec 20 04:33:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916215 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 37F73E7718B for ; Fri, 20 Dec 2024 04:40:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9C02610EE9B; Fri, 20 Dec 2024 04:40:10 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="asWE8xuV"; dkim-atps=neutral Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2072.outbound.protection.outlook.com [40.107.236.72]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0FFBD10EE96; Fri, 20 Dec 2024 04:40:09 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GkzeSsfvmIl12YE4PD5yqBHuXmzt1gz2yPh/YDR4GhWV8qEzSi37dnLr0JRnkiFLZjTB7b0cyKh9HICHAfLrwMC11RIy8WQL1w86ctrH/iX65QocBp3xt2zR+F5HDwk3R6EylvN3G6SmXrO0vMOxfVFCYGqUdfqIxdJ99gV/CCVVlrJmOwzSIxEYeqh+Xc6piUilV15heZreRXc4d/unu2NrYifhOpEjZE2MwmWR+E7kYlwZzKK3dU24JCm0Ka5icIKx8B/uEshau5Ao/M6UJGKit4AmYSTY/WE4efCC5ZqYsuR6BA2FdtjlQdcWv8djb+GHqzzeR4iZfi4SBv/0eg== 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=IfOl/b6EJRVOdMjN/1IIcgsE2LJvVOt1tJjJkwBnn1g=; b=sDxWSzjHTx+SW35t2s7T3yYKMVxXturZ0QFbIH3+qQK0p7CwYB664A6YTfdZVXLaNaCYa84HAQpQOb6QcOPCwMUbQ4ZDKxbWZZimd/ZyH5ui6phUieOo3Fu1R5E8ntSDU5UxEouNU/zODdtF93iBHz96VQZW+MaoPTdbeH7ENlvjJDoTos6kjn75FhywNk4STVQEyDAlJpT53XolsTPU646OJXoraYO9kiXl7xrao2+BGlLsUru/H5a/mWT7w1zAv+LkBuRHw2uxMWa3ClQau4HxDd4HRpZAhZKqNLjEQQ/wPA+eavPdYIpuxSkJtV1KFWVM2bJsjRP+n8GF8+/2uQ== 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=IfOl/b6EJRVOdMjN/1IIcgsE2LJvVOt1tJjJkwBnn1g=; b=asWE8xuVR+Oi2t7NHTCtYom3YFAHyv6yxs83IvQIV5BBSHbXFRCbvYbf4y5gBY4iUOA2vuNTvN9WCtNy5Iep0mFFcxO8f5xNvfJRUCthiebGOPYk/YWguyKNL1IzCgQLcuQYFgmPZYzm2flox3qQPSeZcwjdAUEbCcdKoIKwuXI= Received: from SN6PR2101CA0009.namprd21.prod.outlook.com (2603:10b6:805:106::19) by SA1PR12MB6822.namprd12.prod.outlook.com (2603:10b6:806:25d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.13; Fri, 20 Dec 2024 04:40:05 +0000 Received: from SN1PEPF0002BA4C.namprd03.prod.outlook.com (2603:10b6:805:106:cafe::67) by SN6PR2101CA0009.outlook.office365.com (2603:10b6:805:106::19) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8293.8 via Frontend Transport; Fri, 20 Dec 2024 04:40:05 +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 SN1PEPF0002BA4C.mail.protection.outlook.com (10.167.242.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:40:05 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:40:04 -0600 From: Alex Hung To: , CC: , , , Louis Chauvet Subject: [V7 19/45] drm/tests: Add a few tests around drm_fixed.h Date: Thu, 19 Dec 2024 21:33:25 -0700 Message-ID: <20241220043410.416867-20-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA4C:EE_|SA1PR12MB6822:EE_ X-MS-Office365-Filtering-Correlation-Id: 645e9874-13ad-44e5-e69f-08dd20b0602c 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: 2QS/aHAX05XpccQRANi2Ws+r8E/GEk+QL80UdAVeKJM/gyUkAiOrEgwWl5fhFIzBdjLPLheWAxZONxcnkgvzQg+pRMzU/piz0sgGZLLKoJ1sqU6yiX2WNo+vHF/eTnceACW+jXLs4Qnp7s2+Z3OFSJdv8YosBtyuY60K8DNMJbr5tGrXahSHQJaj2F5JIhiB93LYtD3na4ZCSo7BqL0q33ctFIo3HmIvoOIdhgC1cf7ItNv6DUGh1bnIOoPfY0xmThy+t6hGXNkKoMkTtKGsEyYZCSS8Y8FUQyspkcPT0+onzyhHcDLQjtU5zJj15MNUrkkEhnCXL3LcV2CmOSNgqtafE+KPArh1P6Hrbh+zuB9rWJPi5DFyuUq7ZS6j6Z+gfD0cWYuTk1hDxPzHEXVMtI+2dzdGK6n/wVjSkoTKSYFUQCsMEIAbhciexM6i+CF4iof1Fxfvrz/XXxxqSD7StTrSUrAkIp7Y1l+rTSVrxodSiVaSApNUSU7ZItEsJA+yaN2+oz31dy9N6JJqh55GbAb41oZUekMiOYUtl5V3fxOuq1+NBlfJ243hq0A2qSe1gTgAOsz5/atV77ykluYy2ZeicG4gm3mpzQ4F3ETmPRFEFvfkhgrOlaIf3d45FdFF2HdNb/VbLZOhrX2JMuz+iGRafdalFV26fKi921HHV1g77YADVJf9PkBLrcJHXiXIYvZS0o5Rc/PM+SD1XukUJVPzm84pUhYwXgtmBBVC0H0jKAW3RjQZ+VfOCNYaX5xkZFsYAqQsVqd9XIITsYfAUOyQJFkXsQgkDAw9ZuFb6yP6dI0+qDX6PB64lmJtNVbZ6kWjTRPE6A6ZK8rTntqvOB9S+uAfZ33h54UUmP0qkayAZTMEHQgV3qmQO+nYupR4adDzRq0f4Ye3qu/tF2qchKHvxplWQ2Zm8O5dkoMRmyDtZUdXFONLTjDbK4MA92azRxzHCeDkM7XJJGhBVTgt6KUmOcxidhAx/m0aSLH/dNmGwCFIFypDqxeJ7FBXF+K9XGTg+oxgmwaWrtlOGTAMBkqm0eoXwwHNm1vFNazLNZjliKgChmwqa+R6/9a/M4nT44G8IHN0sixGEnHGXZMWCML6ZUcMD546vG++Fs532sFKuJdTqQdZVARUuR9GzF6VGiyy5BM8Nn5VtEg9KEaKk26YPTGlZ3gvGpXXLnA5VUUJjF7N1YAZTPH6lqFAz9QVY2Fau46ePzN3gtLn0FeVnmIvcmLKf9uv0HnCligh4y9i1AHbmgyvqs/WcY3LoPuP3SjuRabWC6BX+/TQ6udBfKkAukswPsZ/Rm2qNDafobIlRl+qASc+XiHwwxIxnkDak+0PzuSxSToIY3dHSZNLyU0edvKy9GogYy1QXpIxhSEDLxZ9TItERy6J4zf7XB3xsoHzr7Bbqgliwz1nBFGqwRNCWIT7KtKNeGAtC+OZThuQ5I+NvA0jTOeNDokLN7dQ7g/Sx5RQcpwfjd00UNJgn6D6MLtca24NVkw/ieZZOZ4= 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: 20 Dec 2024 04:40:05.5585 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 645e9874-13ad-44e5-e69f-08dd20b0602c 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: SN1PEPF0002BA4C.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6822 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: Harry Wentland 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. Reviewed-by: Louis Chauvet Signed-off-by: Alex Hung Signed-off-by: Harry Wentland --- v7: - Fix checkpatch warnings (Louis Chauvet) v6: - add missing MODULE_DESCRIPTION (Jeff Johnson) - fix buffer overflow drivers/gpu/drm/tests/Makefile | 3 +- drivers/gpu/drm/tests/drm_fixp_test.c | 71 +++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/tests/drm_fixp_test.c 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..de91177af213 --- /dev/null +++ b/drivers/gpu/drm/tests/drm_fixp_test.c @@ -0,0 +1,71 @@ +// 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"); From patchwork Fri Dec 20 04:33:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916216 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 9D854E7718B for ; Fri, 20 Dec 2024 04:40:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1DEEB10EE9F; Fri, 20 Dec 2024 04:40:26 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="xPml1ait"; dkim-atps=neutral Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on20602.outbound.protection.outlook.com [IPv6:2a01:111:f403:2009::602]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4820310EE9D; Fri, 20 Dec 2024 04:40:24 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=V2SCrrEP+TjJ0zeMQfqAYnfWJ+Dzr/eFcGQkQVj1c/KcoJAxKHrR7v+k14A1d2qGWOHlSlE+TBy0alhUJfVMjLAVSDdTNJ97clv0y2h/tmjn0zwYpkp1Xet6u3yIR7nkGq4c9CzwWldMRCEVk0O3DgTF0yb6g2ILYgLMTwb2+YUvkckJVjJ1HIdNTcB8zsrPb8ldjo5XFNcFKcwVe0DOe+/l7XJvzD0tGfUSqpNlCXKWpRPKC2ZZdMlcjuQ9/kZOHk9XF1d3Qcjp3PkkdK/Upw1zuYa8UOWFUrGWYhfGQfexRPYhe0ZS+T95lpZdfINmkYFkWA7v9FP3ce9S9Vmq2A== 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=fl3eJlHQZFMshFgkC2xrJbonFmTj/2f/6oZmjaNTYLQ=; b=VTJeO+W44ehoT9GQfcIKOkDCCRolNDFdD5pjMFo1o26iJIZ+N+/ufz+UI4OZMZr228x2f3sbUMo7MPPQ6WvYv00fs1OUL4QSc732kOYQCaDftC6jQXTxF4XbDrp8ZUZwk8NayCcn9GNkTBWfLUaylwttcE/f0kppNr9dZElirSJ/7FKPQZPNf3DYerxl6CFYw08/j2djHGDIwUUKqR8aUhzkYui8tlBUjo9ZXh9Xg/1Fn5png+bWlbFaIpdrtpPdP998v660rLs7FpEMqWD3V9ucqR8ucu0Uh5eEtxQfdMwTr+gn5XZMAfqKuwJbj59KUjxbAjrZdLK92Dyq5GLNpA== 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=fl3eJlHQZFMshFgkC2xrJbonFmTj/2f/6oZmjaNTYLQ=; b=xPml1aithTSreOdTfNoEjTm3fVC+e7m5yGJaDsogCyD5WGK6Gb5Bs8Arr8Cz7kwV9LsZdkg4s0IzcmlyTaj5nvYQuccNHOOZuRtdEn3VoVWcwzmJ6aVlbiffZevwoM9Tnr4ihQdmxLJxawp1YF/KWjnwh+4X8FcO1PTBM3G5l/Q= Received: from SA0PR11CA0008.namprd11.prod.outlook.com (2603:10b6:806:d3::13) by DM4PR12MB7696.namprd12.prod.outlook.com (2603:10b6:8:100::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.14; Fri, 20 Dec 2024 04:40:18 +0000 Received: from SN1PEPF0002BA4F.namprd03.prod.outlook.com (2603:10b6:806:d3:cafe::c6) by SA0PR11CA0008.outlook.office365.com (2603:10b6:806:d3::13) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8272.16 via Frontend Transport; Fri, 20 Dec 2024 04:40:18 +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 SN1PEPF0002BA4F.mail.protection.outlook.com (10.167.242.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:40:18 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:40:16 -0600 From: Alex Hung To: , CC: , , , Louis Chauvet Subject: [V7 20/45] drm/vkms: Add tests for CTM handling Date: Thu, 19 Dec 2024 21:33:26 -0700 Message-ID: <20241220043410.416867-21-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA4F:EE_|DM4PR12MB7696:EE_ X-MS-Office365-Filtering-Correlation-Id: 1fd678e5-80ab-47b4-cd0f-08dd20b067cb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: YdyK7ioZv9ZTfDMOO9e2l/55tEYPq248bz/hmt4VIxwGCgB7KwrgullJkt+nwPIqFkqcegn8KnU+k7tresAlRRtjq3o2hwC8uLfwJXfAdKAlCL77ECeheZH54i977mayOqMncVTnF/40kObyx77xNNYHIxq3QNoTrtAttV5vRZk0GIWEWLSA/7CsyVPvb6WBrckHyRbyEH4WoPj4IG7H15Dj8JtygjqhJuMY75TLoqgg+4/26pcUZgY3i4f9K9Kn8zVzP/8hgZWSd5KcdlA8a75y1O0U+j6yo1f0r2XeJn0VvLjq+Zwaosn2T5ksc2uEKag1L+vf5l4jMtzSI17Mn2iq3JRYYXnm63cqhE8X16d1TQBQGo4DDxQJupAVwoeR8MsWqEpm3TrlUtooNAFLeOr7IsdHfRLDh491tz4wWR+Mj2bRTLKHUb4l1EP9R5w9dfmsNzHKkxRnDew/65AqPY0izLwhQV6+8sh00XW8L/W7kHh619QUhNFRZKn/OJPLIFiVc8isnSB6eMZ6XRBba6jSVACbYhZkM42cZGLyfEwg6XBcLoKk44NrJUjo/u0RHR/gwSHYsCNi8kzrfqxPpQDh+29Cg2ya+/hfr58oULl6G+ccipHFBKGUk9WXO9PKYSUSn6JzCzmbzlH67DlPBFvUBbmEKc3U9iKFSTRpLsw74WR0qOvn8aY4B6uZVisFf8dO4ymcjh/mMxHkIBFl8F2VjvaVUDJNhUVwj8fSCxYVW2Q9eXTx/bg5CDYDMtLtTMpp/Yv1M11B5WshJver8GnJB8C5e104OgC0jIPxvUiY6Fnr0+UIHnLX1JtEV9elEzRjC7bmTl+UmlBD6MoNOQWSwCHVZMLpRcbV8FYogCeW7X4Mc6tBg8a1273lcyyUlcWjbsigixbyHWeUB1ioc4ppfDcYGbNLBgEl+SmWSo5k8WBEafA0iCKPRpxxyAzjqHDtvdBT6mI7dwRJIr3THaEkouijpctx6rNhRaYOIygRuSsFIf1VrOOjJ2o5J5PKibSGmwiRGrLlRicSDcbFJQ1AuUMhqm8rytJCOwPVp8rj4Y2DMr6jQMDOxth/ERg7ogft9ZRkKI9QJ0yW0K3dR2iuLvD0d0+KZPtkywS4CXjnyhqHS0a6k0EgRwtgZNpA7ma8gfgA+ujEsvRvQKba9uWoxWKkd2NCiaeH1OE6OjdwnVctKqp8UbnyiYCAnsmzxPX6fhIXqVyZIefTMRlGQ/YsGDwEbJwCgbiuDQGJ3lx1zQYDWdFrIt80nYS6aEtbHyvAwDCFTCBKSBa5Yi03eF8mBSFm87xlhESbeHiRRTcPiU1Fr0PWrAeH4L7m5jXeObjIItxWu+YtJ3CVJ1xSK3ymagRY93jySBJmRD+xBx/GJpcUSFdTf+ln+yBnIgugjl4doWPefRE7YMHC0mr3MGJVQBGuYNw/cEtcr8df7+1vgVKVgyC+ckNuNIxGkzXsWm2clI/sqosxnoxLNKtfM2pXA0HKAsb220k/iKVin8E= 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)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2024 04:40:18.3283 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1fd678e5-80ab-47b4-cd0f-08dd20b067cb 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: SN1PEPF0002BA4F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7696 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: Harry Wentland 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. Reviewed-by: Louis Chauvet Signed-off-by: Alex Hung Signed-off-by: Harry Wentland --- v7: - Fix a checkpatch a long-line warning (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) drivers/gpu/drm/vkms/tests/vkms_color_test.c | 250 +++++++++++++++++++ drivers/gpu/drm/vkms/vkms_composer.c | 4 +- drivers/gpu/drm/vkms/vkms_composer.h | 1 + 3 files changed, 254 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vkms/tests/vkms_color_test.c b/drivers/gpu/drm/vkms/tests/vkms_color_test.c index d765c5eb5d88..e9bc4380fb88 100644 --- a/drivers/gpu/drm/vkms/tests/vkms_color_test.c +++ b/drivers/gpu/drm/vkms/tests/vkms_color_test.c @@ -190,11 +190,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) + +static 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. + */ +static 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 cdcaaf8cdb68..ed43282e22fb 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -159,7 +159,8 @@ 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 +188,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 Fri Dec 20 04:33:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916217 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 5A06DE77188 for ; Fri, 20 Dec 2024 04:40:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AAC2A10EE9A; Fri, 20 Dec 2024 04:40:34 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="eSjou6UL"; 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 9AFC910EE9A; Fri, 20 Dec 2024 04:40:33 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hzhKxZWQUK1B1Rynf+YCBr/NpXzlR3O0tfYh6bmCh2ZlSzpYBq6QTqUEHzH1eKEPPiDuip3ekXBxA1JYQ+KmiWfEsn9zzWoabdnfTKI9rCJ1c8jQEmBUx1Mug49tzMCiCJwKmCvm10JTsfjU1jw5+lC3R0+wdBq5a5ylPSQdX2gaEmm7R0d97agEhS9r0pXbW97XtBCAiys7YEQIncZ9Xpf08mgCUi6ylhfGBq1UuxlNiIR1wi/VDk/i0SUWpi2GHT8Pwqltacao7uE8J61ngTO3X91RGjDfkLInKBnOlq83RgWaxVOpt3Etm3vxgLdkJ3MahVsLhnL8u+/gO9D//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=o+8Buo6hcCmNOaMaNfivezW5wsMDNGEYsIfnjyl3EAw=; b=kpgVcu23REeE36hxMmDQabeLOOF5a8HQtDMNoanCftmUZHai6G5NDmcA9vdOSjdivKjujHUG9aVOuSpbnwezLwLYjysgOwzUnaLp0V1pquU/VBb6hL7lDDX/LLbjMXTdinNS5PrutKKiOB7NMoixd4KF7PtqyvMujSXWuw5S8O9gL65G/KrPR+0P/QadPJV1srHgygrG5kBttM5tDpF7M/jlGUqGq/+FOFDDsKki3DIU3EZHkm/SHI6PTyCcMt4al/Y+xm2KK564pPKWVa954YMo86zDIXbgI2npoVQcLY1WjzMLSfePto5HQfRki3Bnn7QnNLbFLzo9iKrAZG0HCA== 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=o+8Buo6hcCmNOaMaNfivezW5wsMDNGEYsIfnjyl3EAw=; b=eSjou6ULBdLYXnBkGS7MQOQo945Acx2DkpZ4JiPvIa3APZWbqGJGklg6vErhqbz5EDb6rx31PY6Nxnp2qbuICH6VOtHadZiFYiPNlrf/xCRFMVkFcLc0BA3jGSAxYzeAdI44I5Goa0U8sbDX/mEUV3EvKUNTTxWJUYSiIeo2ilo= Received: from SA0PR11CA0032.namprd11.prod.outlook.com (2603:10b6:806:d0::7) by CYYPR12MB8923.namprd12.prod.outlook.com (2603:10b6:930:bc::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.13; Fri, 20 Dec 2024 04:40:31 +0000 Received: from SN1PEPF0002BA4F.namprd03.prod.outlook.com (2603:10b6:806:d0:cafe::a3) by SA0PR11CA0032.outlook.office365.com (2603:10b6:806:d0::7) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.25 via Frontend Transport; Fri, 20 Dec 2024 04:40:31 +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 SN1PEPF0002BA4F.mail.protection.outlook.com (10.167.242.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:40:31 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:40:29 -0600 From: Alex Hung To: , CC: , , Subject: [V7 21/45] drm/colorop: pass plane_color_pipeline client cap to atomic check Date: Thu, 19 Dec 2024 21:33:27 -0700 Message-ID: <20241220043410.416867-22-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA4F:EE_|CYYPR12MB8923:EE_ X-MS-Office365-Filtering-Correlation-Id: 0af1f7c4-6b91-4192-06ef-08dd20b06f57 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: sLPX4Cc9yusnqZxNq3C9guT3M5rqBve7jUugUeLPiYWWD+QqYyY2+u6pco9Z4xyzTBqu2wyKGOLS6dJTPM3zV2RzlnoOget1cuTR7P4EscqK8eC9gKqkhOKgGkYl6rlESadtDLAbsFnP7Slo2acrOREK3qa6uOQtt+SPEw2utxMpRCukcEKvYkaHecxfxbOLnwKifs0fxoiQtYgYtl86KSe1UYFKWX6hpupcgb8XIdzrdbZfGeqVw1ZN7UNRmv6DJPlFTjx+CwXSX7M8aQDdKQPePqj6RCQ9+tM+q2hbyL2dBOEk0PWuTYqhFKh02Y2rkNf8x9U4fh35e9CwNboeRAHAUAvx3GB95cCBJ31CsBJ0+80QIbvxvDVA4vxknc3kHeDDmgRohzgZLYLIoeE9ooJTxGEcELgdNu0A/pI4EiBgguIyknekyf8dn/8h0+hhV6CGa22l/cFsTv+mdYrRI4DpJc1KISaeEzkKcDukBl+A4G4kkt73F1xn8NZUXo7m2qFj0xO7OQBhrSfgg6vJM1+GzcBRDFERTSYzzJgx71o8u3m1lyJZJTyc3NH6viQS3sOawoI+JC2IKp531uRRtb7wEAwPpvI8NoMXQZFoEe+9vIx8uvFLd4+RySbdzzJ0QG+dtC9kmdlDEaT+Oei1aCl+8lRVNfIEwZJmxCMrtlsSEYPNO/VE9Ul4rSRFulgtW+rqmKfGbyoUAa/D9scWhy+U4dwrTtxfA8KHJo2CPR5M5SC/QNF4/rknRbXaBaY+9VhshflRL4t3hsQTVus5o5cAy+8MjKTYGKkQIOl4cEO6Z+wU9ATjoQhyFA1ah8GjlBWNnOvYcmvOq2FtGuVW+irlaDaxEUSHSMfGjagCW5KwMboKrewklsT3zYXt/PvJM+eijZ1KMomyJ7+DxRDWVp6TcE0/lhr60SAwish1GBxDr8bGT2WCICGj+rHMWL0awAICfGJZyTvMZQeXqFlXzXToxACX27zq5LmmgxgZuQLxe2n+32ghQK4kj+p3WL4LS4BUIIXzTqWlDLJeG8K79UHkpQlHfSKxhZytdk7zkQlkvto5EmAz/8C/i3hNca184xEgASihBiK8/bNY9icufC6EPZZ4HltJfgh2532+xfrI+3ETCzywSX2/qN51+JmA7qubsyia3kT3SVYlOxRDCH0vSGRc265nuhfl/UoIditSMGNjUfq70emxRHNPX+uHouxfHUsoh9Jih32wFWnFgG2J2IuGbt4rgWaArMXowxtZkdDcwSnC11jhRljI2J3L0kNDZ2R/6dZLUM/AO50V1UQrxPKaceUkZQYmO8FwVrS7RbfOl0HjmnW/lm3g4nFjkWTkXTtIgmWL8psTmVj9ao/Z9vKq8H+z1OKLyGrcsWQlM9HwrIMd8x/TXfQl+P2AYsJUI9QU/BlYeTwiic7fGljL+d0NNW1ka8FDHMM8p4ZClBw33oLhlxmW7ExRL5t3fj8/ioj7PqeMUbcSsL0xaehdx3C13dud2kA81zRLrvc= 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)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2024 04:40:31.0316 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0af1f7c4-6b91-4192-06ef-08dd20b06f57 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: SN1PEPF0002BA4F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR12MB8923 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: Harry Wentland 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: Alex Hung 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(+) diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index 7bc4978e5441..a3e1fcad47ad 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -1572,6 +1572,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 feef16fd89e2..f3afc1ef3f81 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 Fri Dec 20 04:33:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916218 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 05852E7718B for ; Fri, 20 Dec 2024 04:40:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4E0DA10EEA3; Fri, 20 Dec 2024 04:40:48 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="DNwYrfYE"; dkim-atps=neutral Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2047.outbound.protection.outlook.com [40.107.101.47]) by gabe.freedesktop.org (Postfix) with ESMTPS id 36AE910EEA3; Fri, 20 Dec 2024 04:40:47 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AZF7qy8AIWL8JfYaG/kHBE1u3+UsNhdzs2Nwdml53Xc8fVu5V6DLISY/9vwEFJQutt3F10gqaHxW+gLjr0jS1rE1VkB83zjHpa6OaBk8B2ZquKtht/361qY2KHatUWchyzFDCaZhA4BSygGk6XzjYTm2PHxJQOG6LcDfQBUWvPdsp/jIjE6SKRezmcttOyOB7MRYyz9cUGbPyUWKtB03fGyCODw3zjaOBVLSzdhIWkv8R2OY8+U8ccXSwvZDraAJQ7Xy9a1uyq1+KKRxaM8X/fg8QLXMM9xGPM+2ix3wDt4mNHykW3fdms7tdqHAVOYbDbZ3W7AD6vhW3JK6ZGEd8w== 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=RqvpWbRZ++mCvFPi52xvEHhVKwj0waEPxpwqTnUWI4w=; b=R+WwS7seRGSbwPHIkF9clJigoo3Ylp9YAHVZ7b7FCmBlJQu19QVUTDOZod+GmEcXpEyW6KmgKjb77unjvmF9j/6PgC5X6wtFfbe8eLNRBxSkQ3qaB63AEbpbtu9aMMme3gKmPDbYd0Ph3xtvoXJuZzL9kDDOwNkhLpi+9rrbb4CsRwWxi6sIuOoOf+QYp9Lvpb+Cs8DJwV+fgv8Glbluswb0L4o7u+thlWruZ0yt1tUPaa5zIYkPxxHPhKyBnKfqMPtk6/Lwsn4KlOVya+B5YNAMrykxtsWNNcJi3KIw0PqmpAtuqzCAqRb9snjQ2BQZAGpXRCglAaoJEjdNjzALJA== 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=RqvpWbRZ++mCvFPi52xvEHhVKwj0waEPxpwqTnUWI4w=; b=DNwYrfYELrNrA9gNi4d5aI7XWgMaXZa0CdGIuQTrzPKiIltivH5fWz6N2FDgdgl+4MnctcAujJ1b6XgPeUvknGJxoXIorVjt4GkTtwZ9q3SsXH/0GoPHzvCdYSKIx5vlhql2aiDkdpo6Z4zUYoDHNGXqxpx1QG6bsbd3DSRi1gM= Received: from SA1P222CA0134.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:3c2::7) by IA0PR12MB7652.namprd12.prod.outlook.com (2603:10b6:208:434::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.13; Fri, 20 Dec 2024 04:40:44 +0000 Received: from SN1PEPF0002BA50.namprd03.prod.outlook.com (2603:10b6:806:3c2:cafe::4c) by SA1P222CA0134.outlook.office365.com (2603:10b6:806:3c2::7) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.24 via Frontend Transport; Fri, 20 Dec 2024 04:40: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 SN1PEPF0002BA50.mail.protection.outlook.com (10.167.242.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:40:43 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:40:42 -0600 From: Alex Hung To: , CC: , , Subject: [V7 22/45] drm/colorop: define a new macro for_each_new_colorop_in_state Date: Thu, 19 Dec 2024 21:33:28 -0700 Message-ID: <20241220043410.416867-23-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA50:EE_|IA0PR12MB7652:EE_ X-MS-Office365-Filtering-Correlation-Id: 80300962-160e-4b86-8027-08dd20b07709 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: v4zECNwG8onXmddHHMr6ycFDp50SRntQSQAE+QeZnOjVCXAszKOQV6TkOoQzeLH9WL+Gc+4t4hmWtQm/sRqvJb49T61GOmd/YVhPOoAy6U2VjmgNw/lxGJl9qgA3YfUi5SW2GDZliuWv/soSuPZobZiSUcJ0IaHcmV+ATeZQ3jnviqQPSW5VGiQclhyLYZrEzsOsOYMjoozHQ0svss8VJwnmwjohWrOk1m7IMZoWg4/MwABHpv0fhwATPWwdy9AeuG5fidVXD/HCHO1ewPXtrcc05BLcbTOUU1j0yaQhZJ0Mq1z9voMQ5vApmtl6J3yqxoGFKA29+tNiK4dCBsZtZ9nNDO6gsmhtsc7L4z/ReS1zM8KP68LK3fINQHDt2UcRLN5yhFntUaAv1gRc5HpfRNFowdfyH4m/Ui8/ZDtdPRchFgaLakNp1w+X41oHyA5LIFzugngtAYGT5TYR6HxgcGqMpGfnMVz4cyUmvWuf3aZe22hzFS8XO0ykYJvmvWVQCamjwQgoz/ZpfnE4+whXh9iBt+8DpTUPtSPkceyafFiBeCGgNnr83exYiMmROlBIikrNimSZ0C8nHPV7VA/LtdLt7COx6FhsFA2i8vK/zyBILtuw5j3sG3iSmzcGuaiJEQxc/HCBJbCgc1HzkK3ZJ5SbYfkoZbwJ3GDuGZvozrQzD81r6gkC2ByCslcT8/4Zk6BbBSUV8vUGHqmlC89b5lvTBuNH3xlWR93fX12AeIXhrMpcJn2Ym1ElC2Fj4Dc+j9FPbjbcQkbnyfChM1oM1W/OX7NUS3r7T0XVy3PcCo4XwGykLI/fUFPfy79uDe5vGDhYUnEZ9vTPKrK4Bqf4cP8BCu5A9ksVy32YuJTP0oppzihmkdT8VUISnA7rpnSrY2uEIq6MZhkdYbIgbvyxNHfQVTYv+MQKhZZuzIXcWOfB7iiX1lYkSIhk3a07qQCmHm2UeMQYgw9P/9xCwkBnwTQKho1sWyx9QQGuki/kgLizuB1mEZSeI4skx9RtVAvJVXPGOHXMKttXfrN8YLJPsBwuKi7NYiaqGtlHhWtdnKXBTt+ua0iTb8vniR0sqeISEYjIexANMMlKazVeE812/aXEOMRcwomVw8+hLPC6wxM6A4IoNGE8s9GiESileK3PPdcLIPRDQQuwq8JLWHn/NFmf7+Wze8zn3zuv11gKySxjppUG5Y/KEyMVt+I/GXnqx6ReOb3lUSBxXa9lGTBMiT3MMWsjjBpvXC8vaxo+fxsadYLunO83V/XyD1unqMrc1sc58GqISSpTiIpW+JYMZoQ9nBaRk/C35fb+1Nirm/Rq9x2jhf3xQjinycv81mU7szhJ9cogAg09kf0DYH+D4SPke/V4DNt2WfbJrwjvxd6ZEGnORPSmFROu8oAxJpgo4nIem+SGDoHwnWBqdWWD/7ExI1iUp+3IaqVrrbxtkcqBvydW/rpfm8h1RAB/ezAaR68R1bIpRdyE4AyLRq3kaPcB5jqApRwQCnh083seO1Q= 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: 20 Dec 2024 04:40:43.8985 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 80300962-160e-4b86-8027-08dd20b07709 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: SN1PEPF0002BA50.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7652 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" 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 f3afc1ef3f81..c926f1924edc 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 Fri Dec 20 04:33:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916219 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 CCA27E7718A for ; Fri, 20 Dec 2024 04:41:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B732610EEA9; Fri, 20 Dec 2024 04:41:00 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="pCU7M6jI"; dkim-atps=neutral Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2085.outbound.protection.outlook.com [40.107.236.85]) by gabe.freedesktop.org (Postfix) with ESMTPS id 52B8F10EEA9; Fri, 20 Dec 2024 04:40:59 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ec3GnQZFsmLk8uSNmw9t9UtgqIs6fSmUQXeZ+gohFpRih0iqctTt0JIsQWy1OUkHiYDt4ttiGVfkLs/CptI+akKyNOT5rvVMMDtn/6iskJqYhLB1botP+g63nV6WVVLuISn0h02QJi2pne9/mJ6vyiQIgYQbZ8HHAxGqATZxL7pzOWhOzj5xR+APcUtVf5joZzxV5pA6q2n/DhPQ537bPuDcq3KUJQ5z/YEDFv6Cw24161gsNTygrRLOJv4Q9kdbVlYC83Qcriri9JirnnkTdAWL1CKkYs922RoXElVr8RyXkhuzxwR/tvD7+AAd+iHLAGKO17bQZhPHqwAp6/DdKg== 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=qbwyPzcbQ/xK9Y5lfWawd054/2yDpk6adw8N9heLF7I=; b=Jlhr5gLiKJimmriVrGWa5J1TNl3XKuAtzQDI/Mvh0R2/SKVP0yuSn9RB6b/hff1t8Rh62dPqGuFEFCHjBI355wRBaQIQWsLezdrnXhXTttdnaBbkUxDyVn3FMpyEDfiELY2v3MhjRY+6OVTGCTb7+aPRLsazo6g8Khx4toOs8d9AAdw/v6KOaHgemF0/XDFOnTu+ftstztaq9XG8LgW0jU2znWh9hCBnvntifLqKphS4X+SfDmOIieQ/4Idbg3gbczDY2Eqk9mM+EQfyYF/R2qYK9Z30iyEI25UsaujakW11hZuYChHV1sRrTB/mqOZUUruIGyn+Bc3VLLQygt4IAA== 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=qbwyPzcbQ/xK9Y5lfWawd054/2yDpk6adw8N9heLF7I=; b=pCU7M6jIDqMZxOvZgYIFZBi5Gdv/J8VfxerlfpuzLzpqLtkcH9Tk8ke5qeb85r4Vp715QJqRKsHj10EN4B1xHNn4E5jzqk+BkB7uSSU5IOLSEVbI3NMuJTPPUs9uTK77lTNAB/IGZbDFqvwJx0+ePpTyDT4joQuaYuw24roRW5M= Received: from SN6PR2101CA0027.namprd21.prod.outlook.com (2603:10b6:805:106::37) by DS7PR12MB5744.namprd12.prod.outlook.com (2603:10b6:8:73::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.14; Fri, 20 Dec 2024 04:40:56 +0000 Received: from SN1PEPF0002BA4C.namprd03.prod.outlook.com (2603:10b6:805:106:cafe::86) by SN6PR2101CA0027.outlook.office365.com (2603:10b6:805:106::37) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8293.8 via Frontend Transport; Fri, 20 Dec 2024 04:40: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 SN1PEPF0002BA4C.mail.protection.outlook.com (10.167.242.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:40:56 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:40:54 -0600 From: Alex Hung To: , CC: , , Subject: [V7 23/45] drm/amd/display: Ignore deprecated props when plane_color_pipeline set Date: Thu, 19 Dec 2024 21:33:29 -0700 Message-ID: <20241220043410.416867-24-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA4C:EE_|DS7PR12MB5744:EE_ X-MS-Office365-Filtering-Correlation-Id: f54e0b27-49b3-448b-60af-08dd20b07e76 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: +7qMndtGuDHh2xZ80YT0BaAHm3dl1D0j2Z7BrxCaNbwaPXRJhjiH96kfRo8js2sG7aNVTJ1/XOODpnUcc+R8gEkzBcqpRrH1VXTNRCu6/nuE0q9w6B5iqLmtqs44xdZeWsE/XNvQZpIMDKrW040RKFID5ZQYC+Je34QzfarsFNT0OS9lJixpB8FO8U7iTff6etN1Lcb/EvpbK/XEpnpCjJrEsLsdzjBvpYE5Xsz+tvHq89dSbgncDslxOt0r0UEzCxL7gL0ycYm9atgcqSD7wJYqpmJrwoFvEfsldA7QfGzIpw3YhYAPtSaIKg6hnlOrfi6jHKvQkFCGg/TihmiEGQKmwoPXNOxmfomi2IjwmKE88jlsuX458AZmDQwrx386Iq4waAMFqzzjjk6UF+qDoSg3LopzoMQ73HdgcQFIPjUz1B2lSBegxwRVhPd71NRskiJ8EaS5YDJe5g58tJ5zbN9dNf6hN83xHubCKPCunFsKdNhoLPf1ZaRwUo3cUYHOQo39GMPb4dWTYpBcbjSG/IFjXxRbrJn+3Fpz2OLJkdrOevvrrO7QSCcMEOSgPgprckTNTT19wo/+kfmfklawEePTrFOCeO5/f7oeFZkw4mASdDQb3OMK3ZGWeg3+82Y0C3I8SPOZ8KF0Wkj/8PQO54Wei9tLu6TZgFYZGV/9J+YpD8uIDvBt59hXZVsBl6KocjwCyHv5eh2riVI/HwFZFOfwIQ6HvAvR6xEGxOqm6m8fW0KBhaFgaBdFRWwih2D4F1FS6ITZLOGrRoIB8e6pxFuGKHbW3JhPAYqnbvA6AEXDchnZGObaary/SXOFh6QU6RuW9CNF9eebHYYcAg/i3sPpRZaIXI9cIUKkV6nW91va57hPL9xiRajuVLzpcJWgm8AlnSsmYWLswtgbxeAL01oBPSH9T2fjnIrlvvdterfqn2dLyzy7CRqv02GA26HY1SThYfBwhyW2EK8L571cCIfXd3IAX63UY2/piZBAD7uPhrcVWoT7E4fp+3dQJdhYKfe0OnaAHrszXMYdRdGGQnze2wyZsjuDXBflCnDqXyNb8Q7RnE0SLLOQOy6zNH+1cFWMzCLG7Fcobg+gGreacSw+VFFP6KDIS3aDRVDJBprFdq1V7ZW/iOweB/9EL21pWt9a1sDuwbJ3ZAXIYtSZoARVNPoVZl7Kud5Df3tvbSGb7qp15M+sdt0pttRGdX8hBm1vKAf8h2sXaBVrBHkxZNyTtPOeDVWsaZSRtu1ubaYLA0eKBIW8fQj+D45FK2Dj22PaEKfaWnll1foLQTM26525fmI2FH7D7s0lx1M1JxCeLKwucH+NR2Yo7KD5DNunKQWNA2Xi/qKxHMwIpSNEhEAYHp9X8JmuO48FfYRWqCqVZCjVWw63Ily7zbkehQe5I+aGNXLvP38+Yxv8MNhaXwhpBSCKv/6Nz3mdTdwlduUbUuarEA7Qp5f99eAc6qj6Fo4dV0DdcaGoKMs9ZKEble5gj7FwK/6ngxhISfnew/Y= 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: 20 Dec 2024 04:40:56.3561 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f54e0b27-49b3-448b-60af-08dd20b07e76 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: SN1PEPF0002BA4C.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5744 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: Harry Wentland When the plane_color_pipeline bit is set we should ignore deprecated properties, such as COLOR_RANGE and COLOR_ENCODING. Signed-off-by: Alex Hung 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 Fri Dec 20 04:33:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916220 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 9778FE77188 for ; Fri, 20 Dec 2024 04:41:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 159B510EEAB; Fri, 20 Dec 2024 04:41:28 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="RJ3shkbM"; dkim-atps=neutral Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2082.outbound.protection.outlook.com [40.107.244.82]) by gabe.freedesktop.org (Postfix) with ESMTPS id 55E9910EEAB; Fri, 20 Dec 2024 04:41:27 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qMy9p8bmdsZCw0ibgxZ2N4qVdajYnHocBHYORyInNJaW96Lac+q/5dXRFCjZm6Tv3gCH7tXlDo2XZ5gTVIE4RIF25OSA++5W8bTrEeA0kLXDWKZt8jLHsZ4xOVPp+CwOT2qRE62oKlQFDGadZjJWaNpJL+Q48RaeavU6B2IvWSSDeitNTc6OzYP5U8oecr4TLhbcKQ5VDhgTxjwPFHOdFliDkBBgus/hBvimR3eBKtAeiv2Yj5DaloEIhRHp2JdxG6099wMTthyfLUj1PiIKfbrXDwiP4Aw50PsqnL2L5bxtx/EDo5K2rkBZJXdMn13M7Rn12r9Y1iZXfIR230hRng== 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=Bwxv7hehYqvHD3ROk2S7ZCE75DY23e+bKJ1E6YlO1Pg=; b=aOfXwrRd0yjwACfzB8bEiS/Or5R8+EWFMvdlQbOv3Xq5hYep4KU5wszpG/D1lpdPiMWIVDY4crvxTeFsf1MBRUhqXejr0S0pKjrBeZJH57rRrM63IpbNXmn7czxP6cbeYvm1FO7+bB+QZxQXKP2rnoHYYF9R3NrROGfdMfG+uYKpGOAuZcGIMSdFwuxYrYHXpBtCAMBEiIti6hvyZIwJoUXnqIz/GhtPF354f2qE+ykNTpKKgYmSl4ikFSMPPpgqXaghM4uDU1b64fLq0na8Xn8GrbkbZyDEsfIX/ciBkmWrSWKWnORluzYgLzwD50QsU5yA/X1CQtZ+NCq81wDR3A== 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=Bwxv7hehYqvHD3ROk2S7ZCE75DY23e+bKJ1E6YlO1Pg=; b=RJ3shkbMul/VODGrhjrDKgtvcRqnPcjG8wLJi4dS+u4142sVXzT0fCS7aYgh9Fx2kLAmHL6mqp/TNdRfa3yFBOpepC52I+OOyecrsYvXzbs15u+5mDbYBmo9hB7Sk9GGITUvrqLXXskcxGZwoVgMyrpl4DTDbZsiJB1MwKp9wEQ= Received: from BY3PR04CA0003.namprd04.prod.outlook.com (2603:10b6:a03:217::8) by DS7PR12MB5767.namprd12.prod.outlook.com (2603:10b6:8:76::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.21; Fri, 20 Dec 2024 04:41:25 +0000 Received: from SN1PEPF0002BA4D.namprd03.prod.outlook.com (2603:10b6:a03:217:cafe::7e) by BY3PR04CA0003.outlook.office365.com (2603:10b6:a03:217::8) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.24 via Frontend Transport; Fri, 20 Dec 2024 04:41:24 +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 SN1PEPF0002BA4D.mail.protection.outlook.com (10.167.242.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:41:24 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:41:07 -0600 From: Alex Hung To: , CC: , , Subject: [V7 24/45] drm/amd/display: Add bypass COLOR PIPELINE Date: Thu, 19 Dec 2024 21:33:30 -0700 Message-ID: <20241220043410.416867-25-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA4D:EE_|DS7PR12MB5767:EE_ X-MS-Office365-Filtering-Correlation-Id: e09f0967-809b-4daa-b3fe-08dd20b08f37 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: e8OkgGeZCMalqhx8CyZKJvirrXuf9wbHCE3p8n0epWSj8juvRFNxybLDkfEo3u3Uw73YctprvYriA2qski1bxk1M9/Nc8SBtYtgTAzsndH0HrzNW1hpRxuRy6ozx5dvrJwM3R0zsI7O28w+5N5f+zK2e7wPTB2nTHwMHKfsg/B66gnzY9uQidozKK7kD9ZJAR/anY5knvLvKQi3cxVPUoW7MlcZ+9bOKjML5Lcse6YfMbhFNk2sXAbchsN6+xSIC5gLbNoe8ZUt4Jv/6obGpxskMII0RyYwRqWPCVhHl+/X2I+qrsnguMG9/P9z7c/iCaW0CjRIlSgfjORLdZYmbyLaTlpBrBxfCipn9YPADFGuBzrSXkLFxqco34JPNHMEvflEyLwQNNH4kYfnIzFRgjtgumZCa++P1EmZpNAWxFoi5F9MKlq8oZiqtNaDggfxZyKgcQr9sZDXrMyXO1f9gmqpdmrdoVeBB0zF93UCyuVVr7OsjUmfETlnebasdU2Y9mJKmo7l5p+WLtOTGu6lm/Uwoy8waoplO6Xgxo5Rwc0B6zZ0kPTo8tnP1LqH3STwvghGsCDhgRaVzd2jYu0bzE0s0qJRj7wjDq4/pUutzUG824qACzwTb6OHfu4rAoPqSJPPH9eYTNjfYMJ57EMAv4S3F1idaFymO4xB/7joIjd3KEQjx6Apz1K11IHVMWJFEn2nXjfFIFRoVkNZ1bjg4G09/WXwBugmccgNCCg6mAJ5CvGUQgqh86o7M6ovkKISSqz8yfRT+pWRtwsu5JR2H4o4jr9fc58l2akeRLKy4w9GBbWorrDG4AzmkQvykSj5BieQakMMZNAvMd+DttUJlHwUW3Zz43n8oYHPeCx2SMZKURu7sF/ls71Hr0uzs8OeajQjGNqPMu2rLap+R5WDzAFPyWmxPT9P2xCP2dNU1DIdwXnVibXYlg8+//RQxu5IQvrQVEu8k92Uu0ZWYmVQvAFOBUwSEFTo5JfMizKotLoyA0btCUff9mVKIU+O2R0m2Iu6t01ugcojyjn62p5kJxJof1jV2tJDjnwb85sYzhQV1f3Np9JZRqEJspWUt6BZkobZSQk323/CMrpjX3Y4j/KjCwGp2MH7hfR74etBEmOYT/0UD9OrqbGAbed66QYox2Mbtwtgor4qFzdc0dnVTETItcozUA5zzsQX1DrmjOQp1mp1h9o3Fh/yW7cBG/800vODLOzyMgIr7S7SGpbibDtjODKKS3cpiQh16nSuMsQByUMFnc9xl7sbE0ULGvhvphb1QIGWzNGiuCk0wQQfGSNnPHKTN/HcmoHTnsERGARsrlu4wKZCEg+wvt2PKzkIY5YsKPQ3h6E78VUQ/AN1IR83V7NXAsCS/Jzmt8rd51UD9xMupVo6GV/MA3549doxgzqKFgzq/8zQfohtpUO9vjvfZWR7ULNVENv5CVW3LI6ajaULA03/H018JmE9qxis4rHnjNjfjKFT3xrWu0bPwehP6oAXOKWBZAzYet+yixT0= 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: 20 Dec 2024 04:41:24.4666 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e09f0967-809b-4daa-b3fe-08dd20b08f37 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: SN1PEPF0002BA4D.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5767 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: Harry Wentland Add the default Bypass pipeline and ensure it passes the kms_colorop test plane-XR30-XR30-bypass. Signed-off-by: Alex Hung 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 Fri Dec 20 04:33:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916221 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 26E48E7718A for ; Fri, 20 Dec 2024 04:41:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9BCEC10EEB1; Fri, 20 Dec 2024 04:41:41 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="V+VUN4rU"; dkim-atps=neutral Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2083.outbound.protection.outlook.com [40.107.236.83]) by gabe.freedesktop.org (Postfix) with ESMTPS id 190D110EEAF; Fri, 20 Dec 2024 04:41:40 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=O+I94YnavLyKE1eTj0phoTJdVmjwjQ6+5m6EhcDNBFJ6SEY4JJdS+PvVWlXf0BQ2QdC0aWXK94njfTkM9HMTiF3fza/4JRPFZW1L2tvSULaSNC1NexhXWv3El+V9xlLJRbcl3M2uHVoQKuYk1Q/Y6+5IvFB9RmfT6WTIxVBVJbtVnEDa+4QxXefuKkieNxlbq7zUZI48nV8V2VCSNtV/+ulb9F2slo3Og8m6NKgvVCwbTFklXlHwMMUbJslpP+pFBckgs5kUyWNrw9HMg0LnoFi4gpPMTQvYDPj4vY11hAUrfn96ItCyg5vJ7dKKv4Z82joVPUc6N4h6/de6NVoMxg== 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=l7BX0/wz/HJhyOCmHrM+dLgF88Sh8tQ9PSsAgUlMX18=; b=tvrl3D3c80+mvLLfVMnjDozJYh2xijmpgl+n0vnQWKXrWP62/Ak3/PPykaWev0lRCGMzKPNidg1pT8R7N58fEXCQJAWO1LFjEtglz2lphvP7pzSApYG6cFP3QoztCBouVnIusNsVmlAmktftLz2C2HsqTkn9LjkjOrw99eyGmo0M6tw0AK7h8ID4idk5OK5VPmDKY9+fuLYqNVG1WprxLQNWIuSWVMs86vjOvdJi/Yt3BPQkcsCFqF+U4drGG2ICtXJplqUoDeYQjjC5Rsjr9dGVl1SlBRZlpmwCrbG21PW25BMW3Zq4WLaaQ1XVtYJdnMy9YuReJ5TViLxIIFmIvQ== 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=l7BX0/wz/HJhyOCmHrM+dLgF88Sh8tQ9PSsAgUlMX18=; b=V+VUN4rUU6Q1peTfpwTHzakSfvaAOpQ6LGHYk+Oj77epTzOvJ0+2AU7L6x5WMyRBmcqTc8eQCNeh9OrYJGzUWF2+CojBdC1qYGFPwiI8ZnuiY1/u2qXEagrqVLIQqSpm0TA+80VNGEivM8vf2icBYicB7QRkHqkz9Gu0jXKF6hI= Received: from SA1P222CA0134.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:3c2::7) by SN7PR12MB6689.namprd12.prod.outlook.com (2603:10b6:806:273::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.16; Fri, 20 Dec 2024 04:41:37 +0000 Received: from SN1PEPF0002BA50.namprd03.prod.outlook.com (2603:10b6:806:3c2:cafe::1a) by SA1P222CA0134.outlook.office365.com (2603:10b6:806:3c2::7) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.24 via Frontend Transport; Fri, 20 Dec 2024 04:41: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 SN1PEPF0002BA50.mail.protection.outlook.com (10.167.242.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:41:37 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:41:35 -0600 From: Alex Hung To: , CC: , , Subject: [V7 25/45] drm/amd/display: Skip color pipeline initialization for cursor plane Date: Thu, 19 Dec 2024 21:33:31 -0700 Message-ID: <20241220043410.416867-26-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA50:EE_|SN7PR12MB6689:EE_ X-MS-Office365-Filtering-Correlation-Id: de1a0377-fdb7-486c-2130-08dd20b096b6 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: bhBJ/Jkbw+yY7R8GcXQfUhTgOPYT2mFanSWZO+XdogVXcGkD54T7II+Y0AfgNORO69PPSMNg33FwOEkWKjmVquM/E4Oqi6kpiRsjfCoHFtVpO+JOHstGQU5RzFO8LE5qEtNdGtqT16sEzZDqqTVfj3fs1jMD0YFaIQ4oVL0mxyAyv9ZJNHYVYCpqPJ/esaFWwq9z3rd7DsC3bp0BjjPlPr59h223dfgORIUt9voFl67NnTqwUxST0ElFlGMiCeYzgAWS93Y+u9vwo3sYFZYc3osr75eproRfUqqRO7h/wuAy+IQ2sxauEzWuCfbTEp3qVkOR+3/Zs76UkoKwVw6dDNWyOktgkUjeaqjXJKgZuZvNMuTVHshfoChEuS5UgmwoLpykzC/qIFZHaKIXAUrvQ4uKpmJzaa5t1PTfLp6bF/g0j45/KaR4pU20v6hEteagtHr+bALAdssOBNXidqLgpKbAZ8MlgazJNVgCJRqzI/1lnB2QTkjkikC/6sD2u4ydDJnGqIRMRrMpoAxheb2/vUTrPXaA+tmxuNH0dop+/7XXBCS2sJZtuO6/7Dwq2Z1CDrl73N71hFvuOCoQFMG2Uh0ipT5qaYhJQVsEsK99fQUdIDdldsGDygbipkbRXGZS+ZUeBdSmtYkl1JCisRdf63tc6HwvM/xRTqJRYly981MTL2gldfvYVkLcO6pVsKENmL90V7J39cm/Zi99GcYu5b/wUAZAg+tw1CvxIRaomUXA+XInEFXZqRzbebe4wZbwpX+t/4zEU9fS2stUA95PQRwOi4S1Yyv38e93drhwVeZR6rSsWfzcF3xmvxxDH6defgoPuJclNyX5K3zvJJuCafFsE50Y2+69DPltEzezDdX7Q/pjJISJFCyHbvUx0uRGCjFvO6Y2ZETaFcKONn0dUJI24oGWCHp2sPadDiYHmlGFLDr82jtL648/Qsbu20B4Z0U2OP5W8EBwtKmyBz2LEi09So2vRHQp0jASWQ0APcTjIRW/MWXCXoU74pEytdL+EDq/6xNd/Jaj/Bad7KZ8DhRNn9YtU2vTxIDj8w+rr8Y61rmAMsUzEx+sr9vfineQodzqM3m3d/lfh1tDc6/yjDi6YH2uSzP+1PZj64sbd/NuxNPzTbROkOPNAuyTWEAUmM793CIoqEXgh3REKw2XuYp6UuIQ06pJLdXKpqDBaBIxq9/EW7SrDNiRS5DBZ/47yCgHBoZmx9Yf7ueLcfX5668KWDS71HCPvNgQwHRVXYb8Vk7vr7nOUpfG32VYy9bPOZcQwiAZB+x6X7B8f4u2QGpK+0U11sz6INrQkfq2o35edKlarAXS+2JzRoeaGQhVE69aIJx7wXFPa0N0POAG4ZTe/ooT9QsqjysDbU8v0aaWnHIKOuFfjkfgUv5TtGeijvdkST/o1cXcGjPc+1GTnmxHOcoeXA3rAkXK+bfw7IAU4bS0ZkNG2g+crFrTUbNWF7gyjF6O/5azoEcLz1HZSPRqIfkZUBxS8mGbFh2dDoY= 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: 20 Dec 2024 04:41:37.0548 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: de1a0377-fdb7-486c-2130-08dd20b096b6 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: SN1PEPF0002BA50.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6689 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" cursor plane does not need to have color pipeline. Signed-off-by: Alex Hung --- v7: - Add a commit messages 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 Fri Dec 20 04:33:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916222 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 23D43E77188 for ; Fri, 20 Dec 2024 04:41:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6ABF310EEB0; Fri, 20 Dec 2024 04:41:56 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="FvEJdLrz"; dkim-atps=neutral Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2057.outbound.protection.outlook.com [40.107.244.57]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8239110EEB0; Fri, 20 Dec 2024 04:41:55 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FUAjxRXunsPGWytyxkEwX1ZG3YI1f68mHh+2sfXb0pIYw6zRNL82xEmJNNUwQj37Pr8gs0Ryx1C+JdMhTPdAmDE+0jFaNOjvDZr9kSeDSOpD3Iubkrn5N7hmG50UMJ8S4JxMzWR920m2ELBAJ+6BAHVELZd/exE/8CFxDIxehdLAXvf/lHVRAeoUP+GPZFY8MFBklH2iGGFwL+BZmYIOr80e+wHWHOTLEnI4GEnEkrjjxqkVUVIw2trryMDrONG8qzUPYnVjTm7RDKOYmkeR3QIcJunyJaTyh1yVHBM9tLfnOO/gbaZnrkNDkH4K2xVPatALYodtY9j4lcOmu3jGow== 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=fJLHVPYEphPX1+QrOoyzN9WFbDnopiHbUXbf/sUZ7oE=; b=Co0+LQce3ao878zDEXZDHjVStJP3ienQmRLcwRO5vyIZELWJKeAWIuBf2tce13MXbjvNQrEQ68SC2R3/+xYfnmKjSQneUZ3Oq1RL6T7nmz4SI8wGZB6QvO/EUnTCT60OhvVLW5WtSOzdN4I4WohZzM553RuvN0H0MC2fOCHqI7NH0cZ4lqNb70BgxtpenQhfM/Rkx6rSGqD6ssKoob8+Z8o/56jUxgZym4t6GAjFujhSbjCj2HD7D+H3Bz9ZcqIpP6d/0M6G3kvGi6LO+r9AtsrQsuySE9Jt8tA/koSUeIVHyoOGR1SwK/kXn2tntoTMlm/vV450+vTBtUan+aZsRw== 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=fJLHVPYEphPX1+QrOoyzN9WFbDnopiHbUXbf/sUZ7oE=; b=FvEJdLrzqIOc9Ks1HFEQqbsVoAuCZW1oVdpnbpa0x4JXDGSpIR0h6QNe3TQi/aAibyptIz8r3pZGQOcaeuxvIUAqGl+6yNMQCiwYifR9rHgpCc7bI0NOY0ukVuklgx22aLPvXm8U/35SBw1v2l+Ti2a7FMPhrrHmUNWD76wWNq8= Received: from PH8PR22CA0014.namprd22.prod.outlook.com (2603:10b6:510:2d1::29) by BL1PR12MB5899.namprd12.prod.outlook.com (2603:10b6:208:397::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.16; Fri, 20 Dec 2024 04:41:51 +0000 Received: from SN1PEPF0002BA51.namprd03.prod.outlook.com (2603:10b6:510:2d1:cafe::b4) by PH8PR22CA0014.outlook.office365.com (2603:10b6:510:2d1::29) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.24 via Frontend Transport; Fri, 20 Dec 2024 04:41: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 SN1PEPF0002BA51.mail.protection.outlook.com (10.167.242.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:41:50 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:41:48 -0600 From: Alex Hung To: , CC: , , Subject: [V7 26/45] drm/amd/display: Add support for sRGB EOTF in DEGAM block Date: Thu, 19 Dec 2024 21:33:32 -0700 Message-ID: <20241220043410.416867-27-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA51:EE_|BL1PR12MB5899:EE_ X-MS-Office365-Filtering-Correlation-Id: 6a8d095d-9480-46a9-d20a-08dd20b09ef9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: Y6djxJLmwV5+Zrm1KC0a7amdS999lMsZb9zayqsIkRXGpxTn/5R1PvMlSJrCLYPB75ewuGP6WrKVsR8g2OjF84KOUYA+wKz8R0CCqj+OV0o8c6ssF+OI1ChEpraQlb6LpRzqLTHIoQq0L5SECg54YAitlApSxXAPhGn5aMLgEg1bYdCR6wrvHgvJeihIi+RE6lrWAGHcrK5t34wgqv55rS6UepJlimd/InJyg/NItSoCEmxIJNFYfI4TfI+c5VE7ndliEoB+Wab+wnqW54LEDUG0U0JVWeG+U0uKoJ8KxqPNFO+i+4BfKwXBKR95WiFfnJZbXFk0wfvetBnu5HUuRd+Vt4pP2aciWQoaLux+uWe+QitEk7fQIDaMA0VPGSFWRofpb1eUkTAfBKzb5FVyK6k7aEHNqAVQoa+wyuo+GzCc3AFSfereQNCg/xznRfCNAWa8+zme50m0Vsqo0ldHle5jE8eDsiKdFhho9MFTWr7zGdq6y/oNsJhyOgQMN2JKhT+0yaFSQcu8Vq7XfMpHP6sJBUclBB0jphv0BshIc7M7Cp4IEALcfiVXjYJdrZq5eYHiVAOR1vFHoHfuibfsxVh17qseStrHEqQhAZsXP+KPnOftyJK18P6nRqJhbWwFs4rYMJp7d+X7R5h37aegjq0CGvd74A+MFIretGi2KNpZ8dHKVhYIAMYXnK9StmcP/YetIvcGhCONgIba/j9yx+Hm9JiY4WYw8MVHcQTc59rUjxsU8VKVhNUGGacQNscF/1HAmuErh/13ZoSel3Rb1Z64wKkpnYwJmpjcIXBrEkU30Roz4zJI7XSkaHBdXh4vT6r2eHCzMbMLSoSc0V6UFEHb8xngPjlrRSS7g6ds4FAelFrNf/EV4kefRbS0kDQmwrEyiJJjgwen2+tByZNzLN57jrAmAhvxmkWaUHX3oGVniBKATInS75uYGh1ukxQCE5Wf+Ls6iGnvbNpm7dAkf8R9hKbdXbkbcaeZRihqVHSVDG/vakV6TYePUKXN/ak9YeXCEPY6EvE7eXpY5OuPBhq4VZKMoVKOtif2Cuf61r3WXVNUtX9SufBkTI7RGAm5O1R0roYO9YxlteCrdtdN5jmsVW12cVXBldcNrQ8la9icYrrf5kCWAhYg+VV2ogCIKy7gltMsUN9X8ekUOUY4IO30OPskw+fwIRapNe2kOJXsCif27T0CsDFg3U43SaPG/QT7oBmKohe6WPB+EyeWBUIygn/EQ0LkvO7nwAIRF3ejpUPmdwuvN9IXoNOzubWUsVgL9vs5iENOKnybb0Fb22rpm+Yd0nWS+9jF72Gb/7C5NWAsjwqu+Ui7NoiMYAjL6gm97o3hvtJZwqVFYqSs5d1vlehmq/t+258ATRLwNlQb302O/zaye8ibdrBxhpfS1Vd2G27KtDvgX9ayfH39NeIF4nsHq7OTpIasI1Q/bgxTpsGMB5NPAfBBwIyVp9vESbLitX2FmdGmMJvAhfjybf7W8zhXPacZdEsWKHxIFhA= 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)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2024 04:41:50.9040 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6a8d095d-9480-46a9-d20a-08dd20b09ef9 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: SN1PEPF0002BA51.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5899 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" 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 Co-developed-by: Harry Wentland Signed-off-by: Harry Wentland --- v7: - Fix checkpatch warnings - Change switch "{ }" position - Delete double ";" - Delete "{ }" for single-line if-statement - Add a new line at EOF - Change SPDX-License-Identifier: GPL-2.0+ from // to /* */ v6: - cleanup if colorop alloc or init fails .../gpu/drm/amd/display/amdgpu_dm/Makefile | 3 +- .../amd/display/amdgpu_dm/amdgpu_dm_color.c | 86 +++++++++++++++++++ .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 70 +++++++++++++++ .../amd/display/amdgpu_dm/amdgpu_dm_colorop.h | 34 ++++++++ .../amd/display/amdgpu_dm/amdgpu_dm_plane.c | 10 +++ 5 files changed, 202 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 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..566035af00cd 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,18 @@ 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 +1149,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 +1252,24 @@ 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 +1366,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..3be0cb19ebc7 --- /dev/null +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c @@ -0,0 +1,70 @@ +// 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--) + kfree(ops[i]); + + return ret; +} 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..3324e2a66079 --- /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__*/ 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 Fri Dec 20 04:33:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916223 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 0A769E7718B for ; Fri, 20 Dec 2024 04:42:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3561810EEBB; Fri, 20 Dec 2024 04:42:09 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="yor35e/l"; dkim-atps=neutral Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2070.outbound.protection.outlook.com [40.107.92.70]) by gabe.freedesktop.org (Postfix) with ESMTPS id DAFB510EEB9; Fri, 20 Dec 2024 04:42:07 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CJAoO0t01861O9Z3RGACCW7Tz7aK2TQMw2rpofmG+eNsC6mPLPiUHjSYunlg5Hjyfv/WgObnB5nRxhRHiR/k8GJfqT+8tSEYuFSorrcVatKY1aGMJRkp6voYf53P2tMVz1cKUwBdeiBydO5HxAYKxfeawctFzgl/AucyHvSihqPNeFHVzgFP+JUv7yx0fWvXCm7xUlhMYvgt9ynXkoUk6MA5s8oBKTrNeJUksMZNvGSiWBXnVMH+wGBYYh1Bx5jxkV/bEz4DKpxfHKB6JLUeU792iLu++oQvQ50SsYQwwlBV1UApcQW9LuOmbepbs3XPyOO2DZqnDKO+wbo3+/AP2A== 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=3zFpifbsjUw5aIk/Ur4KSpPRxH8c5tAEtG5c53YmYNk=; b=cMQnIOgglaxOgF+gn+T6HNrVCP8lnDO1S9MOCe9E9fRcVu7uLfr+58ncosAPZo6vmneFCjafPwAlmu+x2nEcPDmZrO7+0z6frs8R4isaUECXkaYQHEsnHG4MDjUzsJ/9+E5FYB8PXXaW87M1vg1+15fevFmBxFrEbOBcygQBT/ea7L0aI2RN+LvBYRcoDGT8q8rUx+VjUcq/rorqiW06IxIglCIISQ0xP0BBoFA85agWrGweAzlH4krnOrMaldVvtn0kN0LuoT6nu+Kcj5tBMR7SQzM48114+5A2yKyTzd6gaeR/Fe729n36kMbA3b2u8Vn8HbrK/TIOkBvrbjfL5A== 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=3zFpifbsjUw5aIk/Ur4KSpPRxH8c5tAEtG5c53YmYNk=; b=yor35e/la/KzTpxN7eEDzZH50XJ9+Q9JLYubOV63WyLKqhPOJ6Az2VheLrrOLQjyUVsot5AehPb9jgUS/Gg7jObwQ4ZY2K3RsNGXyw6V81lxXNwdn0soWYfSkeCJxy3VX7OQE9odqRoLy+NnF37HiXZGKAo9mKbwbJap6bkwDnI= Received: from SN6PR2101CA0024.namprd21.prod.outlook.com (2603:10b6:805:106::34) by IA1PR12MB8468.namprd12.prod.outlook.com (2603:10b6:208:445::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.16; Fri, 20 Dec 2024 04:42:02 +0000 Received: from SN1PEPF0002BA4C.namprd03.prod.outlook.com (2603:10b6:805:106:cafe::59) by SN6PR2101CA0024.outlook.office365.com (2603:10b6:805:106::34) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8293.8 via Frontend Transport; Fri, 20 Dec 2024 04:42: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 SN1PEPF0002BA4C.mail.protection.outlook.com (10.167.242.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:42:02 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:42:00 -0600 From: Alex Hung To: , CC: , , Subject: [V7 27/45] drm/amd/display: Add support for sRGB Inverse EOTF in SHAPER block Date: Thu, 19 Dec 2024 21:33:33 -0700 Message-ID: <20241220043410.416867-28-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA4C:EE_|IA1PR12MB8468:EE_ X-MS-Office365-Filtering-Correlation-Id: 8d72118c-9501-4395-28de-08dd20b0a5c6 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: 52EUuFUp5ZGD/IJiJHlA6zIywlMAlayOIXwlS7hMT16Jx8tJspygW1We6cPsO5aaaZwtSr4nO+nRy8ZCqLBp1mhtu7wBClLtIHDG7wAtPbINAHVf/egG/zz0dp0vdhWyf/De3wlsOaL6eIKGs7AxraDNPIvVXSQblEEtBueFfnEuKlLWx8MasACFukfHCP3evWAJytdv2ZQZ3ubbpRen3W7DINz47UnV0YCgO/zDL8WcE4MhrABL1CpFQCwhAebhAY1gFPP7nHvWEVHVl7QClpjq1kHNuWt/8DynvyIKi8xN1ISXFTcOHdJTZ2B9w8IwV0BkRsQVxLcoaaR/OKMA9CW1jbolJ3n2LsofjWDrYEbgV9vAcflqLeE+X74dQDDrT1ZZJmC6SQagSr0WjuBY2x8oxc7jq083TAH2qJmyXLwxlpr0njAPsnAq8QdVehV8cOkVKrgH3fLHQvI+Ef2rNJgbX/eXiLIDAnn6wiGOk3HJj6IRhdtyfUcTa5E064WID4zMbDX5dOfjaOeD6XgG/hBynJkXbdRSAra/QH/qVxPP7QAmEQRVTf8uDQo4c2Z3pO6kV26oG+5PzeA+gne3WdUW7O+fN19aw/cZfItFnS4MD/+tXVfimPWz0v++6LyAqWEmeIPs1HYgnTgTsv1+yzkTgjsp9L44e+yHrrw3/H711omQSNznwTvO+rjkyllfdVyNN2XK8kV/wC8dKrfLyyPum5mOmg+pBRmtmQNIIVz4PgV05CEJo6dXRDoLlZVRm5ffj73T/LJkMaRviBgzDCjyQ1s2xTi6OFOLUw3RWcZqKAxB5apG6IqsBQJzGFzxgShRgx1V6lnBQ1ixlA7Sft2xabW2uyUb3f6ycyM8xFNjR4PUEty2Hwe4eNKWq0OHbPMxonZ8RDcSKuxZcod+SXlCobgY08APnzA/fkJkzloGvunAaUVbk5qFGlNVLaOC3848tXj1iZKqFqfEUMhJrLqPAOR1Q4beHsWG6vD9jvcFZJELvBW6W31gXsJBsVg38KfJLOK+7HOkQqR7HtL4/Jlkt7XKrETfyGZ1WLA+WiAf5XQ+bLnmjFiudgWplqSgeDrpJGdFHFbh0HWuQalEQCktlwMv9k/2EKskDxgWtqbW0of3EKPNEfXrAw7ICW4Y7uoY0LUlK5+FujkMcullvho+YuJd8zSYEEgNvuOa75SxKElxGdBuP56KORpYJQ6l0shmDfQKRC/Y6XZpbRDqjhep62tZOoGLVjrFjq6zfUUfWAbOW4NIrQ+aIChXW1EhT+3jw5657o47JRsTxSU56Ei5ctpjvXTQgSwsuTIGVXdDywoE80aYSwjaiFLIQ4KW0YRj7MhhQZsdXdthVwvNWfd1PO9GvK3PXiMcnzEbhdY11BUBUZkF0PJ1g7vwc5lntU8wZVtwM4f6r0lr3yVeOdZ7CZXD5CEa/6Nni9YY2ytnHr1IT6UbMIp56Uc7a3YWv1g2VqXQGQdFcAK+Zz+fMXFQUANybsQq5pXhIriTRCQ= 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: 20 Dec 2024 04:42:02.3257 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8d72118c-9501-4395-28de-08dd20b0a5c6 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: SN1PEPF0002BA4C.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8468 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" 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 Co-developed-by: Harry Wentland Signed-off-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(+) 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 566035af00cd..65f681b0c31c 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 @@ -1202,6 +1202,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) @@ -1257,6 +1319,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 */ @@ -1267,6 +1330,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 3be0cb19ebc7..718544b11863 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 3324e2a66079..71cd27994528 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 Fri Dec 20 04:33:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916224 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 56702E7718A for ; Fri, 20 Dec 2024 04:42:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C60F910EEBE; Fri, 20 Dec 2024 04:42:44 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="Uk8EX9DM"; dkim-atps=neutral Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2069.outbound.protection.outlook.com [40.107.237.69]) by gabe.freedesktop.org (Postfix) with ESMTPS id 88F7010EEBD; Fri, 20 Dec 2024 04:42:43 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SfRU1toCoEPQl0g1Yhol+msMYkWJye4bF298iIj0Lvz8CNKdNubQwQVuvaF3ycorS1DDgtmguyQ5cjXkt24J190qg3xeaN3sDF/+3jXDI8uAB+xxLDbBF7P5UMheLu7xecxXP4EpQPeUbs3GkLoQPIAK0q2qBq7GmMToIqGJ1E0Hz7Ggcqv+O5aRPLpDYjdkT7KkSve+0CFrtQpwUx1TSG9Qa8I7iMcJYK/s1qfkReAiX99wB6zz6F+FGMbMUpPrZ+35I6zqKZtMPqWg7RpJilpx6QkF27Wu9O+KaBR8GFWV2wNgxZ2NCXheamYUBqFRLx3itDA9VBi5mCU61yAOIg== 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=1SQ+pLSU80UAEFj5EJXWLBEvI1xA5sWnwBV8oSwmYOg=; b=F6hxg06QpUM8IekFNb6jt3pU11BRT8TPix+j8yAhmOu/dnATzOjMxd7akjd/BinRPKkbqmmjGBCzQXRS4WvsBZyUqO0oCbwbeVXfnkx0y85E5TsbGhiIr2zEAQ84+HEp5bkkcaPRPiWddPl9kmj1B8JaSiX2+opL/EDq1a4/dfetntwsduZQ8mnlfmHjXtzSFHoUovPadz3XOfgkMWLrm0Dt6Vrqc85wNTJjYMS/CDXsoXk5xa2w1M/cyTh98znG1qegztDbnW6O0tsO9gQNtTHv0qLw9vG0bcrVoNfngssbLuG3P+BGbjm/GS99ACMH42x8kdpfuRyw6v+9zNaThQ== 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=1SQ+pLSU80UAEFj5EJXWLBEvI1xA5sWnwBV8oSwmYOg=; b=Uk8EX9DMoU2Ns6ab4ThH/Dc3f9wyPJf/YIFlRu8KN/PUBi1SRLgIIQ1dpzc/XUR4EO7rx8GniXKXRdPLNprxxxfzFVVQaYfFO0gWbzQVmOydBQP24q6DVs+IbrR1mvgMiP7lihrvI9LT+Dk41+21d0sBi8O1gwa51XYBtPdpsX4= Received: from BY3PR04CA0023.namprd04.prod.outlook.com (2603:10b6:a03:217::28) by SN7PR12MB7180.namprd12.prod.outlook.com (2603:10b6:806:2a8::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.13; Fri, 20 Dec 2024 04:42:40 +0000 Received: from SN1PEPF0002BA4D.namprd03.prod.outlook.com (2603:10b6:a03:217:cafe::da) by BY3PR04CA0023.outlook.office365.com (2603:10b6:a03:217::28) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8272.16 via Frontend Transport; Fri, 20 Dec 2024 04:42: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 SN1PEPF0002BA4D.mail.protection.outlook.com (10.167.242.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:42:39 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:42:13 -0600 From: Alex Hung To: , CC: , , Subject: [V7 28/45] drm/amd/display: Add support for sRGB EOTF in BLND block Date: Thu, 19 Dec 2024 21:33:34 -0700 Message-ID: <20241220043410.416867-29-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA4D:EE_|SN7PR12MB7180:EE_ X-MS-Office365-Filtering-Correlation-Id: 1061a3a8-1074-449d-d455-08dd20b0bc03 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: 5+qaGVAm14TWsf1x/H78fQSICXE3/b2gmi0hlh8/MElLgsCe6aIs9miy3Prdk96l8GmFepvQwUHu3MZZ5e1dXtAdfS1WB14YIkOdUKFipKvawcmySdFizW29P798nr8Ou8UuKbkQ2v3x3gatmKIT257IGbEMXgeWTgaCp92xAfaAptxMOuu5My8K+ivmPDk7jHFXYBCL8JJTNvExFCbZiRXLfU1SMmlsJj32rh0kd11XDL7294vOD1++GLwuv6+qgwEEXEaPiCmkrMxAj0z8z5eeYvXsfVRNr5MRGViBH9WCluavxY+vHnFDL9OuDSTriMJWsNVUDrXT7+oHpyaSnRtt4YREadPD2c+5x18i+H2AIlF52+kmCswLikdCNyVf6MeHE/LXxwF3HaCqfE/ha5qg8tuEmHOt/F8x5lUiEc0K5jI/iiX7VNUBgsGLL3MVBkSR/TAYjBCrGma+rLRI+k9OVYHO7lsC1rrGWPQmtq0fhEilpV1fJa3G2lVTRIlqHj9JU9lysU87Hy4+I/NsLNXZ19gPMNHv7a6iXffTa2pBuRUH9XBUepafDllvF80ZQC76pQcBLpFfhBUqwVBTA9VlE3F48n251NMt7FpaYFaQ6QMFf+F3KZTqd8NOb3rPsyWMFUgpOtNYtyD1Me7OApLV1NUe13E/DYzltSOJoGtoo7xQBXXg3zL7ECDS+r9uzfxW4UWneKkX7NxKrA9r6KlLbmhxQKf/En/VMx2LmRec9OQLbEn3opl16SegY5FedorYl2dh2kYEmbryTnmLEsxQYqKcMCPpILFjj83qp+DblrYpgQvsXUcLPpPWzi0u69oVgu//Cjm4IJzvfpzM0YJ8FsgbFExMWXcbIzCf5enS2ovh/u5rR7puEyvUhLlZCDLYaCHoj6lexfBoznPJNlPMYVRMwu3vpj6zTGTmPx1B9fr4NBZ/PZFMmznFNNVa9Un/y2vh+c3Qz6bIcb02/iKgAeW9/tlvSl9/FBdxw8z22EULRtpGR/7k3squ6LuEcJiBesbkDw7fukpU+n/Ow/4KkgHXj5hSInU8XcbNDLkog3DqqnZHUkXx2w4+hu9RUCyYdCE+6zhJBQlej6uXdc+RZc7U8vurmGqR0+3+D5h+96kl0sRh33Ci0IEBjK9D4k1+gin9cwj4/ObfzpPpGJn+0IzKVxYrrmnXccztzzhK5F18r3EbfKTCAKISRJRcqyEd4yE46ArFzvI1f1/I79muPr0pakV81rXTV+nwcNkStga1yLMpltM0cLuMSbc9DXgR+sR6/ufs6u2Ii7bp8VGx5pT5mYfULCsvG0IY/dz0faqBRMHAmd0UHtGskV7AgIoVNZQ7c5SuNvnAw/i5QpKBZknhWkMqs04zaCTZgpq1fvhRG8crJpYIqbwYJnCJdESqwh7qd0CAvkk7gzCJNN/qHEC+EvaBlbVECVLh6TFZS2pqp3bByfl5iIz0T+QnVq8vSyndHbQjQee6TiBLzSQN/lF6vs0Zj9eB0Jme9dE= 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)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2024 04:42:39.6241 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1061a3a8-1074-449d-d455-08dd20b0bc03 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: SN1PEPF0002BA4D.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7180 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" 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 Co-developed-by: Harry Wentland Signed-off-by: Harry Wentland --- v7: - Initialized uint32_t blend_size = 0 by default (kernel test robot) .../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 65f681b0c31c..ddc8318f6201 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 @@ -1264,6 +1264,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 = 0; + + 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) @@ -1341,6 +1407,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 718544b11863..c5154e1430f5 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 71cd27994528..2e1617ffc8ee 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 Fri Dec 20 04:33:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916225 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 E6202E7718B for ; Fri, 20 Dec 2024 04:42:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EC09810EEC4; Fri, 20 Dec 2024 04:42:58 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="k3l22pAr"; dkim-atps=neutral Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2062.outbound.protection.outlook.com [40.107.92.62]) by gabe.freedesktop.org (Postfix) with ESMTPS id D28CC10EEBD; Fri, 20 Dec 2024 04:42:57 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GDeAo5jt4lxDNPEpSAO4IWhAaORth6RBWEsRAmjlkIvKi6Qw/WoCjJAEXfGMwUNdC3CYFBqwv4UuWDP9IP1CcPrrfd8HBPDtR/2jslIrreLEmuLqPapSXqELV9igIYroG853Mr0AmXRIEZfdmU/mLHJOLL+98oc4Nszp/ZLy2ncLHHWRzikJVp1Hi2uYmOq8eIkeOIP94ycQwsFKESBLpQICUhXpZ8fz1kGKqUDTV2n7Fd1cNhLYF4neD/jru8XSnj87CtUvfD+vHnwugTQp2msnalSvPKAii78rHNcelXjCnvGDdaBbTYryfF3GW1xwndBBJOYCxHXQCYuhGpAXSg== 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=zsBfc5XmsUnasWx39c7OIHeBL/z3yUqz/7BDF133iFs=; b=AfIgiS7pKHobK7uEbX0Jw3JVYEoim9FXY4ddPEGXjxHC0/DmObvF9OPD2qEOXmID/y+Xye5Nw4dqld8I3OMNVcHfAx0Ecm56PNXQmQHGnln/LE8urXGnu7CX0JS92l38UalCIFuHoqZnt0nV9Z6vIJpActIXc8FL1U26kG0Guys4RkZvsPMhKYRNWaWdK/jIVkbuYEU6EzheC3/k2ftkeYEcx2tLp4r43mdxtSw4lKY3eWAWwbisfoaIkPOCJUBYC1pqUBrbnIWuKemFLJB2UDnuuVdOUjX2kUZF8MIrXwlwaHEjt/qnY3TnXdDNaJ4IKs3wNMNAQnG2ZZJtR9xbGA== 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=zsBfc5XmsUnasWx39c7OIHeBL/z3yUqz/7BDF133iFs=; b=k3l22pAr2O4nnbP+QfErN7YZiv/svoZ32rKTqFOPnjy0YMNmFfLi6WTnQL+MyuSLr+eqTr+Z7/43dWtUAaWFl92XEz7XEN8Ld7DhdpP//O74kuoWPvw0bclaMiLEbJjyK7iHcXk7iBMGlaOjO6F9SCYrbHWFSSBjDFzL7a4fIPA= Received: from SA1P222CA0135.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:3c2::13) by CH2PR12MB4101.namprd12.prod.outlook.com (2603:10b6:610:a8::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.15; Fri, 20 Dec 2024 04:42:54 +0000 Received: from SN1PEPF0002BA50.namprd03.prod.outlook.com (2603:10b6:806:3c2:cafe::f2) by SA1P222CA0135.outlook.office365.com (2603:10b6:806:3c2::13) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.24 via Frontend Transport; Fri, 20 Dec 2024 04:42: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 SN1PEPF0002BA50.mail.protection.outlook.com (10.167.242.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:42:53 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:42:50 -0600 From: Alex Hung To: , CC: , , Subject: [V7 29/45] drm/colorop: Add PQ 125 EOTF and its inverse Date: Thu, 19 Dec 2024 21:33:35 -0700 Message-ID: <20241220043410.416867-30-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA50:EE_|CH2PR12MB4101:EE_ X-MS-Office365-Filtering-Correlation-Id: f7ba62c8-62e3-4df6-9448-08dd20b0c464 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: qZ/A9A/Dhz2QJF85mmy8b8NEpvoYtedQvx0pPdmPzHF/eaSHBR0LBNXZW0OvnXxVr0x+tl3UMEwwtfVrIxPDyYFOsgix1hq3PkihItWQT+oY4DacBWzHCsqW41T9x2BICJmv1r21UJvO2vw4Fk9NzDrxl8i0CLcx+/cB7VxWQ0nZg5fQpXXWVyDDBqv5ANkCVkvL7XfQgAtMsk6cxtEbpL8AhKP3frtSFo7LfIM4sz9SseKM8JuJ3r+vSqjElIpcyU8TfygqE42N6BtHzRGT3YBjqWPA8vZ7K8RqHFOXCk2lW+Qpr+wet3KQeju685yXg5Qhmtxw0O0Mjryzo4StPlUrMUqgx/gjiwQsP/kmwII09dZymxt9s+9TMy7gr3WgQdjTfK6Yi95MhxgLRq3cq1CvZUAhL9cSnuh1Y8dpRguqGGBUjmDUOzONGB8+kgq1b0rdaFnlgPu79EzaecpU/ZDxuYbkhKQtRxiI2Uix7pSWzK2VPHG/Vio10vN2R/VgjAa1TIvqZvqFYbv3267Fpr/4/d8VjgjTnCmqOIvi6DA9YMvfK/bgSk8Bk1arC7pa7TOheV92W7ql4o5aYVOyaBrkbilpLf1MrvWYdFociD494i/uympLfJwSOiYWsOBdDEYM8uoD6mmzlWbVwaSQqhzjGWS6rKoeUsTyzjdTsrNCpHa41wEORREdc0IrzD4GUT4jxEfkddRAjpkwtCWGKikteM3XmFIAO3poqbyW4mCfSFa0nTBzny2BboHY3lcbSGD2AmV2nofvsdy+ieXoKVkg16aaWR6qMc9H46+G9fWABtbSOHnA5BxAKHwznLwl4PYToVCjDlczP6UVlc1iCG5v/2KENcmMHMngKMDkng4q/q0m49WAvoKCUzvcLZU1Fs5uwchnjV+W4BQjjhVat8LjRV309raMGR6G0IAhU3A6qAvToXJyzZJLYLWei9/oXC1e51Mn2+PLj8BnorC+uNGM0s4LILt9ULYxKMkK232dX+iHv1AqpgS++kKYchyoTZcWU4+vKyic6Y3dLrfZBhLEgi+vRx9zZQSf0v5hsEyfepoxrb1J8CpqfDefi94/l+EHGL6rL72Uxt+na4NMX9kEaYNmWdcUqXtb8RWjLlOXlwj4BWzv3xvf7GcP0t9//ArT4TwqIf05W1au0gRCI4CfE+NUcWrOuXJmlF/AXakIqW6OltopAZMMt0xT5hBlnzLPFiAOv0ICtl90DG/zFfq2OpdMvePNIqf5eKoArcbrpRlF0yFjuMEqqek5XfbYimNdTfV1+PuFiKqSOx9mNZbd97ASwDSmh+BsfbHZXUyF64tkKUDybTyxvRS1L9p/aQetyfPFT2iXlCnM+dtr+p+iQ8LLIzeaU/3jmsjwrrZealrF+9Dkbtoy8FdLUAcXtY3lYaUm+34nuQCSXGtD5okuurPMzGM8WC/1aO8Buz+nZMFKbisYS1dvCQY2XaTq/WBVk/xfc9IzBnydLC6z3Q== 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: 20 Dec 2024 04:42:53.6956 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f7ba62c8-62e3-4df6-9448-08dd20b0c464 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: SN1PEPF0002BA50.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4101 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: Harry Wentland 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: Alex Hung 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 7d4b29c0a0cc..f3391602a577 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -70,6 +70,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 e9f5c1adc2fe..4084a7438032 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -36,7 +36,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 { /** @@ -56,6 +55,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 Fri Dec 20 04:33:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916226 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 CE2B8E77188 for ; Fri, 20 Dec 2024 04:43:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2E22C10EEC3; Fri, 20 Dec 2024 04:43:37 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="ZQI8C24k"; dkim-atps=neutral Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on20617.outbound.protection.outlook.com [IPv6:2a01:111:f403:2418::617]) by gabe.freedesktop.org (Postfix) with ESMTPS id BDDFA10EEC3; Fri, 20 Dec 2024 04:43:35 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LO9eCUAp2Iudnby79GC0tiucyS8ZEOmct5TVV8zZdM+r83HzW4n2SuAiBJCqs4gIiQIAx5s4kV/GDFX86j5FOjl3xdjLa4f7zwSPFmZfT/TnlIjaRc5kIE3f6DOIGyGYc8jal1wMYUslNSUqMYXnGPRZ97wb3PPlt+hkUi8ErMYGLXCwYtgfblpjTAQy8qPZL3Sb3C6f+GKnGWWb95w3vgt9+dngjnSJQVvwPrY/fj7NdODAC5Lyca+AjH2J583QcIy8cK7KJhldXjZH+IT3LU9wtbGR88GA/xK8C9y/CHBj/f0cBo0mHaZATx0ovqiifNo4T3Kt57I+rTkcYPl1hw== 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=pAVBZsd23BCgpSx5sdeir24JUkThGzfrMTXajUaKXbM=; b=jfz/VrLf4B76Ue3q4KKaNac+UBn3z7Utqf03AuAMsByQlO5lnsEaUPrk1rF0nj4FBDN7i5GVcpdffXeIr0EDewXQ4Ba/yaiWTvkAoXb/wMf4F2QYGonEyFcI3T5bUYhajVF/JuD8e5fB9xPrMlDfjeCqEP7CXy+ty5BGAJv1+1TUSZ9RsF0dPEhubC7W84yeKCJptTdzokpAiHjIOWlfti/PtYSwTV1eH0AxA54LPolbvTRsDt/yj4NJB/Xg4cyNx4oMOAfQ8m2IPdmcIXK2XBMAYdhZu+fe/gJDzv8FnQRaRI1Do9M6Vpp1KVzfr7T0wt2/hqJPiAlA3l/5zi/jwQ== 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=pAVBZsd23BCgpSx5sdeir24JUkThGzfrMTXajUaKXbM=; b=ZQI8C24kEhKv0vXzjKquztibrs0CXBiLQNAtUmw1nLxH0iT9PVrn3ueFB2gllBCMlGTQTgnFRbwR1M+mqi2r+MIgE9kOfOi/OLYu+yumH4jVsuI2Y9cWSS+WyCIWC81dWCnymFKCNEGRIvKnEg7K6emkWKDuGaNMv4d2WXHVuE8= Received: from BY3PR04CA0029.namprd04.prod.outlook.com (2603:10b6:a03:217::34) by DS7PR12MB6094.namprd12.prod.outlook.com (2603:10b6:8:9d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.16; Fri, 20 Dec 2024 04:43:25 +0000 Received: from SN1PEPF0002BA4D.namprd03.prod.outlook.com (2603:10b6:a03:217:cafe::f0) by BY3PR04CA0029.outlook.office365.com (2603:10b6:a03:217::34) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.23 via Frontend Transport; Fri, 20 Dec 2024 04:43:24 +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 SN1PEPF0002BA4D.mail.protection.outlook.com (10.167.242.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:43:24 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:43:03 -0600 From: Alex Hung To: , CC: , , Subject: [V7 30/45] drm/amd/display: Enable support for PQ 125 EOTF and Inverse Date: Thu, 19 Dec 2024 21:33:36 -0700 Message-ID: <20241220043410.416867-31-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA4D:EE_|DS7PR12MB6094:EE_ X-MS-Office365-Filtering-Correlation-Id: e0746e8e-aad4-4662-8d9a-08dd20b0d6dd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: soMB5zjyb2jX39mKHF35OkQsqOuG5P4zuwsNlQw1jpJKUC50r+9NaF1Y7Q3JQiCLP6kkWBVEfqOh80Xjc69oYb23ZYkCDoEkkGz0nXcCm4psiIvRzKOT5ralwSSWL54qdyftCRbXN9BIDCIeiBUfCKpNDEZgeP/ZJWAFVj7AX+nnSJDE+q0Z84r1q7ipHdBSEX/6/EylzAVNW2I7iTs/EI1ng4Vi7SVv1MNbDzL4qOE4cl+h/SVjfsEXTjFy4lrjrXIwt31rM3+2NmGQtt/aH+gLjNtCyts3REfuRhGSSEd3nu1EYm4Pu4OoVMIBamy0cc4TvDVD78cSLs3X755PSkvRIcqgGV1OgRwWzD2g0lnGbHH2q71l3InHM0m5ocEpJknV8XecXrPIL7bTkZRExUjQHHStK+DOiLSgeIgFM2x6Jzbaj4FjSTWiD1GjLpvkjx7IuTwRQj7GJnHixyYEq/87MnZl7sz+7SpyK/7LeP/t3Tew+XW3O0jvSdmaUNYKzqzJXIjlvy1O4FPIEt+IMikd9UuDIRylYhjLdWaDYx/KxLHQueEBcgtdT645naYcgZaQCqdVMlbbBNDS53yidg36P9kYsVg3WHpSD6WuG5ubas3TmJiGN5JhFJHvzcmwgVW90Xhrnh3aLneHr1yVWfy3ZCILqQjZWpIEfY8XPVBXs2XnDX8WR1O4evdwwuThcEf/6CnF3iWeTbip1ZnOGFl3lbKIqXXlScxtQYADRMq/mvOVoJ2xLffyoxIBTL42Qr5hJ80xnhoajOM/6D6r2NvxFabxExqb/ZjSVo8WE2Ulxc6ICfH3jDt3I1lgCyrkXtccIqAgNI27fSUQuE6c7EGltXch5pkxxEAY/XacWG9rQtojE3vLuaNpOddSph5CtnlJElzq/zwEG7ti3lyQQfuHthKo+xTq1BiHSjYAI9y7jAPBjKIto8QKRHeVfNGIwtYec/nbNPl04czm/ACS7ACbtVof4d/aLEKbK9LayXnlqWS6/6cKFKIwqjs5VodxtCevg+XwZdketaKVb9eR0iuwTwXL14oV5Lb97XkU7jJzZrz8IeXhK9RV/GbDplFUcOb2uIC4p8Z9yCWjHpPenIzdBh6sYlZLQLdq0jMmLOV8mYS+NPpy83ZDvM9bY4mYkSsJecMXlJObwQ1s9YOToinzcidgY7u55IAyDf8MO9Jm3JSF/btgSPFOtgwvTN69W7RlfpNGcvvRV4ltFO7MHK5Ef5R2AE5ye16oAqKkMO0Klaa27/j1wZnygOOBPPyccObuQ3t9v3+hASQN+gMObZ+PvDV77/Gbs8YnpiecOpjlyuD7O37IxZILCddN16BuUS/3Vk4A4aIluE7+rLFUsGaoYZixMjU8g1L3xxN6bs23geJs5gtuxdPtkHImGlRKryi36wKlczAxPTVL5zOiFCoByVSLHLJ8l/BTA1/Y2QeobSIycV4t00kMN/JxTSKmCVSV3txPajaVK2OG7IL1LngCPVLcPPxCpvuPWeur+kM= 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)(82310400026)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2024 04:43:24.6717 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e0746e8e-aad4-4662-8d9a-08dd20b0d6dd 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: SN1PEPF0002BA4D.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6094 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: Harry Wentland 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: Alex Hung 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 ddc8318f6201..63044e0296cb 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" @@ -675,6 +676,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; } @@ -1157,8 +1161,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) { @@ -1190,7 +1196,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; } @@ -1210,8 +1216,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) { @@ -1247,7 +1255,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 c5154e1430f5..a9d94018a207 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 Fri Dec 20 04:33:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916228 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 D39B2E7718A for ; Fri, 20 Dec 2024 04:44:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5BEAA10EECB; Fri, 20 Dec 2024 04:44:21 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="zliHEQjB"; dkim-atps=neutral Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2081.outbound.protection.outlook.com [40.107.223.81]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3A48E10EECA; Fri, 20 Dec 2024 04:44:20 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wJ9chXLyGcXOaptPVNPM6gVQk8Kd28xnzgMiL7WSEAOqLc+FkYmG6kjwuC3mopAKvCxEU2DkD8tZ8F79h85uurHhiXXxklmDEymxZFrgLXviPg0PyQcoixQt6nAFE2Tj5S1ZggmC35ROMHhCUCUxm5+pscluTYQwPPOen2sBLy5KBg3fSVD6scX9GPADiujdPGdkc80GSJ4wMx/IMvVx9vfIhmHMm/hNsuIxQKfnvoBpM9Z2l0G5H2aYm2u02OqxrSL9+yLZ9ATBJ73x/VTH38GY1LYmCBYrzdRloXKwi6MXdLeBQQBJ5eWtNgUZRd3YiOyqgoEt/t2EHkDaZxPpxw== 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=wbUVwHqOA/d9jfjsMvmReFTVfBXaIexMWQdnWlHfU3A=; b=KDVZiM8EA85OQUrXmuAJl4JC6CyG/qSppTa+NZjTXUwip/1GcovUYGBzXJ0um2AERnUOeXM9/m10OItxdj0qvsn4uYnyQj2ZAQOOJAvs2oGzev5DfCIdzdDcMj6DWferzDseZ3HWz1ipPRcPTtjh52wbWQGhXaS5YltKdyv097Bl/C9nKULqchSzLAQvTn7yNId+LSpGcvyGWaEBulzb+5SEjAbWlm4308wGWoXSYmVJKhab3OAWtod5OMvsh+uC2RubSuL7+QwNadrlWsrBro8kZ5dNuwEEu9TcnIpj4Mg2sd0sPbA/E44ZmYSXLJDQJEfsSd01Jmkqr7h3+xZvug== 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=wbUVwHqOA/d9jfjsMvmReFTVfBXaIexMWQdnWlHfU3A=; b=zliHEQjBFtHTkBTHmC9d44lpG5wFH6GPOlmUISg5uS6rHYu2vw+kYJXwAQNd96Yhv5cIVsz6Yw5ArAMcspmkggPSmVroWNyOGZt1tr9xTYNzfKe/3OxqK909n6P7zAN7M+jI+PuOLGayRMOQ8z4kg+qcEsOpuw8c5wD7iPRXR+8= Received: from SN6PR2101CA0001.namprd21.prod.outlook.com (2603:10b6:805:106::11) by CH0PR12MB8464.namprd12.prod.outlook.com (2603:10b6:610:184::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.13; Fri, 20 Dec 2024 04:44:17 +0000 Received: from SN1PEPF0002BA4C.namprd03.prod.outlook.com (2603:10b6:805:106:cafe::50) by SN6PR2101CA0001.outlook.office365.com (2603:10b6:805:106::11) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8293.8 via Frontend Transport; Fri, 20 Dec 2024 04:44:17 +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 SN1PEPF0002BA4C.mail.protection.outlook.com (10.167.242.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:44:17 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:43:34 -0600 From: Alex Hung To: , CC: , , Subject: [V7 31/45] drm/colorop: add BT2020/BT709 OETF and Inverse OETF Date: Thu, 19 Dec 2024 21:33:37 -0700 Message-ID: <20241220043410.416867-32-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA4C:EE_|CH0PR12MB8464:EE_ X-MS-Office365-Filtering-Correlation-Id: bdfcfa80-c535-4ff9-b8ae-08dd20b0f649 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: P9PCgvdPmrVSDPPxEYUJqwfFPgbKas6hB7EGqrU9bA2FcT8ccB31CZ2GGzFYxDifnWwz7gUld2Nx8haJCT2eLe+gD9MZoE2KZDoEpi9Flz+TNcr4ZFfg0wfBNBurqbl0lC8+my2CSRt4YucYDcCNrf/GiQCAt07HWmmJFNbPO9Q9Jp+sZK7Od2P3kWBoWiw4bZ67uzS+9thQLKrJSqhMrRjtg+sjeu9KtxyuWxMJwxotvZZGaJ0TrVOmYYQJS4wcrcLIco60yFKYzvzmZWprQZr4gepYFZojAndC5UzuYXLaZAzJNYzWYPQfo6TM+1C3j2mtkRnkzyGcZOGISrERfcaMP9KYZPaeJ3RA3fjj8PXXPoi6islxqF99J6yciYaGUpD6HuqZyISb5KcbeETpRz7EZr27qOmgCwy44YsVz7eVIwkPsTYXx/5dJn7c0ZmmxviA7QdWH3MVD7dCwdZYdJaumpLyQVbEh1vppe45g+GZAcCt8quWqnAEZYYsiXT3JO7O9RLNMIc9qUzhZ5YuPXbEWW8o7imK2qvvchd5XaaLosTKVlMWZzwZMwT9P4aZkgj87IklAwt84Cb+6BLzHwZgOQYcqX3/lYFwnsNn/WvmMJS+q2uwglrXaF1sG036A6nn1KtSfroDgUY+iKUMJFtMNJlJe1TDzCKSYAJv5r2CGpsWcwVuxS2OlUyzQDmN8/d++uTtcrZX9UsRaE8cBLkgmB1SrlQMO/sJU0e5iGtKaotjjPMCtGqEPmR5i/1l8nQMXmv42DnUccXCAOrOUfPBth72dF+iafZu9UKsx2oredK3O0+petvyOoDeHcX5LQbGUh0ItB/wkzmf5zpEEFhTnfMuujgA9X4YuQUnmQjGc6POq55tgmkPIQFLARViF3LMPUN7s59/6m/Ij1tEDkeJCKnmWELZiIZiZpGzZPUmQeIfGIU6dq8MEWIqb+h/oeXGNZ0+8gZTzfYRuUqX4wa/2l2OQGdCrvMbm6DWSbNb+i5vK0o+xQeYgjaZGMtJe6bu1aOnMdyrztb+3mFHn/sZJl0TL4OMV37Wf/hwXNjgC9fgBOU3z6XEyyy1t5JycFS4/uMIH4dRBvxkmvEo5CspIJstigRzLgEVOW0Jqk3zyJQhZ6BX0Ps2b3e/P9YXe9TX9NCa1g8AqJu/rZQOzRDjmDu4w8YgECNHKS9wRxCt7kg66yVf9Owf4cI/uBY7Pw/hUqaxIuhYZ++jz0cJAwaByWc+6tZFtCp3T1AjNybEk84y4BChYOh5Sd5/lO4ZVVVwwm1m4ruO0nb4XI11IifJczgahTgd1FU8tzAGdx/IGOnIV6wQQnRCUVFaIzPfadwpcHQo2vvJQVuDFSDPG1XOsZd4nvp7Xus2sV+LCv/4U9Ag329BC5BzZPTEkFc2YTvU76dO4JkFd63TEtAsKjVU7FBIPWPOso7DQxYd3FcsTiSKnh0A6E378whsdUbcGmjkaOp+7UH+DKwWcSGAXVULVArvIlI3cd4+dVJL9oI= 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: 20 Dec 2024 04:44:17.3900 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bdfcfa80-c535-4ff9-b8ae-08dd20b0f649 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: SN1PEPF0002BA4C.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB8464 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: Harry Wentland 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: Alex Hung 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 f3391602a577..665b23900cc0 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -70,6 +70,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 4084a7438032..83a6bd64d48a 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -55,6 +55,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 Fri Dec 20 04:33:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916229 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 5BBBCE7718A for ; Fri, 20 Dec 2024 04:44:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CD82610EEC9; Fri, 20 Dec 2024 04:44:34 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="1IGh8ojw"; dkim-atps=neutral Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2043.outbound.protection.outlook.com [40.107.93.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id A6C1C10EEC9; Fri, 20 Dec 2024 04:44:33 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KAG8f1glcoQgA5aQgAT83+7pKkSEXaC+Ze/uvmP81UMs4J0vFl3klKbj2vk2R59byAvTkSEYvhpWFENwYi53PAA7mT7jHSwalRkZqGKAhEcKd4p/7MnhS93mAlOQhLJ3vqB4qqV2Uet70/LEhJE8mgDeRC2oggfA92GbvwxkUHO9REAp4y33YaCxa3YndtvumXsfZ4HalSoN7YBgR/By6JoIPHwPDLF1Tfl01+VZP5hrZ1dUZ0wK+YqN4ObzmaD0FI0MIdR0yznsyexPaxuSC5vAmjbZ7JTexj/uMvdzprpK9DIk8aPJcZjjLu64ImjVUU8crtxy1qs6EfFA8pvj3w== 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=nwV1+Xib14JnN4GPQnLpapQ73qKLspSiJKceBBLXqu8=; b=b5cDfxjRSpwuY9OOClWo/C0buuNTm1a0PSujCvuk2nIkN/gNJ8CigXUjmYTlj3OX9FtI0bU/kGUIWVByOHjuL21tdv/4oEa1cIkBjOAZp0+sa66ZBLdElI3I5j7UJV8oX+0PH8YLDK7zg/lRuPaV1aeZsQFYlgjo22CDe3+8O6i8lvouw9+R7/P2WmuOD+tL1kYS72cR0crfKPqlfcjLXCads3JTvcVweHLT72rv2S+4RZ9k1g25myJveZptAV6j/a8baUr/TZRp24WgeYgyRqFB7NDa8U3iyf8eA4RTQX9jFG67hVBYb+t7NMWuqFxit1n7VyQMJyecG/8I243QxQ== 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=nwV1+Xib14JnN4GPQnLpapQ73qKLspSiJKceBBLXqu8=; b=1IGh8ojwykfmDMepIq0j97SWhZVO7opUFicsn+BF5EveKrZb/akxK5n+YPbGSuKcPmz4RwQKxka4jdDHHqDCk/D2ZLa+Wbr8eaVhm8W7+nkCf16iPAnNiTqwJ1c6kZwrql0yLHs71kqE3Rg9H528v7Z/+tM/dwAGx+3MQSDFCfg= Received: from SN1PR12CA0101.namprd12.prod.outlook.com (2603:10b6:802:21::36) by MW3PR12MB4393.namprd12.prod.outlook.com (2603:10b6:303:2c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.13; Fri, 20 Dec 2024 04:44:30 +0000 Received: from SN1PEPF0002BA4E.namprd03.prod.outlook.com (2603:10b6:802:21:cafe::49) by SN1PR12CA0101.outlook.office365.com (2603:10b6:802:21::36) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.23 via Frontend Transport; Fri, 20 Dec 2024 04:44:30 +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 SN1PEPF0002BA4E.mail.protection.outlook.com (10.167.242.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:44:29 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:44:28 -0600 From: Alex Hung To: , CC: , , Subject: [V7 32/45] drm/amd/display: Add support for BT.709 and BT.2020 TFs Date: Thu, 19 Dec 2024 21:33:38 -0700 Message-ID: <20241220043410.416867-33-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA4E:EE_|MW3PR12MB4393:EE_ X-MS-Office365-Filtering-Correlation-Id: 0e63f584-07b5-426c-8690-08dd20b0fdc7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: w8tXUjrwZ3dTBnLvJ6f9bY9e9LUFWwOU4HiMYW1P4jh/v7YClBxHbwZzXbYyw3WDp/b9qkxsuOM5HuAna2xwPKmvyHx6IFkYpAfuEw3TqtS/OFwuJ6fNEzQHlc4u3LLhzVv4IHTLeNyXEuMiLFbU+QBEmRfw2hRtyX8NLahnaU8qyyvvxe+1cAf/Szt7KIhy7+qSxcAUXXp0DMPnS+TwYS/5bL+wfJneGOM0RqJnUPKkFoqUSIL8YaDoqRHW/qt5tXjOiDb4cO0mlY5iuY80ejwwDrzbVKkM71lJnYfKVBvN78aqo66OWV87VqXM9Ef+X1kZRynpEudNB7qWJtR5wKdfIZ/0noKG0IGoK0+gnwxBm6jSUNiFh5yMGBItIiNIPeTwxuybeQyFusITn3p8+5zebeyjUc+4mcKOiogbtUl5OPmDWIMOWLk4EJn3ju/j3ynklFMxpWmtYjpa8tbYYMmAwSoOaWQHa0tyO6bHx7LvdWVP2F4DxhFknchf3J6UgtdsJ2mcTEe5fktm65b74uXE7osw9I+pO/xIjngrl7FAIufxJgghMvp6Mao/Xs4LyWLuj6FhtaVzGonjcLZnl5kaqmzSul4oIi2ahpNSF/gufJj2JUAa58Wiwpzj5PlTNQOM/PxcqsEaYOIvx7aS6rVvKNoFoYphBFJoN3rz/kqX037w3dACS0LI1Lo1WeSx7DdwLYB4wZlxD8RE4HmZwgTJFvTJW+7Im9Uu6ByrODrafwGWX955Q4XoYQzeHszW/oxQl9wRxEmEoOZZtQlmJn7dPlfZr/y08xzdksuViovVXHYUaZR62rX7Euw9qyI87VKTToP7QN9BJVQwdS4p0a3aLwHiQqkZVuzGJNlbOo4v40Dmk0ZBzLlsXfpxrnhF5rFW2QgU2bTGjuX0FUf6bU3m6hZbUST+i1vTQEFDNVnhrIdy9o+IfBSJRzidp4zwdHbb6Ly/T8vetuPSsBlfYXQKj/8XQaze90E4YeBW5A3F3jpCLQoP3OxeFEwSQNpYBXoXkNpkNWV3+emGOOoknoePmJtSEspcBaiUPtxfVT0+Ht7niVN8EvKRNO2FTg9XeXl4wu9XQJrPnhlyUdGPsEOtq+pRPenVSRHzsXleRY6FR35dJtZHnXCbkKMLO4CovDqwRzH0UtLPlPbR6+93+XKJsCG/oMMdIkmX72nz2Y344IyBQGUGvQPFqmecmXjSKRnMtLNqQnYgNL8V3Cmc9sDx3MRoxw9scxZ1qSLAP001vMvbMbeFU7koFViD5gFaihZxLfreHbfu6RGalBNxULIx1lHBM+O7L9l7m+4SIvSmRezltkcgbWZxXVM+t2NvmEmfqbovMAcY+OnQRyVTDfYCPs/8+d9OXuzmDlP3IT4JOtlzIpH0qs5Z70r1VAcN8LAx4yN+MBIZpaJwHPImc4K7AIw+PPWm7TYeb5kJE3xy7hISWhvHwEDYzPr3ok9z0UVMhjEKbx3epGZNmqnm4+G3AbYHbTm62OT4pyqRPvY= 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)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2024 04:44:29.9741 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0e63f584-07b5-426c-8690-08dd20b0fdc7 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: SN1PEPF0002BA4E.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4393 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: Harry Wentland 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: Alex Hung 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 63044e0296cb..1765402bc122 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 @@ -676,6 +676,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; @@ -1284,8 +1287,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 = 0; - 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) { @@ -1321,7 +1326,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 a9d94018a207..ff5828a1e8cd 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 Fri Dec 20 04:33:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916230 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 1433DE7718B for ; Fri, 20 Dec 2024 04:44:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 53A9610EED5; Fri, 20 Dec 2024 04:44:48 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="YTgdjVBo"; dkim-atps=neutral Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2060f.outbound.protection.outlook.com [IPv6:2a01:111:f403:2412::60f]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0FC0A10EED3; Fri, 20 Dec 2024 04:44:47 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sTR93kyw/vKvUJgKl+6QnGZ5Tp6ihv0HfiHN5KIyp0DhXPHh1o1+vV9LD86i9dfWDESt700aDlZO7IyeRzfMN19YcaYPAPznTQqu7BWY5eJxQQZrZTVs+g9OvIum4urn+jjGuqe5PMSvMnab3QddzTYrUnohTNncHjE/ItFK2syS8cNhevS6KvMI7oy+o1krP88NNqMUk3wKy+lYzHVof8Bf0tkaHZUi0bSLf6WK07A7MZd942cdR6vmKO6pz0+J3l1Pm89dhYvD1z+MCvjh6J+wKt+ULeWR6KFRLLUdeCPDT9vC0bgU0RC3DKUIqlRHxlviUSo4kklCm6dom8xGcg== 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=kN+TiFXjETLY6xdrjA8qjF7ilcwj6A8EY6evhmIv9Fc=; b=IFW2HjwLj3tGMyfmXr4aFp1RHy1XBOyFM2NCqRMsQ9Dkc1nSzioWkIlqGAQw1IC/7OWsGpm1BdOx+UxspFC9NT8oxjlMNRrpCF0vIe4kNbUs7MoFcvlGiRaOZ/dmVTK12JJTCCqYk21hapCd+b9prQuSCKKw82lxMIOaGAzgTLnbiGRI/Dy+n+nD94MeTZEkI/ZAZlDOmM5SnaChtWG2gxypbRaFWPeoHqR7ldsLgE9gnlw0vxx+MJFzGdNlrmJ+2CS4J8dDjaFOHSdoCBQN3NYh8d5JdXHAsnlcebEqrHt7ot8r0dzHTSApQz+Q4ZDM2bEeXZpNqpC+0mmrzRGFgA== 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=kN+TiFXjETLY6xdrjA8qjF7ilcwj6A8EY6evhmIv9Fc=; b=YTgdjVBon3pJm0aWviYtrYL7fb4SxAZHSorQZWLUFl2kZTQEyOGPMaFlvlgmwm/gmjt2i9ssEKCEvzHhl6A84ncc18ZKYWBBIaPaSSs78/iuhQJ2XeUj+3P2b4ppnJ20eT0jL7tRJMJ3w1Cp7j5bR9FxxhLxWUjJEKTSr+mq8ys= Received: from SA1P222CA0131.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:3c2::12) by SJ1PR12MB6217.namprd12.prod.outlook.com (2603:10b6:a03:458::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.15; Fri, 20 Dec 2024 04:44:42 +0000 Received: from SN1PEPF0002BA50.namprd03.prod.outlook.com (2603:10b6:806:3c2:cafe::70) by SA1P222CA0131.outlook.office365.com (2603:10b6:806:3c2::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.25 via Frontend Transport; Fri, 20 Dec 2024 04:44: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 SN1PEPF0002BA50.mail.protection.outlook.com (10.167.242.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:44:42 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:44:41 -0600 From: Alex Hung To: , CC: , , Subject: [V7 33/45] drm/colorop: Add 1D Curve Custom LUT type Date: Thu, 19 Dec 2024 21:33:39 -0700 Message-ID: <20241220043410.416867-34-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA50:EE_|SJ1PR12MB6217:EE_ X-MS-Office365-Filtering-Correlation-Id: 465012c6-37e3-472d-ff10-08dd20b1054b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: TBYBmQhQhIbCsBQrFNC4YmBuIo0i8FbWo+l3EzggHnRHYQNkALQ2uSrU43YlW9/qPXfa9zSzcCirsNUBoeUkPY7tFdNtULfcRH0N09KYEmqpqUB7DcJ/FY/2ZFT9JNP9AI6ObYdB5yCPhPILTCxjpYEVm5KKP0OgUpCf2773qGQCZaA4hmBQUE4G8Ap9Q2+fHscrxv6pZO1XvuF6jEhO+rn/l6PhKxb+9zxY9hb8+geTtXYYxgCkx3cgwqiloDWf+BMZfxqhhxWyTuc/hYVpypSuA2ugnvofoV2KY4k2u0klHvLaL2zfwSVp6p/kuRjAzfwSp3BKYkeGbVuQRjjeWC1wBDwoKLvYqsumG0E32mPoPiDLDZViwO6m0UXSisv0x16jnKFbj2CaC3Gu1236cVRgWLmDim6qG4Zn9n1vVIlehPs0UU2E5cvtomInIRmGuxBfiT6Oa3GvRus0WtejdQw3w9gFF0lmAr6PFv9PTvyjrDdwJNeSk7BxDaXzh6sxapGmF90ugOolNiBaZ0ZU0bCeeqHXZRe0520nhNCI5m9I/PnGJl0oMXZg8r196Gt32m5N09Yyf0kQw9Nwxj5IEJQTxBa38zfbsdIoF/bL7j0K9xjeJ/ITaOvTGzAnwEk1vMKi7PP5tmU2cO996IoEIsJrrskkf1Y88ulX14WTi6dvQn/sB7VxMvjSy8T2eoiWbCk6Bn5YrhswfwiNizwomNjMdOY4l7GccQV/Xd7/zz/4ZDyb6dGYX8PE+sNSIWS/JLbqLQRmBdmZ+W4cARVzF6uS+pO50UCyp7I5EXVLR8FUAt+bYM3fPt42X32DAipxGtbpNot0yCUqCHZwx/Ye3nfWDnqCgQ6bq7CHq7x6B48mka2dO/HNn7RvjZXPewmJH8uG3p7eRb38r0x3NjtXACQ7F7N+5WyYMi+ukX5hKUWSr83rxSaifwfo3DMfizMA5yIutub8pATtUhsI+gT6OxJF0UEWm+kXyxSc6oMPSHOAOeJPzeOHtFusdHssG6/Gxkgi3Wv+O6usefHMfdFSAtle7R8B3yrzTbqHEoHYAXbwlzzeAP5Bd4y85aH/ntaCOwXgzZcTOzzcFEP6H0/EzYK+0gk4cMhj0N8LFPWsVD/vorWGwD+pw2TKvsy+jlFJPhkydZcLBne4yto7+8SQ3Zcfa24qhuOgxWtI8kVRGf2Rt9UjRsGDRrb3QjpAedQgXFWKgrxCc3C5v96rvfdAHTa8KI27tDCdn5SwO0F/VSrifcXkkFJVCPWIq9LFALcJqJqbUqFIYA8d4Zk/1KfiK90qIEGGSe9cGeUYy+JiVPjiE3EayYzuvlVoovX4agCTQVrSoZtwATWqGTDNSoLgqac+Zvs+PIgsGwOWidZCnzgaXoJA5gg85vJ4dNoLKVSENJWf/8gAlYVCZ5vJiCm+Kqc7To9oGCVj/Ct6Zj2Rqroy7VX8JF65q07WL0fqEV0pxjCHE/HHDulXLWoTeqyljF5uuUA73TKQX/KdclGb0yM= 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)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2024 04:44:42.5864 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 465012c6-37e3-472d-ff10-08dd20b1054b 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: SN1PEPF0002BA50.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6217 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'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 Co-developed-by: Harry Wentland Signed-off-by: Harry Wentland --- v7: - Change "size" to "lut_size" (this affects multiple following commits) - Move "lut_size" from drm_colorop_state to drm_colorop - Modify other files accordingly (i.e. from drm_colorop_state->size to drm_colorop->lut_size) 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(-) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index c58663327e6b..b7a05132ee01 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", colorop->lut_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 a3e1fcad47ad..4744c12e429d 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -701,6 +701,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 = colorop->lut_size * sizeof(struct drm_color_lut); + break; case DRM_COLOROP_CTM_3X4: size = sizeof(struct drm_color_ctm_3x4); break; @@ -750,6 +753,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->lut_size_property) { + *val = colorop->lut_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 665b23900cc0..e6dea2713490 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -64,6 +64,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"} }; @@ -219,11 +220,52 @@ 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->lut_size_property = prop; + drm_object_attach_property(&colorop->base, colorop->lut_size_property, lut_size); + colorop->lut_size = lut_size; + + /* data */ + ret = drm_colorop_create_data_prop(dev, colorop); + if (ret) + return ret; + + drm_colorop_reset(colorop); 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) @@ -333,6 +375,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 83a6bd64d48a..d3226ab7e1e3 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -239,6 +239,13 @@ struct drm_colorop { */ struct drm_property *bypass_property; + /** + * @lut_size: + * + * Number of entries of the custom LUT. This should be read-only. + */ + uint32_t lut_size; + /** * @curve_1d_type_property: * @@ -246,6 +253,13 @@ struct drm_colorop { */ struct drm_property *curve_1d_type_property; + /** + * @lut_size_property: + * + * Size property for custom LUT from userspace. + */ + struct drm_property *lut_size_property; + /** * @data_property: * @@ -293,6 +307,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 Fri Dec 20 04:33:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916231 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 1674DE7718B for ; Fri, 20 Dec 2024 04:45:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 79EBF10EED8; Fri, 20 Dec 2024 04:45:05 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="0M2CVyzK"; dkim-atps=neutral Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2061.outbound.protection.outlook.com [40.107.93.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id 23B9910EED7; Fri, 20 Dec 2024 04:45:04 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=O5bzN7HXmZrIxQpuFgurYSBYjryLAvqD7qBfF+ncVVbl8yFMKPJG+eN9WTjlaJLCEOiJV0Zr27lps577R5DXKXHcKXh6bfcSH3WqLFLRgelBoKiSVY3+TYkuOXpdMxgc8QALdLPGxazJLAdK7VYAPp0KZ7TYexb7BfTXBq0LdGFVzfiEvQ6iIiKeWz9bzQfAEoFY+tPImXXyiFtGEQEFwUTJbyFAL/As3o6kY/kdwUXvGcVvc8vJkoKGPULVHjWdUedZW0YIbXPbCD8oLAf0NkYgBq7vMeikaUXtPRRfRxzmPN57R3UJK+oZl+6xmMF+avOB9ugW9IMW5bWdrWy43Q== 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=da/zUieZnLY14gUIZxDh/TFrefLzBf6gqkgmbQG/lPo=; b=r4gzz3ncvGB79bXzo8PQFROcaYkz/fTArbXdB94eWQmIle+ZB2hvABWWfOERoHBmJOLLyGV+eRa4HL0OZ7F4lfHUuUv6sbIX/QKeNKMXplegruKWBureJxqNx5Nq8sDbzO4zg32oS7KBh+EXBWTdoU40tQxjdjP057Wwu6KBb0m0ECKBZPSvcaWOo4IYQuUqfj3GXk7W7HdC3uioYgQ1dtJmuh16jFje6iylBi6oSLkt0XALnKU4aNx6AUwvo0xz/9pGRn4oPvvUCJRy1C0sEhAffgpA1ThZ/ohWd46J00IL7A8ZGH72zjtLYbhj94tjs5s0Et3vRWQbJztiJ4rA/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=da/zUieZnLY14gUIZxDh/TFrefLzBf6gqkgmbQG/lPo=; b=0M2CVyzKFohtzV37Bx5H+DgR5Q1cclr0OvijdHmxq5x4BRm0goqzeJpY9FcC51D0rHuWX1OgV2MEKFFMdJwAoZ0M9IrAsJfOu+kqQcNkp0cmE6dapz+7nrMsuatAdERloRbSJFYAXLhV+lPqKJXin5L2V0iSKAzcYFKb0PH0rOg= Received: from BYAPR05CA0074.namprd05.prod.outlook.com (2603:10b6:a03:e0::15) by SJ2PR12MB8848.namprd12.prod.outlook.com (2603:10b6:a03:537::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.16; Fri, 20 Dec 2024 04:44:56 +0000 Received: from SJ5PEPF000001CA.namprd05.prod.outlook.com (2603:10b6:a03:e0:cafe::bc) by BYAPR05CA0074.outlook.office365.com (2603:10b6:a03:e0::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8272.13 via Frontend Transport; Fri, 20 Dec 2024 04:44: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 SJ5PEPF000001CA.mail.protection.outlook.com (10.167.242.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:44:55 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:44:53 -0600 From: Alex Hung To: , CC: , , Subject: [V7 34/45] drm/amd/display: add shaper and blend colorops for 1D Curve Custom LUT Date: Thu, 19 Dec 2024 21:33:40 -0700 Message-ID: <20241220043410.416867-35-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001CA:EE_|SJ2PR12MB8848:EE_ X-MS-Office365-Filtering-Correlation-Id: 7ee64cd4-66ce-4859-5ace-08dd20b10d59 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: /qFHyWcfZ4JhOOLW7Rk9n4ayZd9ntYnXHw29pTSSdpkfs4GjuzXQUr+MGJ1wxoCuwMMxtihyDbKS1orxzIkvnojtEZsQA9KHZGN7FaQd9f2yQ5ykpcNqNCrpHDUVq+VpCGMJtysgmmgXIiSqnRFRiGMiikH5Tq54YYeO9mpiGAqtBPjVxgcizAtNDlJ4ekfrrpbXN/Sb3RpKLbCs7fNyqrszsYwRwGR2bkaB6vfl/6luwfOH/qSGWNsPNwTuCXWh0iHHXkm4IzOXY9y5KOBTMiqBtI1xOnpvPBstbxf9GKpbwu5DoDS1ktAKJQ5SkIWjeNH/RJfZkQOW0QSSADzEk7Y6TM65+kr/bpIBr/TcaqyKKoW2cw+ocupJz+UaWa6d98tQhT9BmhE5S8x2tVKz+wNJLQ7I6DF0M026o6Pwarha39kCTJx09AHNMRZC1QMn71XE2fVF0RFWTOiRVBx7qtTXGZD7NR9O8CDZbaq+aXpsHZdlGq3It54gwsL1wW6qt6et9VoII0VxXS+dL+zaZDugf1HiLnmoz5f7TpXH5BkOOQ/ZH59hcmMuLtOB4QAr+P8pPcYrPGStAiSbGaJR5VZStgI0X+8gFmKLq2AJW8futW7GyW2aIyqUFR+ti3jXl5Kr4NjhzL4DRhpejVP/LEiU4oc1I+rBjvZPRDJgv25RVhtpk9oJNzaRelqcbzHWk56dOdUWtQFsoL0VH+lSoURA1JHCllgq110JXATsGHXHsln+Z5OdJ14kYVYgQzu+asf2I9n7rOXfKtzoCSUF7mm4mrbKJf/5qnp9vhuA1IYgGLvJpX3R9KqF32ghrU7Q1URJzEaXi3VZ8dge+Rn/sIMGxSU2oZ5lbTvtqVcH/QB+7G7lKC2CQzlq4yeF1M4WWcAFV2flHb1ZVQu2zTrC3ERyePr7ZjEF4/hYTq1akksqgegQplAR9wHo6pxyAobtvAjXbm50NxYjn6svvkQEVLT+qAN7QREwh8vjYV5P57YI2P+D+ymUXRmn76r+5IDwaEIG8/AYET/d1xl2Nqi+7gfGJHljfdGjGAgcDvM/6RwfWKXpUbfSbKpWTtaHdWbO+0paZSRMGyHAf4yaHlhAVYIJQld9rPHgtkjY3bqSFrytVcWDMww6dg7TlWkAYo3PvZt6QIsJIhKeFa6/1/wwkXbCE2y8ouysp3qNPMUjmskyTXpdi2ZdxXrToRrTFUbjJ++dWJsUUnC7EBSuj8jUQblFIzF+L+zzYvxZeGnkIq34LTGyMmPejPpQ4oYp8+7DwEJho4+cmg41lkcZ5ciXQqzbcbnT3Mw6deLHyYU7NM8rmLPXANXD9LYAWWTSvhHsjtJDYH6YnaVHq70+JW65vNiavxNqOI85FGmlIfcE4/pe5bOUNER+HcmwpYRS9Qr6kxMuDpowFiVKlH4ft1jS+fXYfEyWwEjZ+QsRL58qeB/A517Y4Tud8TFzchUVNFmVK3MwcTxyg/UQyMZadACAlypEPlUdI15FJDlXMFk4fss= 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)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2024 04:44:55.9707 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7ee64cd4-66ce-4859-5ace-08dd20b10d59 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: SJ5PEPF000001CA.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8848 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 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 --- v7: - Initialize uint32_t blend_size = 0 by default (kernel test robot) - Modify state->size to colorop->lut_size .../amd/display/amdgpu_dm/amdgpu_dm_color.c | 166 ++++++++++-------- .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 32 ++++ 2 files changed, 120 insertions(+), 78 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 1765402bc122..0bea52eede39 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 @@ -1211,38 +1211,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, @@ -1251,64 +1219,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) { - 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 = 0; - - if (colorop->type != DRM_COLOROP_1D_CURVE) - return -EINVAL; + 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); + } - if (!(BIT(colorop_state->curve_1d_type) & amdgpu_dm_supported_blnd_tfs)) + /* 1D LUT - SHAPER LUT */ + colorop = old_colorop->next; + if (!colorop) { + drm_dbg(dev, "no Shaper LUT colorop found\n"); 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); + 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->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->lut_size) + __set_output_tf(tf, shaper_lut, shaper_size, false); } - return -EINVAL; + return 0; } static int @@ -1319,28 +1284,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 (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); + } - if (new_colorop_state->colorop == old_colorop) { + /* 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; + + /* Custom LUT size must be the same as supported size */ + if (blend_size == colorop->lut_size) + __set_input_tf(NULL, tf, blend_lut, blend_size); + } - return __set_colorop_1d_curve_blend_tf_lut(dc_plane_state, colorop_state); + return 0; } static int @@ -1409,7 +1409,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"); @@ -1420,7 +1420,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"); @@ -1431,6 +1436,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 ff5828a1e8cd..8a5e15083f11 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 Fri Dec 20 04:33:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916232 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 302DCE7718B for ; Fri, 20 Dec 2024 04:45:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9A97410EEDE; Fri, 20 Dec 2024 04:45:14 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="jFfxhl5y"; dkim-atps=neutral Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2089.outbound.protection.outlook.com [40.107.94.89]) by gabe.freedesktop.org (Postfix) with ESMTPS id A5C1610EEDA; Fri, 20 Dec 2024 04:45:13 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MO9WwDk/JF1p2qrmVCABvpGcO8riwd7Rl8R+GNZkUsKFBXBseWSO8bkXz6CggoeaikywTlF2MH+JTlk2cLCo0u6HhmkyLZuYs2gmP7x8TL7Cpzx/DV5Om83yr0GXsh5tXMrpce0PFj32FXrX3YAm/3EX3z91Vf0govIPqcy4I4v+Sq6+PDk01N6v1uQEYnpgWyW8vHktj/6+LuraTVyrZ1gYmeyifMcPcBUVdKtEWhqchHmRiZVp5k9rUD5do/6tPy001uyJMo6hnWGdBuUC77mEOofXnpz7tbv/JBa4Wf6Ucn+w3MVPysIMcn9ZpSMj2eRLCoxboKVvIMJb7OHoZg== 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=Cq8d+oOWD0gIDdZxqe6mfqa34vB0oF6zp6+Nh6IMxeA=; b=mAQmpWm9qVgi/RFHXdEjt374PQkZ2h3MZ8WxR9jg6lPc0PetzxvvcUtb12QphqxqsjTVnf308IznzjMpQVL7GqgYsilbE1AbYqHMqSR9N4lj8MaBieUw9xuMEDWfq8okM+eszFfo1KNBaqhl1c/tAtkKyGh2Uvh5SnPdcpaB+rKprOBXDgSNPJSw8dcAxKjbc2pe/WrVFyeXEV6KAlxfO7+ZipC6lJTYHwWGIwz3FAWogdkDKYzH0ULsBp7/zig0kMk0tejw1rhJ9OkaR/E2w57kZGxmFIwxYUNkmL/094HxGYSdxCYSyv/9huwBhMqrLZZARaH3XT7RqER8Sw8IwQ== 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=Cq8d+oOWD0gIDdZxqe6mfqa34vB0oF6zp6+Nh6IMxeA=; b=jFfxhl5ydW41pPKpJ338RjiEgQmd7sOXuBmRy38ZpxNwldEf4dQj8HQcM7Xy8BK5gcKvJC28lxMDbsydBbJ75FHKUYhY18BeKtC7sFezlaxKHZAGdBuslBaWxSVPbiyWkPkcRwBCnb3yAIA9hFDPcK7C1uYcdWVtFf1wp1Ttir8= Received: from MW4PR04CA0039.namprd04.prod.outlook.com (2603:10b6:303:6a::14) by SJ2PR12MB8830.namprd12.prod.outlook.com (2603:10b6:a03:4d0::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.16; Fri, 20 Dec 2024 04:45:08 +0000 Received: from SJ5PEPF000001C8.namprd05.prod.outlook.com (2603:10b6:303:6a:cafe::89) by MW4PR04CA0039.outlook.office365.com (2603:10b6:303:6a::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.23 via Frontend Transport; Fri, 20 Dec 2024 04:45: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 SJ5PEPF000001C8.mail.protection.outlook.com (10.167.242.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:45:08 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:45:06 -0600 From: Alex Hung To: , CC: , , Subject: [V7 35/45] drm/amd/display: add 3x4 matrix colorop Date: Thu, 19 Dec 2024 21:33:41 -0700 Message-ID: <20241220043410.416867-36-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001C8:EE_|SJ2PR12MB8830:EE_ X-MS-Office365-Filtering-Correlation-Id: ae0ae626-4291-43e1-de7b-08dd20b114aa 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: qNxhQNLlU4ap3aLIimAhm76UrYX4wKqAQJNi+dydsGIJtuu3GqGxLl+pMz++L09GYRLycGwVUJRL+f86552WW+e2hbUikcb4XfsZg+meWqHTPeL9YNT294bp7QaB2QeLxtG532AFWkdUnbO5uXy2lrzP2Mhe/UHX+8fBzN0TrrXF2gBPIQEKwsBKb1pNwvRMwiHEQFr4rvK4MFZfhQVmSP/2ARnXBrtCa+c8y3pLlZ7RWX8C3I/g8bk6Y68zfd0BPGZ/Ctj8djg9orGR8GphFpkfs9LalHERnJ4IURFsxyUlyKXwVvkJsEubt1bHFY9AZg4z45rVAFxsi7vI/vJVTlstSmTM3TtY6Puv/DAiLXSupLt93T71mvrxJXSO6u+7uTjyNM/o5kZl6bFe1ONlkMVatTEKGizxs+YuJwomCACzCbFH+fcMOag5b9bKLDR8li5u+2uDWukvJ1E201IrLPVCNQxS24rU3TsRQIUYh2b5dLBVZ4e+ztO3oxCIfjXDMpxhWbMeWVyHpjCKG3j/BOVucOV1vWxIcjEyb7034rg8v1R1EYrTIYgrcRXE8+UQ2GKKby24wnQlJWJDGBr8EFVxMNzr1yQVnmdCdJyP2zrHLXSz9Cq+7u8zugjhQMv4upxEf1c+qGeh+Xex6a47K0YQEpflS9tVA6XT0gPDG5qr+L22vwtI+0Tw5M16NyRoosKfGPtovq8uSZfODszUl9NH2XUemVeb5zcU+8lZXLRwpMMz3lWH7k1nYjBB5Ncs+Xz3V22lWmKi+HHyb95kR476+DQ7rgt0JjzWAcprklJ8hbq65qsGZ6RT9PfRxPKdgfnq4RpadUMeCFhSS4QDgfB6C+NMrQvdJXxfeSTWPv46Zk4ElS1EIMKJTASDkvG60GWWyFEK8uds8VqC6ks7Ti2a9lriodQcs14xRPuYoA6hc4AILdq9iFSizOkE4TMOK0bbwkxlk8dJutvyZ23cr1eZv8u2mG8c9FWMxgP7mHzbcdkkFAs/u2OI6XiNgdBcqKb1GvBOM6DgBlhVS16H+xTWgdeUNzSHfOX6EhF24yFCQZBPRiRx9D4VIc8wXqiRj7fX69FH6qHEB/dJQeYP8RHb3BZAM91c3qdCmxyWF+ljakA/a8AnF76ld0ejJFR+fE0cwwl+z8Jm5E1TTIAuxcnXYN6eOtxE5BGJJ41IsVMqrYj3aedZYq6cTe8ql1OPQ6NUFsHsFPu5Es6MaP3ecBiQH4eCYWLq37N2IyUmeJDUS/BkgOKb0y2e9dtgA9OFruRPRqRNshvpqqrZLQo9p1qZqzz2cIqMVcdfM4Xsgu4UaSjTiIQ+oSW1ukf1gHwjMiL0ZiRuf6l2dSVArBAwicE2mhlKl0Ia+oAeD8pUECrmX8ExsDuxpCWyLTnwpPmn44F24biymZgkN7OWh/Xb8zY2hNDb9cFgo1SoKPUSrw6GbxTxtSIheAgjkFkTWco65+VwYC0L7jBAbrIr75ksn5RUPn8xvaLYAE2Lwlotc94= 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: 20 Dec 2024 04:45:08.2958 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ae0ae626-4291-43e1-de7b-08dd20b114aa 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: SJ5PEPF000001C8.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8830 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 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 --- v7: - Change %lu to %zu for sizeof() when In drm_warn 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(+) 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 0bea52eede39..5d6effe6f90e 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 @@ -1211,6 +1211,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 (%zu)\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, @@ -1409,6 +1448,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 8a5e15083f11..9a9386bf85ec 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 Fri Dec 20 04:33:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916233 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 41F37E77188 for ; Fri, 20 Dec 2024 04:45:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A5AD710EEDD; Fri, 20 Dec 2024 04:45:52 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="z3Gl5cSA"; dkim-atps=neutral Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2060e.outbound.protection.outlook.com [IPv6:2a01:111:f403:2406::60e]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7520010EEDD; Fri, 20 Dec 2024 04:45:51 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dp2qi9rqJSTkaIixswVBKIB8h+j16B4E8IrGMsMRjpDxe8qX7YuFSAZ1DDaNwk8VMRevBjZuS/jwsRA/p2Ngxe8G/5hpYSxrgyq6lR7t4PjypWTRmHJ5DBrZ1dJxm/Z+QM5FZeBbYw+6+Gt0IpsZcm9WAQ4Bu3g2G9xtUHvzW/PIuDb6Cx1MqG9REIkCefX0nptCWum7hpkX7QwbL4P4e+pKZWfIxnT1jihJXMgu3Job+x9FmQ0I+BOvom/oSWelqQXwTdjvfqKrIFZygog3FtX8t7AtX/el2lP4GKrOz8d2QLsWpd1wW+LImwUHaEye8IuA/OcA4ddrfT/WcCOC/A== 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=HXFY0nPGTeUNXRHwQoeAcILblw+4jAF5lmZnDoNZ88M=; b=B/zJBc4IsVqnOah5kNVdnWm3wkgV17HdEbrZmSdJ8MANX/5WCQoNo5S8dh7elZwkHxpsMzDULNBnykqsVSiCfx0cwIzh/icSh+mQ6sIpnu4Kigtw/LT2zZ5341i9Q1LZB7ti6jVIvcFLayckdqSNJKeDx8a7LMd9Y/hmC/ke5j9UFZu6DPzTQK9/QdaVR9udcLnVQsHV4WElNAysSyUo1N5mbi9kJhgJC/8MTL3EkNHLf3pnBd/RbWGMZJCa/rb5rR3K0SewiMiGHsQ4NNNowVBbPWvDCB2pp3VLYdGnMcNWEp5DnBexTye71+epqAUWoCWp/f4tQM1zwaRR5viY6Q== 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=HXFY0nPGTeUNXRHwQoeAcILblw+4jAF5lmZnDoNZ88M=; b=z3Gl5cSAfa8AXKE1PXFJhqP9QWHmKD6qVjv7OO50uzbEosLE/zWWQyknizMIgQno/R0UaWfOPd87sKw4TyRi0vBhbwkmJVrN3l4csFfNZEqoj1nq6c+Lkl9CqmTuWZnf8ZXWFUwtvqZ9HhML0iJXObuIVZ+Uk8RdvWwTxIvUfXI= Received: from SJ0PR03CA0023.namprd03.prod.outlook.com (2603:10b6:a03:33a::28) by SN7PR12MB7909.namprd12.prod.outlook.com (2603:10b6:806:340::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.16; Fri, 20 Dec 2024 04:45:42 +0000 Received: from SJ5PEPF000001CF.namprd05.prod.outlook.com (2603:10b6:a03:33a:cafe::2c) by SJ0PR03CA0023.outlook.office365.com (2603:10b6:a03:33a::28) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.22 via Frontend Transport; Fri, 20 Dec 2024 04:45: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 SJ5PEPF000001CF.mail.protection.outlook.com (10.167.242.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:45:41 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:45:19 -0600 From: Alex Hung To: , CC: , , Subject: [V7 36/45] drm/colorop: Add mutliplier type Date: Thu, 19 Dec 2024 21:33:42 -0700 Message-ID: <20241220043410.416867-37-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001CF:EE_|SN7PR12MB7909:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e29aaab-1985-4598-fa6a-08dd20b128a9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: L6MKfsdtmukmKqfvHzED/EbCiT1IMSwLxJUJFq1Iiq8ykWHcPstda3815o/zMIgKRMs/AVheR5iokBhVpStjufuZs6/yk7/SRa/y4j+gbIoihgkEjY+6vW9KiUPaazpYNQDiXS/wSHzOEirI9YxgycmhMDXeZgioyhm902b6XWlGk0mazGzqLqEJgKWf/XAg8HMjJDdiKBFE+PSylpqJ/Ek4inv+X1gvLs2C50Z2D9Bg4qXVYmG2C1mD7VRtGBZNQpP4+wA6YNXGFbVVgJj6CYD1NmGnb/BzILbnEAJYB7ck8ae6tu+Lc/hV3Bu88WMdnDB7P85Vov8KNlNjxCZnh8+dkbTog0AlIewTxA2PKTaVOxcesYC/GpGWJlm/J4D4UMa5l4uhOaeo6pJN6f/2vm8umqoE4/iaY+YGZaiCMVwJdHit3yW/jOp3xV11WnJrg13RMahXM+pRSvsJBL6xi3lAiwhqep8rn3ymESO1kmXsZ8aRHagctR8ARXVUQeL1TCe2/lFzQL7ibK/0Bd/cvY6sOMbItE8eDhnfPQuz9/NNuBf71SLEMcoogjdzPD+CsLWNP/ZkYArCPp0J6WWpnrPalPPymZUEB2srBum+zlWJnNAYVIYmjRnx5m52Pp0ylkH0D5wklYRJmH7M5FxGdq5brvgsdZckp3vtU4/JbPZlXl+e/sHSSDO67DRKhNWZc2w3S1VtEOmLTrT6Rm8bpLN2swB/4xJaNwGszFt0DZAlvWQtW8Q3DZ2vb1BSJ9XZ9w2MnG7oIz+Boe4fEZ5o/K/LalmPYvKC4XDfgDd8P6ZM6EAKpvTf+wYgw/NRpAuwNvGIhhLKoCtiQGNIgIELpaP3z50EP7MeHT2hdLvPZ589onBELCUipgI861b7QLaZmclyFWYozsvHyFl75xYntCSH6blN8a+sFlkb2Yn3fwOOmhfxED3Aez3fE1TlmDMQyWzInVfRI/hgOmbrXMoRiNn4JmZdwBKwb8oOBHWDFcFe9aM3orFw1Sa3kZO2mGP/H6cUklj0Rs9Tm4X/nSbHSH7lsMjsjaPu9JkHbnBpveq6eiu+YDjRphX4KTeCNSKi+GE79sgZYXjwicfZMj2tQD/hdkFAL82s8IkIkTJkvnLThxYSrNTDqz0ZfO24yOQKjQ1WGGgspSW4Chm457VJdncpxQRY1Ts54UvnBYQn7sfoAgkn5x5E04nini6ihZJkXWvHdfLHzr3SBwZhWkEbdW8xKhnkBDOVpP/4uf+wHOMirlZK/BoqpcutYJEW3OrwbVOFmBy2p7Wczy9UObC8WRgs2JGSuVlglch/+zOzHMVwwjA91uc/VPfC/sb1Af9FihCHTp/VKJ/iueduKB7zbaZbw9iPrejiosxHVoKsPpui76rLH7P472/SzWIeQjfkwLPkChGYly8oju2hxFOkjIVW7TC/BXQ6PMJO4utgbcEswkx/GuJQ0WPy7KwtMIonHdxHCfI4oRS80ExqmxzE2Bw11LcbByPRhNqM3biNOm0= 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)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2024 04:45:41.8444 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7e29aaab-1985-4598-fa6a-08dd20b128a9 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: SJ5PEPF000001CF.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7909 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 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 --- v7: - Modify size_property to lut_size_property 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 b7a05132ee01..1fa6818794d6 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 4744c12e429d..3c815a2a8d9d 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -728,6 +728,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); @@ -753,6 +755,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->lut_size_property) { *val = colorop->lut_size; } else if (property == colorop->data_property) { diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c index e6dea2713490..9fbfb2b89b1b 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -65,7 +65,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[] = { @@ -286,6 +287,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) { @@ -376,7 +408,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 d3226ab7e1e3..d84f457a2b65 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -134,6 +134,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; + /** * @data: * @@ -253,6 +260,13 @@ struct drm_colorop { */ struct drm_property *curve_1d_type_property; + /** + * @multiplier_property: + * + * Multiplier property for plane gain + */ + struct drm_property *multiplier_property; + /** * @lut_size_property: * @@ -311,6 +325,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 Fri Dec 20 04:33:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916234 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 C612CE7718B for ; Fri, 20 Dec 2024 04:46:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A7DEE10EEE6; Fri, 20 Dec 2024 04:46:01 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="4EhChwY0"; dkim-atps=neutral Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2067.outbound.protection.outlook.com [40.107.96.67]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1E2DE10EEE3; Fri, 20 Dec 2024 04:46:00 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UZYe07jDW0OpKrcf0o0GJAioCyOU1GipKshNlaeRjr/6A0rFNz0q9xMHs1afc6OR8RI85QoqlzbQlLk8v4kNvaW0VZtb0eJJqn1kFywuXUXWSJb7oCk4Dmz/4NOgnPTeJB/npWPXB47lcHje7Ld3XEK6bo8lZYKroh7LM4VAqOJZTntHpE61SZ1kR0GGG1iKnpOyIiDcneqrS18vy7l/plja3FmTiG2tEqKEOh4rT/MCBISrDWA1lRqNY6ExNyzPipMeI37g7IGF0L3iKAjivuebGKS2eALa792S80x05ywLZSBCtG9Ni6BVCO13UwOzLpbQW5GtQ+txMKkAmv1Wxw== 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=jHQznEUEWnnBjCNLDldm1K155HkEcknI6BDyuVO9eh4=; b=t7f4rgnlPENwP7iNk1/NUrv630swL4dAaNygVvauXNjNkybC2QxICacWX2JuYdPqN+ofV4C5WTe+YTTJF6zU9ITxz75vfAN8CsCriSWspqbceC2GSx41Cq7kj52sPe7TDNg7uTCuthct/m/+YDq92EcaEavTUmLl9GH5vVIGO9ek2naQ+/GsA78xBfrK/lDQe7OKIgLNGPkO7EyT/U8hU/2TEGZ2oVu2b27TSRGAoaZ3gxOTRgjY8i1aoVGMb7OOBGMxSxx6mCTRDi9h1mpme5k8dtJV9CHiPJttCTdpfQwYVl+GonwkC/I47/ICHcqs7+C4h9amMsiKY+Gp7x6NrA== 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=jHQznEUEWnnBjCNLDldm1K155HkEcknI6BDyuVO9eh4=; b=4EhChwY0yDNxP/HdOUQ2yF4Ju+tmZgzHa8aeJiUsW8gt8SFgatBAQAeElJgk0i8h6cmAFJnrH9OrukEO1QVWytRVSAFdeos+c8GGcy7vM17LzIOcrPmfzfuPUbcpTOhGgGYQPAS2dwJOWJB3E8a6xnkTg7dw1n/kDsBCG/msfuA= Received: from SJ0PR05CA0079.namprd05.prod.outlook.com (2603:10b6:a03:332::24) by SA0PR12MB4447.namprd12.prod.outlook.com (2603:10b6:806:9b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.16; Fri, 20 Dec 2024 04:45:57 +0000 Received: from SJ5PEPF000001CB.namprd05.prod.outlook.com (2603:10b6:a03:332:cafe::a8) by SJ0PR05CA0079.outlook.office365.com (2603:10b6:a03:332::24) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8272.12 via Frontend Transport; Fri, 20 Dec 2024 04:45:57 +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 SJ5PEPF000001CB.mail.protection.outlook.com (10.167.242.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:45:57 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:45:52 -0600 From: Alex Hung To: , CC: , , Subject: [V7 37/45] drm/amd/display: add multiplier colorop Date: Thu, 19 Dec 2024 21:33:43 -0700 Message-ID: <20241220043410.416867-38-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001CB:EE_|SA0PR12MB4447:EE_ X-MS-Office365-Filtering-Correlation-Id: f06ec9c3-c061-43da-ffae-08dd20b131c7 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: CjYAd4UtYLYxeAkUYW/XRy4xZuTaQJu1ElhXyg2zcBVHa6vWCN2C82PBrKbU9R3YmOaQDctqwhw7YGmOHhCMl3IxiRyb6OTnKT3EsmA4QOYRK7Pm0m55jRozCNwrvlk0H9oKQy6xeloDMW1yMLUKAX5Fgtw+WbFYGpSy57u7SqnyHOlQqVySRmj4xHTU9XSrLhNp2w5kq9T16bu+fBqvgwkopbHii2kHu2JtZLMhyjIyNfbBjLxdX/Zwh5uXRTJpc64XZZuj8M5nDkFvOn9GzaUvy6BCmrG9G6IhoOTF1BZ7qyyYfz2jYEMDPsMDBn8TG85+DnWbd07XZqjADGSfEqHXvo4ZCPCMgrvh2HK2n9fNsSDo5TDoi5MrHnW3lOUSfccTUp8hGsNFD8ogaYQr9iZ5w1n2xiVELANdF+2MmQMVyY6ZgoZIVZwmI45BmMC0ghlXyob9D1Q8W44RUVWA2JNtQUPHrLCG4PnA+a7rirKLmJ00YU5zdg/DzOu4rS2N/r4fzwA18eGANso2Sl+pfKmkZw4ppWsvk0mwVza8vDqWspLPYpQ1p6BwxvZIm7jV2PU3P9KnZx3IoRgmbRQj9gTC1yC+WaS8X/bpfMOJRDxbMmwU7haOy81TxnY+zg7exPuaxIFqB73Sqq3DuULtqLM097I1NGNvQnSiz75gJ4Kdvh9pVESDdKuuwPz3rGcR17ALvj61rJo4CEo99dSE0JdjfzXYDtQr4VNr2iSqzc+CtMi6jN/di71jpA1fCnmKVCPQaOqy4whxcilN5Y3ANI0fyK5B4rRrwosvrYSvBgjwCqsU0USudyCpE6ZmdCvcxcn5JTHsXisE3JwKyTb5bbcuKY2xdFQdaKjVbLXa3xJLFSjtwyUxLTFKZYsrsMgvgOgHIDrpHq3zDvyW8iSw135vSZHwoaCx2MruB54giF7kZTsmKh7cWR5ji9LhMNg/KayjYS1j3CxTGJNUKlgXb3UKNzMZskrPrJNLNphnVDyW6aUrMqyavxjcNgX5NEZ91QkVcfSCb6bDdQKS7SBn852nwoxMWhxEkZJwOmebxWxlfVtoVnJ/G5B7iSdKqYK/ezXdyazFHP5k1jSjc7mrWlH84lwUX5BJJrS3eIhRdI9hAW2ePOO7dY3kGdFLyiiOSFmVyu14yElpwo8msmC7P/6Hyx2Qlhl0aL+d45TPdeQkpYK5QtaggF43GZ/BemIHioLKJ//EGzR4E3SzIaxzq/rrOCRGZqSmf9WlfbLSFUfARlTsZJWWVeuMCJyfk5WA79EwVk7pgRru1p3gytpz+NL1d0JtKN4zWiRiQmelYXnJ1DL6LruUG+i92JQ8BkEAzxu7IXhlTrXKKgxGFbpBz/jlwyXguSItbJkBeNluu/N2VhTOhN21KL/IqiU9OUEPt3zauDRI4TVUvdWTG00rj6Sjq56KyLE7+ftZHF89LAfCXrOB8oNUanvpZS9CoWZ0jyTm6K7AnsL2I04/NLgJ90GoqCzSwNFK3v3l12xLuhA= 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: 20 Dec 2024 04:45:57.1406 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f06ec9c3-c061-43da-ffae-08dd20b131c7 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: SJ5PEPF000001CB.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4447 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 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 5d6effe6f90e..edf05290d441 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 @@ -1250,6 +1250,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, @@ -1459,6 +1488,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 9a9386bf85ec..33156531d751 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 Fri Dec 20 04:33:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916235 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 31C1FE77188 for ; Fri, 20 Dec 2024 04:46:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 84E1810EEE8; Fri, 20 Dec 2024 04:46:11 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="BzvMO+ps"; dkim-atps=neutral Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on20606.outbound.protection.outlook.com [IPv6:2a01:111:f403:2412::606]) by gabe.freedesktop.org (Postfix) with ESMTPS id CB16D10EEE4; Fri, 20 Dec 2024 04:46:10 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=L9qwTjC9eM8NKrNuwRCKYo6VsXkfa7VSeiS20HBQC8ZnIOjtxoeomX0a9SuyKClHydbOzVNW2um1cIyd450Q2d8jX6l6eiXC7S3srS9asqoSeJxdr6cbo8+LcmNckI/tiR8kxfrUOn/mzihGwLaEak60T5NeLyJ0SiE7DI1BpyvUScqmK2r4j12JAnb+Dye15eUQVgKkMKBmUq51r+4vs8yHWAkNyPK/3jdsCIK0k21o82/43AWPxs7T8rMwtoM4GMGRJaFM7PB3oIxKltBJEF8dtxuNHwtGL0TgJjyPJy0t0eAmn6iA51vruhNYj9TdMKgBmAmzyvjX78z6xrMYwA== 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=nMStaKi+HVRNtScSYmMDaMrB1L5IkaCNk+upg53fPF8=; b=lewDeQBxs+7wkxgdESqYdqoIasRavvn1T3rmZ1CnfHCCuvKEfck5dpUIzOiOXp9XL0wPc0ktQMVP4IKdLcIpJjIdz247l0L5MhS654pZAFEkDH0dfG5dg8xISR4T4o6K5Ilqgu/ar9/hDib6PPlWYcZ2oudciBLqw1vF89tdVOM0UzkqFh11/fDmnEhcAbtLzBHdFtzulgxcLK+Jv4H32Nucx/YmAY7h68bl2usUJyxRfuM9VQ1RiQmiXZU7PkSNYkv07fdILTz+QVXQrVJ42VwEPmI991M41V3H2xQ20tWuXxjxYhnWc3U2qP3wgIPGxRgh97mDg9U7371+NyY2eA== 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=nMStaKi+HVRNtScSYmMDaMrB1L5IkaCNk+upg53fPF8=; b=BzvMO+psgF7SKRmIrZUgRIuzINCYjvob25BC/GZUfSbgm0TPC4NmogffJOqz0/8FMY6KKdM+XkbbCBfAlK/v/Dk7+MyKy4Ueq9tb/rWnSzpVqkbrf0zE7kHXmLokeGdkfyvLTbtTicqroY37v7puhOFQ7xhnDFgfpSoF9svyGFM= Received: from MW4PR03CA0173.namprd03.prod.outlook.com (2603:10b6:303:8d::28) by PH8PR12MB6986.namprd12.prod.outlook.com (2603:10b6:510:1bd::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.13; Fri, 20 Dec 2024 04:46:08 +0000 Received: from SJ5PEPF000001CE.namprd05.prod.outlook.com (2603:10b6:303:8d:cafe::bf) by MW4PR03CA0173.outlook.office365.com (2603:10b6:303:8d::28) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.22 via Frontend Transport; Fri, 20 Dec 2024 04:46:07 +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 SJ5PEPF000001CE.mail.protection.outlook.com (10.167.242.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:46:07 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:46:05 -0600 From: Alex Hung To: , CC: , , Subject: [V7 38/45] drm/amd/display: Swap matrix and multiplier Date: Thu, 19 Dec 2024 21:33:44 -0700 Message-ID: <20241220043410.416867-39-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001CE:EE_|PH8PR12MB6986:EE_ X-MS-Office365-Filtering-Correlation-Id: 645fd476-70e8-4430-a85d-08dd20b137c7 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: qDkxL3wbdci/2pDCPsJXs1ZVQVEQuiaUnM26ohhNyHbDGI5my4/EtWrmm80KRme0R7SGkxeVvQ/1Vi0app/z3x7TK4oOqvPcryQ3geMKHTwBm1diePCp0InEtGULjGykY3dKe8ZDjoqBz4gALhDk4tTrz55QX0AhM9RXuN6mSrOv0j2IOWNfx4B5p+oYyFRaW7S1Jp0sG3lOecAIjnQa8htpmMUPjPxaUG1v3I0kvkJtTQ04zAUbJlIy4fikoFC3L37qJHrnwtAiUDdjkmfjcEa+wKqjFnewz3GMv+QatQ051lHyS2UgOgE36J4GSe1IceXKdQCeRAx49Wo2JYoIAjULNeYTNo2VDNgA4IZo3zPfIrSZvDn7zBvYyVPrsAZN4OwC1RT98dr/f2rjnAW0BkGY3Ar7wxBHxYHwmi+1gtW2HAayT5DMBcrj0EgMvpTU/sK9p9N31VHCTeTtNFeQ3Bu19zRJ1D0Fl2lZNBl23hqvNxrKHwYWsI0MYkFKQF0fYDQoP69tc7rXthv+3p3McjHgEhocjwPTfQXSbuRan5U+1CFh9Qs8FCWwa/CeICeFvOwjUOQ+8f/SGpN8F4TN1SlwQ0KAUqdZFnnnpdoDThB0f9CkBxAILX4RgJdE8cPWeMFvRnC77af+Rl0fi9ypqYM1sf/GTnbzhq/vUdQ3EFXsooBkMh2i4yArOJa6708pXL2DM9DruyKi06nC46T0Xa81cSB5P5BHgp+cJYpPgy2lH88koAL1iyZkelNn8C0ArM6ZfdxWA1bp7sUl6WLj9DgyxDwYtioY5LcaU23v+o+aUtvgwiszk02JyKDpFHasCUElMq/fQMLEeBdPcqsgnqIz7AEF7paOYocqhFn/39bxOHBaTNJS1E1e7XTKLeE0Uf7M2ZsHxkQHYE9vZzRPtB9ZBf7/e2YCWny5MslID7Y4SYVH1uXJb0Pia6VmvcRAG63mmoAKIfwlK4vfmG1tkWmV9M9X/Y3RTUTUp8GpzDu0G2/lvhbJNfOdhtECewRxkSfIyQMX7rJ98eDa312FZUTZal099akP/zMGK1TZ/pYTNhETZM+HOcekhwrUZjZyA/l7X1bWc77FyxuDg/iHbs1ayS4sd6t7DRPbanpWjlHc2blq0As5uomtuImFWMuAv1fble9lpmHndKDnay3QISMEiVRuV157lPRKxdecUWwcEXMi/VBacDoc09SbXVWYowDnUhcEAvaqmRkzm6ujepUb3q6GWRZlkla7sFh6iQJwBy2pHl6PM5d6ZyJVeimvN4vUYBEz/oucsPuOsqLIsLt1j1TlcxCY817RY96cFyJE5HB3ETW/DVIhPtB8AiunngP0zXw1SUEUhs0TyKtaf7TClt+5ff0CxnQgj8nTcOVULTeNTjXEb+jCS/StWYyxu5Mlwph4/YZHGAHC50iSuM8d2kRSV5j5/LLL3gFc+TWaxRFVwLPPGa9m2z4pQnys74e4phEZy/1bi3SGkPd/o1xQ1hV9k9ueub55xCorh4s= 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: 20 Dec 2024 04:46:07.2047 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 645fd476-70e8-4430-a85d-08dd20b137c7 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: SJ5PEPF000001CE.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6986 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" Swap the order of matrix and multiplier as designed in hardware. Signed-off-by: Alex Hung --- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c | 12 ++++++------ .../drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 8 ++++---- 2 files changed, 10 insertions(+), 10 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 edf05290d441..54ec12c1352f 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 @@ -1477,25 +1477,25 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state, if (ret) return ret; - /* 3x4 matrix */ + /* Multiplier */ colorop = colorop->next; if (!colorop) { - drm_dbg(dev, "no 3x4 matrix colorop found\n"); + drm_dbg(dev, "no multiplier colorop found\n"); return -EINVAL; } - ret = __set_dm_plane_colorop_3x4_matrix(plane_state, dc_plane_state, colorop); + ret = __set_dm_plane_colorop_multiplier(plane_state, dc_plane_state, colorop); if (ret) return ret; - /* Multiplier */ + /* 3x4 matrix */ colorop = colorop->next; if (!colorop) { - drm_dbg(dev, "no multiplier colorop found\n"); + drm_dbg(dev, "no 3x4 matrix colorop found\n"); return -EINVAL; } - ret = __set_dm_plane_colorop_multiplier(plane_state, dc_plane_state, colorop); + ret = __set_dm_plane_colorop_3x4_matrix(plane_state, dc_plane_state, colorop); if (ret) return ret; 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 33156531d751..d0777691862b 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,7 +75,7 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr i++; - /* 3x4 matrix */ + /* Multiplier */ ops[i] = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL); if (!ops[i]) { DRM_ERROR("KMS: Failed to allocate colorop\n"); @@ -83,7 +83,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_mult_init(dev, ops[i], plane); if (ret) goto cleanup; @@ -91,7 +91,7 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr i++; - /* Multiplier */ + /* 3x4 matrix */ ops[i] = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL); if (!ops[i]) { DRM_ERROR("KMS: Failed to allocate colorop\n"); @@ -99,7 +99,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_ctm_3x4_init(dev, ops[i], plane); if (ret) goto cleanup; From patchwork Fri Dec 20 04:33:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916236 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 8330EE7718B for ; Fri, 20 Dec 2024 04:46:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ED1AE10EEEB; Fri, 20 Dec 2024 04:46:25 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="Zi9qtwwp"; dkim-atps=neutral Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2050.outbound.protection.outlook.com [40.107.93.50]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9D7AD10EEEA; Fri, 20 Dec 2024 04:46:24 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=on1GhufKrzzZgLFqeN9RmFqkQgYgKB3OKUpmUewfv/oztyy3H/FJo/BxxBytpm+iOXz0sMhtxjEgtBY+1I0H5EeG7t2LkEJHKA9OxTrQQU/ykqYP7+07vomF2o0wU9XL/AkUnesWEHyfBQJ4q2Uj2+yAi8DLpjln3yKCZvNMYkbivqxLZdg+T922o7oJeekMKA/PFMo+/5/Gm9XT12lDYFrRmLQNorzEG51g66F3FDiUTsX7xT02vKvMmn46l42Sl5YEsG9xDwHaE26B4rxT+QJPRvdt1f7+atG9uP/glX9vSddsbnorJf2f5lhzhBTyfNf1RxRwVxRr7gVQBMRsSQ== 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=IG2IHCwzGp/tKsqbKJZDIL/UTE0qBqa3jpAPSnQ4dOI=; b=BXJkGh0T1U5dws6sOI8GuuFo4nIdQLVHJhBl7lWhwben93Y/KXFDBO6FbJGrOgSfn668Cx6dieWQASuWovFlE3eyK/3y4kaBX863VT8WFHRkfUHJqITUDMn2KzmnOiR3T+iYe7U22FhukA8K5IJllzwCkdGWMwBIu6wf9ZDgvFIkmWMKqLie9SUsigJZBY5u0P6D0fvnpKmttcN8hdfYl4ZY8qV+enSdyC6z7QTUIsosw0QG5o0K5GsL1WulusNbPvzg+fDC7LDsqcOfAZiBpSaqtmb8K5QhwIVgEexVJEKZr+Uvqfr8pKZJa3/2q0whqN9HGnAGrxhTXk3dirmQTw== 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=IG2IHCwzGp/tKsqbKJZDIL/UTE0qBqa3jpAPSnQ4dOI=; b=Zi9qtwwprflbekcnW3F/aLjenQdvLMnJWIL1r15t1z1hHKrB415oHAHGAOG5WuK6bc/8H0LZ8FEnnxLymojLIo/TJ0uZJvDa56+gFSGxQa+ygNNR2JsxASy2raRaQ0ftF16Y4Jm1odu008TcuD+/9XNwVI8Xj5aU/TjERqBnREE= Received: from MW4PR03CA0171.namprd03.prod.outlook.com (2603:10b6:303:8d::26) by SA1PR12MB5638.namprd12.prod.outlook.com (2603:10b6:806:229::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.21; Fri, 20 Dec 2024 04:46:20 +0000 Received: from SJ5PEPF000001CE.namprd05.prod.outlook.com (2603:10b6:303:8d:cafe::5) by MW4PR03CA0171.outlook.office365.com (2603:10b6:303:8d::26) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.21 via Frontend Transport; Fri, 20 Dec 2024 04:46:20 +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 SJ5PEPF000001CE.mail.protection.outlook.com (10.167.242.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:46:19 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:46:18 -0600 From: Alex Hung To: , CC: , , Subject: [V7 39/45] drm/colorop: Define LUT_1D interpolation Date: Thu, 19 Dec 2024 21:33:45 -0700 Message-ID: <20241220043410.416867-40-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001CE:EE_|SA1PR12MB5638:EE_ X-MS-Office365-Filtering-Correlation-Id: f69d5c0f-1689-47c6-4dc3-08dd20b13f68 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: xKvN16WLkrwxDk3eiVG5FsFQrmlLN6wFIg60EGPc04v5xxc2xqkW74ziV0ZK3FW+5BcnGN6fNqQwDCc1vq2QYc2kQiCUx2P4N0ugAn+sUFv0iQF/eHmIZM0Kh9FKDMFMicD8OFqzrmmEgGeQNZeIYyqC6S0diAnfeP2JBTBciKYsIosFty0nmoJNnsXZW2PPtCOvHYIMDslceYCq5LFzJAeia1t9H5cjUXfx8NzhVpqfTGDL5FhKVRh84UKC3Gt1tAZq5IhdnqxzEGUjEapO3WsAg6x2kifxQOCbEl7XSItPeCk+ClUbFlS8LUzdV4VKo0sTZLGl00qhClh8RfeKcIF7Rkao3Mv9RyBRcI89VfXRYoAejN0VBbXPE82NDXobRrc2SNVjOm/GGwwFJfH/IWRbbJ8Lx/eV/H69v7gY7sWYgAIqiarso2yGYroRwbrrgHaY58Jb1w+MAaF9iJnitOMx3fbymGJuXrgVxnI0RVoU9b3C3VgLT2azktLOXaYGeZ8G1hDwE5t1jHoHJDEy+gzw3v9cNLHtKmanlG7vAq0FXbHsr85hVH0D/ZPV7ixLsdcCbn6GFZ9A5l4oSLfni6X86FlNDRBie5bktYrxsHnrSk6T2y6Eyqang3lJTRi//PV9TlZGvJhbKhAviA6A4pojBNzWcY7BGjAVyyu1AZK4672uS1aCK6N2kY3n8/L1Wsif5Ij5zDvegRvmNIkzKR9y97E0tM1VC3rIlVKvn2JwazooM8CuPgHUq+2UINWz17fwxwKmacfej6chZOqc1kD7sVxZ3A0VpQZmyhTEcObxtmDn1LHUErvc5WfeLUi6ZRCgFOU7YQew1v5uqixAjBe3Gw90F9VxJEJ2fohwsGTCk8N2fWcCT5SQeH84qAmP0PiHuu2WyLCVWbLZPfhji0mTuL8WzicQ+7viII2crLX3XRYRtkomv9k5v9DCR1Z0U/XQixqSlz1G4d/5jql6dC5P/hIanWp5iPSQHHPZqGvNDxdmXWeJUs0AbcO6ElrUXd0SZOTeys5OFR81yPMtWUnhDRrosWfhtiLYcwUNhGWkPruR3nSTsw6+WFZarXyNmMvmq9PA6pPwMw+lDOwqSgR9X4heDeR+WUrUS386aHI24QPG7PsQKFbhxkERqezIUS6EdHnEX4W6OL4sT7/qkj9snhP5DlvyRPb1q/26oMvxTveMpwcPCVh4JryZNFplWMgvL6P8gwWzkMdHPTlkssPczai1BmyxU49LzsURI9PJViGpCBPs7lXgb91hox3q+5gyxxVMdc5MVqcdR4PN0HvxqqEl5OcyIYXxMv57Zbd2WFiPPULH5pVt/dClLv93fSC9wnBfKDv4EbIdMkjPpe2dTfwqjjaQi2oiLEKIgq+/nGUTMn7K7T50wXWy8bfQk1XlHQLh12xKMR8qkM9EDO9tZF5dyYBuRItLWO0gsqvMRl4Z+EceWzgaP7BoogNNiu181rjgkJc95UzkOmRP9d040dbO5jBdeueb5ezD1mg= 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: 20 Dec 2024 04:46:19.9703 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f69d5c0f-1689-47c6-4dc3-08dd20b13f68 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: SJ5PEPF000001CE.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB5638 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: Harry Wentland 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: Alex Hung Signed-off-by: Harry Wentland --- v7: - Fix a checkpatch long-line warning - Modify state->size to colorop->lut_size .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 6 ++-- drivers/gpu/drm/drm_atomic.c | 2 ++ drivers/gpu/drm/drm_colorop.c | 36 ++++++++++++++++++- include/drm/drm_colorop.h | 19 +++++++++- include/uapi/drm/drm_mode.h | 13 +++++++ 5 files changed, 72 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 d0777691862b..92c9f3fb0254 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 1fa6818794d6..9a17fe11bcb3 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -795,6 +795,8 @@ static void drm_atomic_colorop_print_state(struct drm_printer *p, break; case DRM_COLOROP_1D_LUT: drm_printf(p, "\tsize=%d\n", colorop->lut_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 9fbfb2b89b1b..e8d8806e94cf 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -78,6 +78,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 */ @@ -234,10 +237,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; @@ -257,6 +262,17 @@ int drm_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *co drm_object_attach_property(&colorop->base, colorop->lut_size_property, lut_size); colorop->lut_size = 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) @@ -411,6 +427,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) { @@ -428,6 +447,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 d84f457a2b65..01c7f5cd6019 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -253,6 +253,21 @@ struct drm_colorop { */ uint32_t lut_size; + /** + * @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: * @@ -322,7 +337,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, @@ -376,6 +392,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 Fri Dec 20 04:33:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916237 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 0D9BEE7718A for ; Fri, 20 Dec 2024 04:46:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7B7CA10EEEF; Fri, 20 Dec 2024 04:46:40 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="Mf7uYSOS"; dkim-atps=neutral Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2040.outbound.protection.outlook.com [40.107.94.40]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7120D10EEED; Fri, 20 Dec 2024 04:46:39 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=p5YEoOM0hXwnCR/nmD/N8a/IplCm1gyeg1DhYTeYZzc9MBYpVH8aQlGmGPb/lXe+7NkvK0d2ZOm1SQRxJh6yjfTwsaSAUHX8HUe+n7Ew+WIgSE48A9dYCr3jnR1mGpGX31vZjP7T8RB3mjxveqDiHx/fmCwjJaOv0rmsF8QRd/ufJMvO5O/HbJywABa9q5b25TaipfSWsfgbAguqtkeLq2z+jIZd1OAdfzzPXdzybnLyUSJKAUkCQ6m5BlrYrPD8SVhNkZnng9psP9/HdtI08N35tq4jsVvXuNXXlkN5ihiZxP7UE8a258I97k+P4TDFQWK4yYOG4rkXAvbFt3f77w== 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=UTJRIWDIMlW+K+Wufm85yfw/m5gHhmpZU0hp7jq4DUo=; b=S4KW7VADprTWMI8/452G9mMjO+eeMOSJj9oR2SRxVjrps3hZBAga4rwxaTWpoYwIp4mWESEkP9MfjFLy0Z9/6AUPbP3ceTvMhtVG9e7gi941BE2zolK7TuJGpRfpCWhJIfbTGIqDHbXJhWCV9tq50nplLMEGDnzt73xLKBuuQpIfVsDz1yeppXAk67Yze5sj5/VYfKO0QzKLaK5TrwDFtys3dT4zeEkiqg6XmrtPOqH7esbjtngz+XI5qB1bqFYGRNJx59nwjYxOkrrs91A8mmpyItHSS8DAxq/ua0QjyrTODa0bUZQHmeY13FXFC3Skt0vxqbzsXcsbJXrzdKebGw== 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=UTJRIWDIMlW+K+Wufm85yfw/m5gHhmpZU0hp7jq4DUo=; b=Mf7uYSOS5SYY4le010IpgaQgJZrGwxufQmV9WKPB8wXFZV7VFIYbpe+VuvsFbVIHILWq7Cre/yRVfpnsp08r+VbXWQA9LKKsSfoFbCrPuNoSJrTqRBeFElVzg48eOIef4n90ueACUOIPniG2SEvsRCSoCaVFYqiXVfYKSO2PWfw= Received: from MW4PR04CA0052.namprd04.prod.outlook.com (2603:10b6:303:6a::27) by SN7PR12MB8148.namprd12.prod.outlook.com (2603:10b6:806:351::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.16; Fri, 20 Dec 2024 04:46:35 +0000 Received: from SJ5PEPF000001C8.namprd05.prod.outlook.com (2603:10b6:303:6a:cafe::6e) by MW4PR04CA0052.outlook.office365.com (2603:10b6:303:6a::27) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.23 via Frontend Transport; Fri, 20 Dec 2024 04:46: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 SJ5PEPF000001C8.mail.protection.outlook.com (10.167.242.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:46:35 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:46:30 -0600 From: Alex Hung To: , CC: , , Subject: [V7 40/45] drm/colorop: allow non-bypass colorops Date: Thu, 19 Dec 2024 21:33:46 -0700 Message-ID: <20241220043410.416867-41-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001C8:EE_|SN7PR12MB8148:EE_ X-MS-Office365-Filtering-Correlation-Id: b53184ca-f442-4578-b2c6-08dd20b14864 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: 36ZH6XSopBHK4HneiYPataUSJQqhCR5/UWG9DGbu5xjIuQxWBumEb6W46l+d+BXvjqO553Sp42xHOtfClqboukp4M7puRjmhTJQ1hx/wTLlFnd4bpBvKKoIHBqWAahGivY7CrDAvG/DuzQ6XcHpbFou8Bljt1OZpFcHFNiI81W8OH+tFai8VIrjMJq2ACBF+mJmkHJilM+lG2k9IseH7oMNJrqRB5BxPpSR9GwWki4savDHAIFyhVojibEu5fHW3uCAb2v/RCXV7kLX1ONkWGFWAPvE6yZvdNvZeZVxaXfjS1xvVB5/6jqwSuYAtaqkXcFPU7mx9tglN32vC0tqTsb1tM9MRVuBjG+O8rmqfCadOczTDPwJ0Q+2XMZaGTQpXSNoZ6dxzyUBGY8hCcluWL/A5IOcvD2VTwzhdzvSeeOnXpP8YDrz2Up5WpnFf+fPyPkolHKKsIOGHNpFLGsInyzgLJJxn7VIxUWjiOA3pHur8Nk1iVdkSMqJUEcbb23NwsroZkaTG+W9KqU8bPy4+8QK+OagHgXokkHoQRnfJxEoRL2GDnNtqBQm5k1TnkFPkr0/AyUSAsGKAyQzfGVHjdE5fgxIRV601pUvL8ZPwV7j/WWQZiGdIFezKe+edVZUqnweQbp+c2Tthd61+paN70iyfc20k7e6TyNAIAqrscz3evVtcq6UG4Ps6Zmg6z+Bz3IKv/31Il2F6Wp3KT9MgwGsbRIkPtQUx7RlqUONlg1IrvZb9M/XSZ1sDpyG2ZuysGPfape8RYsvr3h4Ba18Ugt5RMYcxCq+uK815Ri8NWmK9iREv1S8jqKkv0bQoHUai1WxmQ49gG5nrXd1GaQp+W5TQ6cueMAFEnt493Zr+oGrHqezEzK8M9cjgMvcpr3cRbnHtWlF3TEMhkHgw3bTFYxOVVcwvBsYcWlI0IvisLDHX6JrS/H5fFkmQfvAVQGA+MJODV1Lsc+vx3stGhEvvveNGjVsN8cmieWKkRPk/Z8MphdM0s6kq7+HRQuZrq0mqEX0vVWE/13ziARzcofHiaRTTUJNpUt4aMy24m/g2OAUksjPMv3b8RlrSjaGkB4ohj5DYuF56onTfQ5BMJvGEIbCDpiKaEU0zi1ArrBXfKCMwe6LzeLIoU+CFFkw2mqBDY1cOJopEVcx3xN/nYWvKPkEienaVLQCr2T40kwvbFd0F1IsccFEFnn/Pf03HpkDWiLhUob1x9v6FmOYArkznSsZQEJVSTYpXtMyscEz2FpHdvnqlyTpn2uH0JSfn0zxIz9h7pphADekqazcqMDF+1DNO3+AmfeTjFCMnYW9CIkyZBSNQ+l2aEu+29fK74STKxuJFHbD4zOBluZDr2h/dVxjJRhwWTQ4EvENYUD2u9nfHF3zRZF+9qY2CjFMG8ezFurVfyVRVJYx4LDpSMvZi7kZrYiiO6bImH7zP1CoWhfqtG6VfOWh76ER4Wsn6zaVccoJLixDfTkDr17rQehesRlY7diIYLpf5mmV9zEpi9lQ= 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)(82310400026)(1800799024)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2024 04:46:35.0775 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b53184ca-f442-4578-b2c6-08dd20b14864 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: SJ5PEPF000001C8.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8148 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: Harry Wentland 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: Alex Hung 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 | 53 ++++++++++++------- drivers/gpu/drm/vkms/vkms_colorop.c | 8 +-- include/drm/drm_colorop.h | 10 ++-- 5 files changed, 61 insertions(+), 35 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 92c9f3fb0254..ec94ff887886 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 9a17fe11bcb3..88219b095d99 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 e8d8806e94cf..dfff8e37ff05 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -85,7 +85,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; @@ -121,16 +122,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; - - colorop->bypass_property = prop; - drm_object_attach_property(&colorop->base, - colorop->bypass_property, - 1); + 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); + } /* next */ prop = drm_property_create_object(dev, DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_ATOMIC, @@ -154,10 +157,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; @@ -178,7 +184,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; @@ -238,16 +245,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; @@ -285,11 +296,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; @@ -309,15 +321,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 b407f8ae758d..c418926d5bc0 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 01c7f5cd6019..988955582636 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -335,14 +335,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 Fri Dec 20 04:33:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916238 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 D320CE7718B for ; Fri, 20 Dec 2024 04:46:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 04C4810EEF3; Fri, 20 Dec 2024 04:46:51 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="Ta9Kl3Tp"; dkim-atps=neutral Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2066.outbound.protection.outlook.com [40.107.236.66]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6492810EEF0; Fri, 20 Dec 2024 04:46:49 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iL0PMs5MAvfksE6CFehWnw8idGWqi4A5vO98XVxrg3EVrwIbrJjRhkNrXH6ufS0kgO6vC7Y2R8K4TKNe3uf+pgjqdmpf6Y+JSi5KcY1+T9qN1iXiA1tUcL08BgPg6sSLRH2V/HMAhxFFvsOH+kTBXZHb1Q2LOJ6E/F0yYINjdqo/K93DgViz430Q9xHlWG2yoVqHM/gJ49ADMdDYFe9Pc7BAzT/PBdkkFEE7IhMSCJl3KF3sOGa7fJHsgr5N2bXXL8ObWhzVokXNIlCOVauMM8VCRMBKtKJyNtQGUiZKoKYnKQ25udfpwbKafDGaBgnCX/kt2D8uD08RPEbxvRwoyg== 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=QE95C2aXynRV8PuFopsB/8YGiMpl0ur7C/p5yFPu2Dw=; b=bRin4pwt4UAiDmYLtD7PpPFTcVl0/J8qt4NlOoHkIZhBSKffh5iFBeEqWKsuDsBBCRnocKeW+o6Dc81JdtSXnlwFxKuLbxrHlAQh0jZkje2SiqZl8eyBZOdVAEeVl0+9/6qFbFaPuEGWFm5GaZ1QlZpD0lVrZTouSstlJS/omyGquGdslEOPNyA+b88DAsnDW76gx+M2B9hm2UI2pO7iiP4DZXvI94KtSOAq3la8eGgg+ghceOeseZJGlCqbwQl4rWtvFlW9zU2SAFUIxML3y4T1ezr9J3Goy4LYN/5Ohi6hzG3gRrUhwF4y83bAxDKquWMNmcQb0X4uQ8dumrpkJQ== 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=QE95C2aXynRV8PuFopsB/8YGiMpl0ur7C/p5yFPu2Dw=; b=Ta9Kl3Tpo20lnZT045XclqmD3v0l/nIOYNlnqMKY40/QpSo8OwUUiWSbkzlhjSt40wu4yNBRcT9sHoxO1iIw3Xe8Ip6fV/85PEIBxmYD6RAGFi18rpDyJ9oqsN93o5G56xkGE9q97eUuT/ZuttSHzjRHCY19tG/pScY6e2D/7rA= Received: from MW4PR04CA0273.namprd04.prod.outlook.com (2603:10b6:303:89::8) by IA1PR12MB6625.namprd12.prod.outlook.com (2603:10b6:208:3a3::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.13; Fri, 20 Dec 2024 04:46:45 +0000 Received: from SJ5PEPF000001C9.namprd05.prod.outlook.com (2603:10b6:303:89:cafe::32) by MW4PR04CA0273.outlook.office365.com (2603:10b6:303:89::8) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8272.16 via Frontend Transport; Fri, 20 Dec 2024 04:46: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 SJ5PEPF000001C9.mail.protection.outlook.com (10.167.242.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:46:45 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:46:43 -0600 From: Alex Hung To: , CC: , , Subject: [V7 41/45] drm/colorop: Add 3D LUT supports to color pipeline Date: Thu, 19 Dec 2024 21:33:47 -0700 Message-ID: <20241220043410.416867-42-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001C9:EE_|IA1PR12MB6625:EE_ X-MS-Office365-Filtering-Correlation-Id: 380b5ced-d35e-4f9d-148e-08dd20b14e76 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: UboKC3zUJz3t2owF6i7vBS2k4SAFygO64zYQL4ZB2XX9L7V2NqhUmUIJEkz7wyqbgrfOvov1Rxefgx+giMEGfK/sQDSqgbt1FVEg6QthcZlI1uHBYqRmdGdQm2zv5D0rFvYCEtUku95PTrDmUSqc3reG5YFCmUw23CEr43uhAgy7QidhHy2yVYCFjHcc7nVoG/Q4GyCazUyujhOgXIvaNvAfQqc3Z25N41DHvTNSLofgcbkvLZqTPG8IxvjfCZfrJsiiIeh1JFH3I1MtNkqiJF18B4LdRjS0hVQV5UqKXSHPpQZXXim0Pt1nkrHEmsI8e6y+0GOqDtKiEztHBuIY4YPnnlvuc7OYlMK9AlOO9ifl+eboZjFVMzAc4Ttb/l5y5lLJKcdr4vfFitQrKNwUUDLEWLBTcbi3fl+siHFQdwRanJ2Zfjxjv5FJgJWLQ0a2zNVhiC4JvbofIxbK0J0Yex4RW7ljr0W//Peje0+1ij9Vw5ZtRumHIvqD8TG3B82ndMOTp4jNgqvwlXM799OaH3uT4G5MW9DXIbCUjLbrZq7hyow9ajQoKLFupa2oKyvle0xkipxdq9B/s/tfzptGiYh+L9O25asYQggALSYO0sab8U7p4MERKFKW3MFUDrl9uXLiLTas/l6agRird/ynJHxDaFW3r99kg9uHy4eWhauW5dX2XZ9Zbp2NB618ZrI8zmJqP0bCW3rE7SXH0+BhO/We/UfKlRSoQuTAQR6oMGQ6lsDjAiIBCVPPEwylQYLYO7sLwYsfFsfP8gMHWrpAnVzpCawC/FYWPhJyRWrMGUX9Z8e9jowTgQeCqHXnGofa4KtH+Aw/uzs8OigpuhNMA4BixwTmG9mOez5qpk8i+4KRBXaK6sGw5dKG7aMidJ0O1AsdnQ4y/Ot9vc2jQe06fj2DJOsJor9Sts8EvM7k46etlTRxwvbagpoFcREsMbuMuHZylb845G3BhzCEcd5GlWymE9OfLjXbYiANSM3gyBCZUOKxJ9Jgxg9626UX/QCzF+jRWMSkOnpi4pzU+aiZbcMORFN8bZOyDDOCIWp7MKzXgHsGnBsH8QSqoJkbCpXIXeasWEs23tSP6PQD/6QR07rM8xSkMWMYm1wfXfDjAtW8vpgWqkeEcZ7MPiaP31fJ7PjgG8T39T3PYjHXbD9FncO4qNWmKztebav08V3QO6EyQoK5XxWQLPLO8ghvOndLrTfg6F4Da2SwpIKHXN89KJrGNohNWufBdqnYqKzinXlkJtsyiHR03LpMBt+FHwGfMrnpjBdbKj+rdHnnYqsYceet7G1L1ZeUT1qnf3KUVKyocHWZb3RN/HyASb/dsYOYdZPa3bd3HHOxiCEmdKOCPLkWZqQP+sA2m/mpfYaWUKcwH6QwA6nFBaiiEXyGPi8m7NitSJNPPz5ZzeJL1Q0iNwZkUgLkyv5ogG4INCjDE6dXkGnl8wEbafvh8FSlCEGWOtuxF3FEW7d/xgN3CiOAboBSc+zhlvhPzpLcg6e3YOs= 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: 20 Dec 2024 04:46:45.2577 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 380b5ced-d35e-4f9d-148e-08dd20b14e76 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: SJ5PEPF000001C9.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6625 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" It is to be used to enable HDR by allowing userpace to create and pass 3D LUTs to kernel and hardware. new drm_colorop_type: DRM_COLOROP_3D_LUT. Signed-off-by: Alex Hung --- v7: - Simplify 3D LUT by removing lut_3d_modes and related functions (Simon Ser) drivers/gpu/drm/drm_atomic.c | 6 +++ drivers/gpu/drm/drm_atomic_uapi.c | 6 +++ drivers/gpu/drm/drm_colorop.c | 72 +++++++++++++++++++++++++++++++ include/drm/drm_colorop.h | 21 +++++++++ include/uapi/drm/drm_mode.h | 21 +++++++++ 5 files changed, 126 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 88219b095d99..d94ea4e11888 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -806,6 +806,12 @@ 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: + drm_printf(p, "\tsize=%d\n", colorop->lut_size); + drm_printf(p, "\tinterpolation=%s\n", + drm_get_colorop_lut3d_interpolation_name(colorop->lut3d_interpolation)); + 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 3c815a2a8d9d..f742a6235c12 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -707,6 +707,10 @@ 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: + size = colorop->lut_size * colorop->lut_size * colorop->lut_size * + sizeof(struct drm_color_lut); + break; default: /* should never get here */ return -EINVAL; @@ -759,6 +763,8 @@ drm_atomic_colorop_get_property(struct drm_colorop *colorop, *val = state->multiplier; } else if (property == colorop->lut_size_property) { *val = colorop->lut_size; + } else if (property == colorop->lut3d_interpolation_property) { + *val = colorop->lut3d_interpolation; } 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 dfff8e37ff05..e3dd49c0080d 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -67,6 +67,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[] = { @@ -82,6 +83,11 @@ static const struct drm_prop_enum_list drm_colorop_lut1d_interpolation_list[] = { DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR, "Linear" }, }; + +static const struct drm_prop_enum_list drm_colorop_lut3d_interpolation_list[] = { + { DRM_COLOROP_LUT3D_INTERPOLATION_TETRAHEDRAL, "Tetrahedral" }, +}; + /* Init Helpers */ static int drm_colorop_init(struct drm_device *dev, struct drm_colorop *colorop, @@ -349,6 +355,51 @@ 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, + uint32_t lut_size, + enum drm_colorop_lut3d_interpolation_type interpolation, + bool allow_bypass) +{ + struct drm_property *prop; + int ret; + + ret = drm_colorop_init(dev, colorop, plane, DRM_COLOROP_3D_LUT, allow_bypass); + if (ret) + return ret; + + /* LUT size */ + prop = drm_property_create_range(dev, DRM_MODE_PROP_IMMUTABLE, "SIZE", + 0, UINT_MAX); + if (!prop) + return -ENOMEM; + + colorop->lut_size_property = prop; + drm_object_attach_property(&colorop->base, colorop->lut_size_property, lut_size); + colorop->lut_size = lut_size; + + /* interpolation */ + prop = drm_property_create_enum(dev, DRM_MODE_PROP_IMMUTABLE, "LUT3D_INTERPOLATION", + drm_colorop_lut3d_interpolation_list, + ARRAY_SIZE(drm_colorop_lut3d_interpolation_list)); + if (!prop) + return -ENOMEM; + + colorop->lut3d_interpolation_property = prop; + drm_object_attach_property(&colorop->base, prop, interpolation); + colorop->lut3d_interpolation = interpolation; + + /* data */ + ret = drm_colorop_create_data_prop(dev, colorop); + if (ret) + return ret; + + drm_colorop_reset(colorop); + + 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) { @@ -441,7 +492,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", }; @@ -477,6 +534,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 988955582636..7b58dcf0615a 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -261,6 +261,14 @@ struct drm_colorop { */ enum drm_colorop_lut1d_interpolation_type lut1d_interpolation; + /** + * @lut3d_interpolation: + * + * Read-only + * Interpolation for DRM_COLOROP_3D_LUT + */ + enum drm_colorop_lut3d_interpolation_type lut3d_interpolation; + /** * @lut1d_interpolation_property: * @@ -289,6 +297,13 @@ struct drm_colorop { */ struct drm_property *lut_size_property; + /** + * @lut3d_interpolation_property: + * + * Read-only property for DRM_COLOROP_3D_LUT interpolation + */ + struct drm_property *lut3d_interpolation_property; + /** * @data_property: * @@ -345,6 +360,11 @@ 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, + uint32_t lut_size, + enum drm_colorop_lut3d_interpolation_type interpolation, + bool allow_bypass); struct drm_colorop_state * drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop); @@ -395,6 +415,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..316c643e0dea 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -913,6 +913,27 @@ 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, }; /** From patchwork Fri Dec 20 04:33:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916239 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 06730E77188 for ; Fri, 20 Dec 2024 04:47:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7AED110EEF4; Fri, 20 Dec 2024 04:47:04 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="aSzD86hr"; dkim-atps=neutral Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2086.outbound.protection.outlook.com [40.107.244.86]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1950E10EEF4; Fri, 20 Dec 2024 04:47:03 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Eztmj17t8vjvevXfWDwnGDjzSFW0kUAsDdoTaHBoAvFoo984JG8r+0A2hsmkOlRyQ7NVazLMNdPVpnPvUhBRJwO2eyJqOodRKaoxVS41/++vDayNOolSnmCtyTXYYcmJlkGA3GIpoLBo84rIku5PYvvOiM5/EokTtKqK3J/hSNebp/XdYatTx9GvS/oAWCgb2RxY6jW9QWKcWVXQ3bfW7yz5dZ6BJ6NnoeMWkl5OByAx9FBwBUnQyz5UHg/FcyBEdEurfSmvTR2n3sxCXnHGewkvi+NRV6pGcEZ7TQLUKo8W18cXUtyqPUerzCRimhU7J7Uu6vtVwrrpZMUR1DT7PA== 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+wq5uoFahVI/7bw4jbBuJshqT/F8eERGTUQQjqdjU=; b=Z3G2RZM1H8SVlG48fo0Prq+yv+bLdpBGwywE/hjvgoOqHaDFMgEG/SRlPKic4z4uCvtD99QGbNDn50P0aMvvACBbt/6I0pZ5rEen8vPWlz0APGOkVaJSpEZ+JzrVSVSJCk2bDieG8Ci2OcbJDz+Ib5mgqSWmsFjUYb7XOq0vssFYLjAUxS1TN8k1e4S0k1uxbow9w4iQYm6ReaAY00n7z0zq3mSqczNFav2zfDNbw/ljSeTKVxuSd7AxucX0wwTVfQtHEcvzDmSjbo4AzSK9SIKlKcFpXJv/8iv6uUjmwfBeoucRWd3wmL9A2SEg+jVZgFCLoNfjjjqjWVeVDcjUQA== 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+wq5uoFahVI/7bw4jbBuJshqT/F8eERGTUQQjqdjU=; b=aSzD86hrpvi7Av/rTZfzA1InblbFe4jJPmLBbtRwPqKOXENY4EUyftaiKwBY9x/rUrcAkjBvd7Z47ztEkxBQJOezJDw1sR8jIi5XQ631taNTBCP6RfB+NI45UivJU12sK5Z7UMNHs3NtzmUuT2RQ00p94gwb91z6EHkCpxyzbT4= Received: from BYAPR04CA0033.namprd04.prod.outlook.com (2603:10b6:a03:40::46) by IA1PR12MB8189.namprd12.prod.outlook.com (2603:10b6:208:3f0::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.16; Fri, 20 Dec 2024 04:46:59 +0000 Received: from SJ5PEPF000001CA.namprd05.prod.outlook.com (2603:10b6:a03:40:cafe::11) by BYAPR04CA0033.outlook.office365.com (2603:10b6:a03:40::46) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.22 via Frontend Transport; Fri, 20 Dec 2024 04:46: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 SJ5PEPF000001CA.mail.protection.outlook.com (10.167.242.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:46:58 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:46:56 -0600 From: Alex Hung To: , CC: , , Subject: [V7 42/45] drm/amd/display: add 3D LUT colorop Date: Thu, 19 Dec 2024 21:33:48 -0700 Message-ID: <20241220043410.416867-43-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001CA:EE_|IA1PR12MB8189:EE_ X-MS-Office365-Filtering-Correlation-Id: 869e4fcc-8bc2-48a7-11fd-08dd20b15635 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: oErCwYvvdikfypZ073U4Z+6jMFwz4Y3lenZLyGiBdR9g3ikGCPFXVwAI5XIcGeSP8oRt/S8KIPQVwI0xGUC+uyykc33Xx6QnIkUGrFsU28aUJB5cIKowxnWOy3jK4weY3ot3neJnJgjAhRbsxdN5soKkaKnjCglQcazQebUBFB68fF6MKyYhUId6A8wGgcy7JKsrYujr1Vhjk0jodalsnTEk/PhSH4DnAitijWemB+jH66EKPsRctMANGGAq1fynCcrTbTB49/EBwd29E6QXw7d5CRIS15bXRmu9N1g6YgfVvFKhLu+FB/lwzKCnFuQP8nkV45PWr8eILQf/crkDxkkMtCLNsTkKLLxo2/7j0G+3oZY3tHQH51LBuXjknpe0p6aQWlFWE0sjQfUry9jBXJWtCnb+njMVjxKboAERj5/kjwEW+4DmDDIXB43HCMGD/kvDBcL0m+LwN/md9xuSbiSAwVg553aanQbzuWwSs39W0/b34hdTd9bXmPxZ1kpssZoZI1Lr0yLVOu2VMctNJC1+4jA2t9LG7YXB3mNvSvZPcq3juvZpAZumzz/5IyLEry7a/SNMw1HHfxBhgF6D6Ddk//jTNFll71cfcuiRB+Vro+RbA7K5Kb4K//J2iJ9kRs4wYeRcT6amyruVGiL7emZdvNUaeMIDUbK2MlO3/vbPrvwLRGgSD7ImY7uwNm4bd48f0T3jntvaGysrMhMVIJ87SaDWVwiCjIl9FKCxhxxxetvEtsv8Q2Sd3ny/wnkG78g9l1fUENj2hpHRTA0uV/7utrzrqD9iCT0jOvowaMKLI8ddxqN8UQbD2viVq1E0nmlgSp6aPQBu0NlTkVCcdqbnokO8OfIl/l3I8PryPWAtwgJc+xK1IMMhQvb7Nlshn5rS9COkdIVCy+Rz7Zf9slS4ZGJcNTv/qeXLf5PQPE2AsmIS1JWyUcP4+2vio5HHJBtua59pL8fPOx9aq4GtCCnBR0Mzscdpj5ETWuh/vFTZAfCNhzZxKQ3G6KT9KoYrW2zA4MdZ/LsHB/WSIEZLzV6ljzEEmsTSfWm0kPaGCix0nz+/uWD9NWHtaB8T4MgMqxC1ODX65S7YOwWNTRHyyApnOIgn8pU5qBQ3ntPjtJBRkvtF9pPob4aRoqw0sG5ROa8jNL3GVZ3VjItiZ8B+uTIQi2UsxGk+qBVvhEDgNjUYIfTn9Os7HpWTvovn2GJkh3NKHsRmwgrCQYsTd2sqcQXEOYpvQN5aaaMVikyM8nEPQDmujnBiBfzGjfzv2830uxE23tpK8sX3fGDL1CWOYJIbmJXiCJVdOLvMTMi5OlyS3hR89YHBmInypYS8gF5g/9nLfNJwQAE52Q/+SZUqB1X9+Wl2x4Lz5zoQiEhxshBgvERcdOvf1QpkSuhodTyH38VPx/2VdYUbH+Dw86jJxAVbCZkIl97GBfK+YENjKc5Mt4P7bwLYqLAAiSSnO/aattlD8p6gOw8ZI8PGvYs/FOdrdBM6TB+UOzUL3kohJ+Q= 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: 20 Dec 2024 04:46:58.2534 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 869e4fcc-8bc2-48a7-11fd-08dd20b15635 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: SJ5PEPF000001CA.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8189 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 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 --- v7: - Simplify 3D LUT according to drm_colorop changes (Simon Ser) .../amd/display/amdgpu_dm/amdgpu_dm_color.c | 100 +++++++++++++++++- .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 19 ++++ 2 files changed, 116 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 54ec12c1352f..5e8c5c0657c4 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 @@ -1282,7 +1282,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; @@ -1310,6 +1311,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 */ @@ -1337,8 +1339,88 @@ __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->lut_size) + if (shaper_size == colorop->lut_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 + * @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 dc_3dlut *lut) +{ + if (!drm_lut3d_size) + return; + + lut->state.bits.initialized = 0; + + /* Only supports 17x17x17 3D LUT (12-bit) now */ + lut->lut_3d.use_12bits = true; + lut->lut_3d.use_tetrahedral_9 = false; + + lut->state.bits.initialized = 1; + __drm_3dlut_to_dc_3dlut(drm_lut3d, drm_lut3d_size, &lut->lut_3d, + lut->lut_3d.use_tetrahedral_9, 12); + +} + +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; + const struct drm_color_lut *lut3d; + uint32_t lut3d_size; + 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); + lut3d = __extract_blob_lut(colorop_state->data, &lut3d_size); + lut3d_size = lut3d != NULL ? lut3d_size : 0; + __set_colorop_3dlut(lut3d, lut3d_size, &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; @@ -1467,6 +1549,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 */ @@ -1506,7 +1589,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; @@ -1515,6 +1598,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 ec94ff887886..e03e6044f937 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 @@ -49,6 +49,8 @@ const u64 amdgpu_dm_supported_blnd_tfs = #define MAX_COLOR_PIPELINE_OPS 10 +#define LUT3D_SIZE 17 + int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_prop_enum_list *list) { struct drm_colorop *ops[MAX_COLOR_PIPELINE_OPS]; @@ -145,6 +147,23 @@ 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_SIZE, + DRM_COLOROP_LUT3D_INTERPOLATION_TETRAHEDRAL, 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 Fri Dec 20 04:33:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916240 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 C5187E7718B for ; Fri, 20 Dec 2024 04:47:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D6A2110EEF9; Fri, 20 Dec 2024 04:47:54 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="rY3frm45"; dkim-atps=neutral Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2061a.outbound.protection.outlook.com [IPv6:2a01:111:f403:2413::61a]) by gabe.freedesktop.org (Postfix) with ESMTPS id 93D0710EEF7; Fri, 20 Dec 2024 04:47:53 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ENpOEA92NNxhZETnILiaD5dFpJmmo2MZrEvwJANKaNjY4nkFrjYUzHuJYEOLZKu3m8CH6mnLf3ASCQhJMYI1ZiJw3yNu6hkQ87V7PD7A1rBFHsh/6OahuMLSMuCSodiqhHk6sXaLGDQBFxNBcH4D4Sl10ZZOen04UWBflUpAHarkPtofz0aqOmlrDsqFRqPbq87o6jUZf3t7Gm0WssNR1hN8pOrUt18Qs/myr72XkTezQCn+BHeMrRJZ5afDLdJ/pOfiuUbCvZSfN2INsJY0TPYmvGdpHqTsLaAmy2wrix/3yYxrxIXShm2VxBj83l+wCT9hfZdSCUE97nOH6ewpag== 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=u1SXhCRrhlqJoEUl/zOHQrtpYAMcCmtWjirZJPF1oG4=; b=w+46kJHiVmqumsBJbYYN8RfK9PJODlMO2eZ6eJZjyND4TNlDfezS87kVTZnShAL2zVbYQtBL3uCvL/yD4n+5k7ZBR9f9gZ6gQ+/hTdjfvXvWqbgCPMTBpKd7FI1EpAwTrajnox+TtOhk2U3Ra48whcTsNClC4QOWJVFiMdbBvosSLluvx4hsCEb3qbpk+Wq1t70mfrl4MY4jiuKqskanwIYdQGO2Me48gmDDtAWcJrs8TyUEWnSGrhEkzKE+/YtPpj5Rh42IDs7C/pOWwYcns1UNrd/2R43Fxo/AfNV5XxB1E1zh7uEjCMxpdCwzAvbCdGke1kJ8/SwHjjjdVIY9yg== 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=u1SXhCRrhlqJoEUl/zOHQrtpYAMcCmtWjirZJPF1oG4=; b=rY3frm45FqnV0TLZA8SIpaO6y3gECJVMB9lNYCpwPL+/gmgYFFDNIk9qPSVjMZYVoKF6pKyfgUEBKGK/vJzi4UkaSagDuUkPLWHB/kAj0nDRafCmNiRVpyugQ4I5FoQeEgi1ttrqggTUq0jPnkkQtnrbqEdoRaG73TvRBwUmdsI= Received: from MW4PR04CA0045.namprd04.prod.outlook.com (2603:10b6:303:6a::20) by PH0PR12MB7862.namprd12.prod.outlook.com (2603:10b6:510:26d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.15; Fri, 20 Dec 2024 04:47:50 +0000 Received: from SJ5PEPF000001C8.namprd05.prod.outlook.com (2603:10b6:303:6a:cafe::58) by MW4PR04CA0045.outlook.office365.com (2603:10b6:303:6a::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.23 via Frontend Transport; Fri, 20 Dec 2024 04:47:49 +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 SJ5PEPF000001C8.mail.protection.outlook.com (10.167.242.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:47:49 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:47:09 -0600 From: Alex Hung To: , CC: , , Subject: [V7 43/45] drm/amd/display: Add AMD color pipeline doc Date: Thu, 19 Dec 2024 21:33:49 -0700 Message-ID: <20241220043410.416867-44-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001C8:EE_|PH0PR12MB7862:EE_ X-MS-Office365-Filtering-Correlation-Id: bfbfdb7a-76a0-4aac-3e41-08dd20b174be 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: Vp+ehA0Xx36W+z3L3nuoFeYe5rRViTFMaO+C4NH+GnlKhJZfBSAyfBPaq+wqjMcJQBf5abnCOJQnXGb+flMA5l9hfK+Que91xLthYVU9HkmiouUYfg2wuvHRB4fMWvtaHB2he0JLCubVJgyVH+g1Fp/XPwPFk/fgcUNwQLjrkYxgTvN3o089IEA1bW8NnJGVVCEZf3ddq3YKNRh7RqXulCXBYjo9222DsAJC0OsiiXNe4abrVeSfH9vXrGM02KWZuKaJf0N+kGpuYltVxIpOgqZTnNuFQnDIa976Q42AqmsWtnrINEWr8QgWArXjflfMI2mp3uGajHysEEdv7h+NuRW4fSCjV70hiteQ1Raj47uQDomjbEuO03/ZPVc8n0PdvfMpeI2PA3qy9j+IE7O9f2x4KLzm/hNy8By0Ho+E3irPRlpA3SS5iyyVwrE8VNdfQnIJBfyUi5Y/paHUtINF4e5PsgylCKnzZEHyrIa74cdwbT15rNiBbW4lhFd9PaBhikIQayZIBS5YhGwPqJzBYIyaE1WyKmKCdQ+xlKGq4PkrowIjMFRg6amb4gkIebXNIZ82jLCp+8zVpcz1aP3LbWe7oSsekXuFh77AGvZmy8avJ3UPGxMYATJboD6H56XijrYTv2sVP8iu9jZJDwq115AJTkc0zfhFr5uG9VyB/OtNmQyjGtKIVkvujCRNEdOCChgvFZ8v2WU7OAaCbjl46IUyIYgTIWuFaSiATOrBtPlKc3esW5yU7VDQIWTu9NMYb0jLNX4KkFRQOYHAnoQwYM+86Gzu6yCv8855cOyX/wxUvsPOR/6L/Ahd9TJsgqfpnzzzxfKW3/AhlzEQKwUGJoNexq5YhFy4SnTzIRdWRUgbV9zDDkHDMiqKaWZ9HOSVEtHWmQG/7QgjY57xkfiFwXQEpK7NfuY2RU/nBMEcGOPed0PphKNg8ojxABs0ykR8y/mnJCo2eB8qR1T5xGKb2VVb2iBGa3X5GvcnC5TXT43Ul8SHP27O+6nu+KUjn5XIHPyENDZVq+/rwrUS2sJN6HuKhbtoFx5uGp90/XckL2xwx6y2ahf2jkpouHtb9F4R/PXfqcz8TcLdqM6Vku6YZC6AEWMDtfqDYLNgbwuJBwR4XU56eO9vAWnua9cXBDGFoLBpcArv709gawvFhh7Dh21wl9JSPmqXts1kOJBrjDYYGcLfdwCgI5SVQsiqxMzNwoTlSnUGdgnnGmeNxpY9yTiyKpgigVJeJ4Ztv1lgbVAhNqUWnC06a/WlfTqEUAGuFCx+wMGIJVrh5QRjEmirxo8AoZjUT7CR5UEs81yGcthXxLLWCUksYLkJVib4c8hdqD+6dfeAvF/ehP8vlmb9j+f7aT0R6272cEyCPQ1ahupAkBhlhAsX+/TRV+Ub9Ns0elQu0WB4dVmhpUshwniQjkw19tEPGzoKyV+U5FxquGUGRizvuqFMG+mIjH7tzJkTkV6vb5IHsEQ4XHAVH2v+hZlLIAn6m0Zs2ClY8k/70RY= 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: 20 Dec 2024 04:47:49.4997 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bfbfdb7a-76a0-4aac-3e41-08dd20b174be 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: SJ5PEPF000001C8.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7862 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: Harry Wentland Add kernel doc for AMD color pipeline. Signed-off-by: Alex Hung 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 5e8c5c0657c4..56fb0870a2fc 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. + * + * 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: + * + * 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. * - * 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. + * #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. * - * 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. + * The 1D LUTs (#5 and #8) are plain 4096 entry LUTs. * - * This means that the following - * configuration is assumed to be the default: + * 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 From patchwork Fri Dec 20 04:33:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916241 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 4AE49E7718B for ; Fri, 20 Dec 2024 04:48:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B5C2E10EEFF; Fri, 20 Dec 2024 04:48:07 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="tvrbrQIK"; dkim-atps=neutral Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2045.outbound.protection.outlook.com [40.107.100.45]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8ED5E10EEFD; Fri, 20 Dec 2024 04:48:05 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=O7SwWCDH0+fthW9zWGx0fJmo5OcIjM9J6hRCz65Qg/L9GylzwetGGVH5QJqHrWNugiba40F8QKYvxySDFhJSPddQojEnOao4zucj+RQlnA35wS+QFh37ytG3LceyEeNyDZGsDqYXjshW/kVW7zT7WelMoGkYyGamfpFCRmvqQ6fdBNKcI1/PXcU2Ip4Eg2McjKS9GwPmHZYvXcio4/QVRKaNS9EZxC3K66tIyYPLtx4D5RXWLEEGZPQfqrLUDyUWspG5IJRmI4kILgwWCyq7eh/d4/f9laGxNNsi9sSn0+QCHoq5zxD3jy6ubJd56/0SU1fB39kpuRY4n+h6rkSZnw== 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=3+1YMxLEXqvHE3gUSeKIGicKtZ0XFcIZE45yGLrhDXc=; b=kCrfD/gSDQHasfF4Ml77/JrSvfFI63ro0e4wx13RFqtxEa5/g0h/3/B+67SbdUPbN2XJt1UOMkeBKrLAe7suU0fQcQG8mPSgnz9wpy9HTJAjtxyEmwY20tfrdmzdnvJvxeNMSSjf+/K1qBm98gZfFCZn3C2pQwEnRB9kPKz3SuVZm0/bH02o+nkPw2ZaOlu6L/d7i150G3yFXABpVTiZ+QxtKB2Tlvfx+jr13PHdSo+WPGqArEIk54jFAG0va/pIWLxmwi3N5mtvx61SCsehhyJgpNgqt7/n7bFB4BcRE/Y5pv4P15Wi469fO9e7wxr7EbP9UM/szKMozYjX3pe6BQ== 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=3+1YMxLEXqvHE3gUSeKIGicKtZ0XFcIZE45yGLrhDXc=; b=tvrbrQIKPS0z0b5c+gXXCrCYtrUq4drNMbO4MzKBrsbaI4/qgG3it+uSdmfNMbYh3JC3JO0rS9q2pTQptvgPwfFfqjCrghOHuZOuIgpNZ8Zn91WGXptLfllholeTmdtqC022cJaEm8TWw639RU49Yp3/3g2b9iQmiI2iUNvUEKM= Received: from BYAPR04CA0007.namprd04.prod.outlook.com (2603:10b6:a03:40::20) by MN2PR12MB4221.namprd12.prod.outlook.com (2603:10b6:208:1d2::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.15; Fri, 20 Dec 2024 04:48:03 +0000 Received: from SJ5PEPF000001CA.namprd05.prod.outlook.com (2603:10b6:a03:40:cafe::22) by BYAPR04CA0007.outlook.office365.com (2603:10b6:a03:40::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8272.16 via Frontend Transport; Fri, 20 Dec 2024 04:48: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 SJ5PEPF000001CA.mail.protection.outlook.com (10.167.242.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:48:02 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:48:00 -0600 From: Alex Hung To: , CC: , , Subject: [V7 44/45] drm/colorop: Add kernel doc for data blob Date: Thu, 19 Dec 2024 21:33:50 -0700 Message-ID: <20241220043410.416867-45-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001CA:EE_|MN2PR12MB4221:EE_ X-MS-Office365-Filtering-Correlation-Id: ff6177ab-1280-45cb-e50f-08dd20b17c4e 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: 2uFZJ4b4T96TO+DmngKSISHRZcmVFSDR1Gy0jxLuymJpZ4h2Ea5kYL/KcHgYLZlCoXkdBkUZ94M+a+6wZ+ciDl844JfNL0ER3lgmnPlr+AsNgyQt3QuRmGdJBq7B8iyv9bn3LQvoKv+sVlq0VlAnA02yE4jiOqp5w13BMzbCVh4VEbanc2eMuGV4NAfNJWGS57OCVBvScGeLs/8jmElZH+XP9gghseGMHnKZnW2/nriCR8IN2QNKWtdSG7pdcnY/OULS2YoxRAfrnMeonk9OeZTdmWs46a/osIZQd9MBBZ3VxwA4HdqfBK1WiS1tUpm4AeMv18FH8UunUbvDDUxw6fGYckIq3QiZHPuJXsUjfLDmVv12+1AwJeuuEodSfWMSeTCLqp4FNOtSGX63aeb53cTKpURPfbn3ilPQF1Chyk2rY8lxB8c1kP9yZvejTTYmg3bKlsUnvMWUgmRsSs+c/MUYKmwwmhcuAcwrZXqgtXlBL3aA9gRmMpKRYugRg7WH7AT+Cm09D6C9V5Mtm27XiMMdIrF2Rxa67utKJ2mk8sLB5lvQcS6ZX+B2ix8VsYPeboAKaaM2nrQFUBfWh+CE/E0MdUdnc23wM2Xrih0DPn7lQhJcgX91oxeM6hcN8AVGbGhBtAjTlcBbXpZ2L/HDWR8XANDpq+6RudmzTblv4KjcLG212Olce95ADRLHWBmxkKKalMUIGyuaBInEuicvtxBtHrDHjejTNlSAVNRWloALc/BN+6MChlXo8naOm2rvXJRwJ0a7rlqWrkPbHntg2rdJwDFTmEFOPHUA1V1R3tjnSVVTzpVnqCI3b2+fdH9OdjBxu4AWfFZowLzPcmivwARMFCnGxTzima6yqtIDn9JApY7w30oWxJGfwCnaLLUHNVP5Kenoq5sN6u4Xz2/DUk+1drSoeFAjRR2ZIbTMx2bSCB6s7201UjkEqV2Qicnu38y+FfSl4VPKgBLGr54FMBZvUjR/2dQmvBLPnOvnI49cPC0jCxdoy+VbU99VzuiI/bDBwF1/2ss9OsAU9/eVZ7Su8Xc2lu+wG2GjcXcy6G+c2FRSTWD/GwQHSyK7BwqviLgl3piPi0kIzQUX8De4kWWnBzgrMaRaCqzLu1XEpGBf0tonLOEF27utRW8W3lzxH7Y3lnR0QA7WbtQYo6PoHhrPlrK17tyx43WlJll6bcD5Uc7Ad/Io14TQ7guI4uTr1gOv5e5via4li57XXxSoZg+F7WDCAAkyG9nBXEdlPBGwsqD7UNZYsIL/oe8Ar+dE00BoxoAXA5ygTz9EuO6EFzC5S6mavkttg4N1H/TIEw68JDHOVCVqZ+LHDebA4yss05FT564jq4cVla2dUtzJAkoB12OvLji0dz+S72xnB9xxFnDOJQVtIXrbM+BNnplC5vgzj6cWoVmlOrv9wb7JtygSYHIOpuQvCsazMPFmBPxZ6+KRjeoXq/8d04A5Onnk7dpGmMn1JG9Y2eaxF0HFSb6aMpVBFPxM/tZMlGZEPpM= 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: 20 Dec 2024 04:48:02.1761 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ff6177ab-1280-45cb-e50f-08dd20b17c4e 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: SJ5PEPF000001CA.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4221 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 layout of data blob for colorop types: DRM_COLOROP_1D_LUT, DRM_COLOROP_CTM_3X4 and DRM_COLOROP_3D_LUT Signed-off-by: Alex Hung --- include/drm/drm_colorop.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h index 7b58dcf0615a..11b474a9b10a 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -146,6 +146,24 @@ struct drm_colorop_state { * * Data blob for any TYPE that requires such a blob. The * interpretation of the blob is TYPE-specific. + * + * For 1D LUTs (DRM_COLOROP_1D_LUT), the blob is an array of + * struct drm_color_lut with size of "lut_size". + * + * For 3x4 matrix (DRM_COLOROP_CTM_3X4), the blob is a float[12]: + * out matrix in + * |R| |0 1 2 3 | | R | + * |G| = |4 5 6 7 | x | G | + * |B| |8 9 10 12| | B | + * + * For 3D LUTs (DRM_COLOROP_3D_LUT), the blob is a 3D array of + * struct drm_color_lut with dimension length of "lut_size". + * 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] + * */ struct drm_property_blob *data; From patchwork Fri Dec 20 04:33:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 13916242 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 793BEE7718B for ; Fri, 20 Dec 2024 04:48:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 951C710EF02; Fri, 20 Dec 2024 04:48:22 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="mIicdLXX"; dkim-atps=neutral Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on20625.outbound.protection.outlook.com [IPv6:2a01:111:f403:200a::625]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2F68610EEFE; Fri, 20 Dec 2024 04:48:21 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LXSJNTrbDrJy1XB7goajZnL69ntCAYyLZem46/9NeHk11aWjonc27eqzTTRSZzGF6njTU3qPRX5+tGEGE2MXqWdUbCaCa4rh57xS6CPaOhwDxPRvE5EQNQ+MjFmn8sSQ5ar66hw//Bo/4Gc8nBBPQl0A94LtCUtPBSB7s8bCHaibW+1PM6qBOlnKVRdv+j7VnlC1YzAVjquVlqKNgD7KIA+pNgfFwDXPXzEuiLEJHVO6w/mHeZE3SQItk9JYSsMtCv5rmVqlo6K30jm3Z+dGcRSmqxVjVFHRE50LgdnZVMONo2QX1yf18UzxGno1njgrKWkUJ9tnlbtwztDTDSUpCg== 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=td4+g3CUCM6NEU97Hcj0TZWbVpyNh6cPZfuGS8bOERE=; b=UNJ7oK7kuU5yMH/AkbU/qQltg3F835YIWBoGGAhBMk71GQUymzcTVj75JFN2uOZELyUNKkMK7eb5PIDCF+1VkKLcaHZRCKf/I5bBJ9o+z9fpxoOrLkoWl/k2WIyNK2xB7agvvMgva0GOTs2lVfWzvKA+4UetjMCyPpvxF+mKHbP68JA4yFDKmTgJtrW+jupsfRMdpNkUGKm1rmj5fPTQe8/JLvAqhpP+Ma3NH6Px0JbTvWioEIfyZ8Jx0ko1u2J6i1Gt0WpZ/RQR3qW7DJwtyJMNoJksQGg4j4is1SVNSK/tRxjJfF8KPvd0ZtSfpuVF/uDjCZbiHn25cXdEVeyx3Q== 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=td4+g3CUCM6NEU97Hcj0TZWbVpyNh6cPZfuGS8bOERE=; b=mIicdLXXSjOxJ2YSv8SpKFeliP5pTHNMNdO6yWUJnEuFDs8t5kO2IeohkzpbPYyZVfp6gxZG9fAt+z2tkWJWDJxd+jLjWHatB6VGRiKO3Gn9kpyRX/q1pS8X1KqNkcZDFeGrkl/io8c38gJPWgAdnghZjBZ7/kDgad0WzZjKrcA= Received: from BYAPR06CA0012.namprd06.prod.outlook.com (2603:10b6:a03:d4::25) by PH7PR12MB5854.namprd12.prod.outlook.com (2603:10b6:510:1d5::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.13; Fri, 20 Dec 2024 04:48:15 +0000 Received: from SJ5PEPF000001CB.namprd05.prod.outlook.com (2603:10b6:a03:d4:cafe::98) by BYAPR06CA0012.outlook.office365.com (2603:10b6:a03:d4::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.23 via Frontend Transport; Fri, 20 Dec 2024 04:48:14 +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 SJ5PEPF000001CB.mail.protection.outlook.com (10.167.242.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Fri, 20 Dec 2024 04:48:14 +0000 Received: from smtp.xilinx.com (10.180.168.240) 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, 19 Dec 2024 22:48:13 -0600 From: Alex Hung To: , CC: , , Subject: [V7 45/45] drm/colorop: Add destroy functions for color pipeline Date: Thu, 19 Dec 2024 21:33:51 -0700 Message-ID: <20241220043410.416867-46-alex.hung@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241220043410.416867-1-alex.hung@amd.com> References: <20241220043410.416867-1-alex.hung@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001CB:EE_|PH7PR12MB5854:EE_ X-MS-Office365-Filtering-Correlation-Id: f9411f1e-0aed-443b-3e9d-08dd20b183d2 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: dK/fWNjl/Rusx/0hBCTZtUsifXs80xemWAomxdau0XdRFlnYwyXFbEjYBh9re+PpZXaRVL6hbUUMn4Xp4ZL/YA+VsCg8xpHbKfwNQBdQJ1EM0t37O2WJHio5RiLPabsStrWB+HzLPV8FgeUcSekc7uFDTivU7mGQUYkABw6OMqjyin81hSXd3J/5/bA28ROycLgDm6BOYDxZThG4rtpoKJiqA868McsCdcvvIshFJyIk+65JR/wcBT8dy5xokfPY2KXFPzs4ESH3DY9CaIeYtEC55sahsBf2ZH3FwdlaOa6dbF9d7J6nSZgcAG/4KDVjfVjSpgVZg8+k09dhancgcHK4aNafo5lHiyS76GS+PFWmePzqTIXbl2r7NP9nVKep1gYzhuFmhmGnIRySjBbZlcv/za3Nmc7uUcw/iog9vvY8b8svZDGqUbKsayE5aqh+6uY00GputaUqGIZxCzGb2/m0wCjLrYvTnJqhMe/TZcN4I9n2nkUm9qC7pSgmPMzxS2Asv10rwZ6okRUT2Mv7wsWMbsPFOyhjOT5z0k2jqeABbsqxb8rcyAlmhZDIPFIIitD3LdbJl7M6tjBHHzwGkmOAxQz2dRYrjMQvymjXJzVOBvceQBVZw3iewi6MQFMhISeMdH8UZ6ReX2JHEbzYMfSsWDIMrRssSnbDodJLFJTH440wtwmR25QU6ElJuCZTcrUBEb7OklKXNCACR/Pg0mnGDOeRtCnZs+we43Kl3yfGj0gsj+DEbnldDU/ewEOOmYV7yjV5d5Xvq+iOUw3WPSp6wZSNKHNavBMhDcmwiIxnvRhpz5hs9oj3t0kazkKcSD4w3QcvR/iRbBX0oUs0uLU4FWngzo7aez9/d5zzfSLAWi6/trMFI8K+84j565GvYL7lfS6VMZ1xbHIQUn7kt+We6NdHx0JEz+oPOE0M/HxZ8HAVGOy2nCJ1Dnck2gXTu0vGh/ccMPKcBfw2kUqjeiQsnHeti2QAZh/rQVHwuKYiMyaqz1Hv7Mm9BEpOs81qrREW12nT3vLQ+AxKfx07akALJ4tu7ufJs7NIQ3oDIenITV2DtMmxEpL+rLtYS+kq2JIdU8PP+u3Qr63CpW9c27jUajheRFxkfuhyEqtbRHVE2Zw6RkzP83UMmWX/OeI5si4/tzK15Ec0vTJ00HPNzCxp0mtIWRZr1Zb7ixzIZGWd4R7AAp53i2lTuhnKDPQzFxi2Ar5yEeVnRkivn7GaiDC26IXXQtwbTWw35/6E9MGdn0xAj+a1+U/5M9GLCzsE2ZT+RmnwakP3Y4M/q0wB3gABRRiJZrz7fRC5QdR4KHs7c1Q2iY+6vc6WqquhvN8qhPCHuyqlmOEtUwxLSGeSqTsgOC1pEVE9SZjiwizMG/Y6PPklww8eHSSHR+i2gdYea3FEjp1vu8heFjn6Jr9FspzYbj9VzbxYkfbnLh5vLQB9CyRrrs2LR9zCoRv2NmTUu7Xd2K3fP/JwDDqe0cxOa05DdN1VksLLIwgY5UaWtXE= 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: 20 Dec 2024 04:48:14.7810 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f9411f1e-0aed-443b-3e9d-08dd20b183d2 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: SJ5PEPF000001CB.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5854 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 functions are to clean up color pipeline when a device driver fails to create its color pipeline. Signed-off-by: Alex Hung --- .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 3 +- drivers/gpu/drm/drm_colorop.c | 41 +++++++++++++++++++ drivers/gpu/drm/vkms/vkms_colorop.c | 3 +- include/drm/drm_colorop.h | 2 + 4 files changed, 45 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 e03e6044f937..80173f00dfd0 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 @@ -200,8 +200,7 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr return 0; cleanup: - for (; i >= 0; i--) - kfree(ops[i]); + drm_colorop_pipeline_destroy(plane); return ret; } diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c index e3dd49c0080d..5245d6a4da39 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -154,6 +154,47 @@ static int drm_colorop_init(struct drm_device *dev, struct drm_colorop *colorop, return ret; } +/** + * drm_colorop_cleanup - Cleanup a drm_colorop object in color_pipeline + * + * @colorop: The drm_colorop object to be cleaned + */ +void drm_colorop_cleanup(struct drm_colorop *colorop) +{ + struct drm_device *dev = colorop->dev; + struct drm_mode_config *config = &dev->mode_config; + + list_del(&colorop->head); + config->num_colorop--; + + if (colorop->state && colorop->state->data) { + drm_property_blob_put(colorop->state->data); + colorop->state->data = NULL; + } + + kfree(colorop->state); + kfree(colorop); +} + +/** + * drm_colorop_pipeline_destroy - Helper for color pipeline destruction + * + * @plane: - The drm_plane structure containing the color_pipeline + * + * Provides a default color pipeline destroy handler for a planes. + */ +void drm_colorop_pipeline_destroy(struct drm_plane *plane) +{ + struct drm_device *dev = plane->dev; + struct drm_mode_config *config = &dev->mode_config; + struct drm_colorop *colorop, *next; + + list_for_each_entry_safe(colorop, next, &config->colorop_list, head) { + drm_colorop_cleanup(colorop); + } +} +EXPORT_SYMBOL(drm_colorop_pipeline_destroy); + /** * drm_colorop_curve_1d_init - Initialize a DRM_COLOROP_1D_CURVE * diff --git a/drivers/gpu/drm/vkms/vkms_colorop.c b/drivers/gpu/drm/vkms/vkms_colorop.c index c418926d5bc0..5cf47a6ef79e 100644 --- a/drivers/gpu/drm/vkms/vkms_colorop.c +++ b/drivers/gpu/drm/vkms/vkms_colorop.c @@ -89,8 +89,7 @@ static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_pr return 0; cleanup: - for (; i >= 0; i--) - kfree(ops[i]); + drm_colorop_pipeline_destroy(plane); return ret; } diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h index 11b474a9b10a..953eea079708 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -367,6 +367,8 @@ static inline struct drm_colorop *drm_colorop_find(struct drm_device *dev, return mo ? obj_to_colorop(mo) : NULL; } +void drm_colorop_pipeline_destroy(struct drm_plane *plane); + int drm_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop, struct drm_plane *plane, u64 supported_tfs, bool allow_bypass);