From patchwork Thu Oct 19 21:21:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13429851 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 747CAC001DF for ; Thu, 19 Oct 2023 21:22:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8DF1E10E549; Thu, 19 Oct 2023 21:22:08 +0000 (UTC) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9FAB310E541; Thu, 19 Oct 2023 21:21:58 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P6DzmsOsfdENv2py6IejkBpXB56iKaSXiDOZ8XGMEKFZydxPqZ5uH3USOPNSt4btqWZp/3ZM00hHrrX7S86p/qaMjTbnb8ie+0GJM81QVTFqEWmLeluG1IbxbTwZapQ/3SFxcX6rUQ1Uy2W6JHXQ7qgE6XJPFjES2s4yhinFg9569r6nOm+FKjTZ2WcwROJfAMkJBzn0Wa63rI5BlEAwMN4+iUOD+td6oFnoPa6BgV78OcpjZHZ5o8A4KhuQ0K4LsFfrsbJAOKGlQj/khvH99WDe8Ktsl31LTbUqiAVkaFEBiGZx65klsrE4L7OtVXcLF3ErR0WVjE6CXaJz8656Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yHyXy2hciyvSg0ekbxocZTuk6pic7viaylZqPDJMptk=; b=k8vV3ZfiN8o5MjAQuii+0rjUhHBdEtT7h09c/pgH0Gmr9og3dmAv8pjZVPfasEkXKQCw8ScNgbyuW7XghwcbPkgE8bqP/9/VnGxMfEqlrR2nOex392gfCmrwoy1a5NkPs8uCKTnvq2n7ASXnMqj57DtyBc+zMzczX6a1mXoJxmMrmSrHjN2WH50rO20zlUwZn0iK8cNdlFJTGIil3TeT71j+OMS7bk7grzlc5VVJ5NMOIJ86kdCsEn4gCBc6qgNoD+qIQ2NB5Zb8WybZbmrGRU8XTd6esq/Hdl68zw9G/UCPrOA37QYoKWPdHS6SY1YclHjZzUqCy1ADQ6/cnmHjMg== 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 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=yHyXy2hciyvSg0ekbxocZTuk6pic7viaylZqPDJMptk=; b=ZYlcr1dAVzADDioQfQ/fWgFwn8BkNrTaPlE4hIy55FItJyjcTOO70//5ChGjhb8ZyeQLs1RjWqwTqBWm8AqC4dlXNieblCP3nHhjrQiaGgnRqGXkGLkCD+MC0617ko/hTN6dWbYFstcUAE2JAdOYJWR+1IfUasrnonMlD/1uwc4= Received: from BL1PR13CA0316.namprd13.prod.outlook.com (2603:10b6:208:2c1::21) by MW6PR12MB8833.namprd12.prod.outlook.com (2603:10b6:303:23f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Thu, 19 Oct 2023 21:21:56 +0000 Received: from BL02EPF0001A103.namprd05.prod.outlook.com (2603:10b6:208:2c1:cafe::f4) by BL1PR13CA0316.outlook.office365.com (2603:10b6:208:2c1::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.8 via Frontend Transport; Thu, 19 Oct 2023 21:21:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL02EPF0001A103.mail.protection.outlook.com (10.167.241.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6907.20 via Frontend Transport; Thu, 19 Oct 2023 21:21:55 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 19 Oct 2023 16:21:51 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 19 Oct 2023 16:21:37 -0500 Received: from hwentlanrmb.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Thu, 19 Oct 2023 16:21:36 -0500 From: Harry Wentland To: Subject: [RFC PATCH v2 01/17] drm/atomic: Allow get_value for immutable properties on atomic drivers Date: Thu, 19 Oct 2023 17:21:17 -0400 Message-ID: <20231019212133.245155-2-harry.wentland@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231019212133.245155-1-harry.wentland@amd.com> References: <20231019212133.245155-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A103:EE_|MW6PR12MB8833:EE_ X-MS-Office365-Filtering-Correlation-Id: 7da49bb6-3aa2-489e-e355-08dbd0e96b6c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nXoJBDoP+N0pUtGru7qRSihG2Ya756MUavZyf6vfAQOgG61tEtdZM0TmPTnMyllVUVUZWfsAyauTqS/Vwp+/w/FTPWKbJZzEjBlyD/jlbwgss52ZyBSCNQLRphJ2l1Dd1FAB74cNlms++ATF67q6qEXSLcANeXt9EBgT9aJtjAm2uQ7zGfSB6WApJrKmOkV9m7/HbrNoriiMs7pTXd2CdyRi733vQaHLS8Z/cmIQbqZxVRk4EleoNsTjIvlrDftDMXxu2o9gSVJfg2cSTP6C7GbZ1Wrn6VxDQrp3Fz4lp3kHRfFfySdcmS95DmN7nLBmdOdmRLDypQqrfLTB3F7d7lPQxbEATRH13tHwkI5uIqm7vQbv47cW6sWCeLtElUfGhVE4juOBiOWOfh3a4U7eoQLo2RNaWVu/DZW/U249o7T+bSgKxJ6ZIEsVelKf3kYZCMHBYE43iIg/M1tUkGXCR4LR8xFNxXl3BBhPcEJp/PfSgBESpSpEMc9A30t5dvAlHrmnnjdNNkboT/vqCO8wsITleewYOHgpxeAN6c+rW1AWmTd9MouNi7dSw3ZoRuDYcD4af5v5zn04h3+yb0C03xaD7LXYbKA29rsfGMXQvsGit2V0p1mQHN8tmAcY+hpsdMrA8y2nTPUFB7t0MSyRi3ThQwou55WFEsx9wbhTq6HmxBpz2Lxw79FkbZUbWl1VoPErDZB3Nqft2k489QUUbe2hoEchGWpWMXzygZEB+iA11o8p8YV/6+bFbFGNtZdRcUoGiqKQ5BZLlQK9retiWQ== 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:(13230031)(4636009)(396003)(346002)(136003)(376002)(39860400002)(230922051799003)(82310400011)(64100799003)(1800799009)(186009)(451199024)(36840700001)(40470700004)(46966006)(478600001)(6666004)(7696005)(86362001)(356005)(82740400003)(81166007)(36756003)(40460700003)(336012)(1076003)(66574015)(36860700001)(426003)(83380400001)(316002)(70586007)(54906003)(8676002)(8936002)(7416002)(6916009)(70206006)(2906002)(5660300002)(26005)(2616005)(4326008)(47076005)(40480700001)(44832011)(41300700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2023 21:21:55.1000 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7da49bb6-3aa2-489e-e355-08dbd0e96b6c 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: BL02EPF0001A103.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB8833 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: , Cc: Sasha McIntosh , Liviu Dudau , Victoria Brekenfeld , =?utf-8?q?Michel_D=C3=A4nzer?= , Arthur Grillo , Sebastian Wick , Shashank Sharma , wayland-devel@lists.freedesktop.org, =?utf-8?q?Jonas_=C3=85dahl?= , Uma Shankar , Abhinav Kumar , Naseer Ahmed , Melissa Wen , Aleix Pol , Christopher Braga , Pekka Paalanen , Hector Martin , Xaver Hugl , Joshua Ashton Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" drm_colorops use immutable properties, for type and next. Even though drivers create these properties at initialization they will need to look at the properties when parsing a color pipeline for programming during an atomic check or commit operation. This aligns the get_value call with behavior of the set_value call. Signed-off-by: Harry Wentland Cc: Ville Syrjala Cc: Pekka Paalanen Cc: Simon Ser Cc: Harry Wentland Cc: Melissa Wen Cc: Jonas Ådahl Cc: Sebastian Wick Cc: Shashank Sharma Cc: Alexander Goins Cc: Joshua Ashton Cc: Michel Dänzer Cc: Aleix Pol Cc: Xaver Hugl Cc: Victoria Brekenfeld Cc: Sima Cc: Uma Shankar Cc: Naseer Ahmed Cc: Christopher Braga Cc: Abhinav Kumar Cc: Arthur Grillo Cc: Hector Martin Cc: Liviu Dudau Cc: Sasha McIntosh --- drivers/gpu/drm/drm_mode_object.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_mode_object.c b/drivers/gpu/drm/drm_mode_object.c index ac0d2ce3f870..c9b1cd48547a 100644 --- a/drivers/gpu/drm/drm_mode_object.c +++ b/drivers/gpu/drm/drm_mode_object.c @@ -351,7 +351,8 @@ static int __drm_object_property_get_value(struct drm_mode_object *obj, int drm_object_property_get_value(struct drm_mode_object *obj, struct drm_property *property, uint64_t *val) { - WARN_ON(drm_drv_uses_atomic_modeset(property->dev)); + WARN_ON(drm_drv_uses_atomic_modeset(property->dev) && + !(property->flags & DRM_MODE_PROP_IMMUTABLE)); return __drm_object_property_get_value(obj, property, val); } From patchwork Thu Oct 19 21:21:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13429850 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 87339C004C0 for ; Thu, 19 Oct 2023 21:22:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7017D10E54C; Thu, 19 Oct 2023 21:22:03 +0000 (UTC) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2060d.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eab::60d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0185E10E541; Thu, 19 Oct 2023 21:21:58 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MwEQw0wXAXlde1cfd3bxx3+tNSwv4/C2o9aqsW25q7GG4hk5w6nuJdTjekpzt0IvEglNAdy/kZXNpeVlijUU88Y42gLMFmMSgnXCdehgqSY14/warByyyFa0b4zwcvYy9SulOHiBBIahF7lmzahQ0OipGgM7NAZjjk68tSs1B9Msvl+7TUq0no38k5Cm0/aaar4UObQwa417fZp36N4OLGAVj5K2VB8v2J3xZZ61O4DmVVTaVbRy+AlmEbBAdAQ3tJpX5GNIMvmGB4BAMvB2ZrLJqcF5HCkNDn+FBXUajJwVLqbQueFH9rCUmXKe0JTVReeQJf0hFdSvGTkD89kvCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9DLYzvGEMv0IDMqahuWSqExac14WlEC6dktqRTDQ4IM=; b=RM/P44yYOjlvgYDEyZ/72Ja1wl7xnHeDi9e6EEMZCWr4xoRDlZfzlh6oGaM8Kb+WlnJ5HEOjq4IhpZ64IhYLgFiTkxfTTTJPVCJqwrskTafxOg9zDjwu2H8HyBpNqbYM9DmPmeynrXJKCXF7lgEu8xozOkzKQ4ruQg8oaZjrXrisIXoCF08iJRj+dOGPHPaggB3wzuWd/QAHGVJS7+lczjInIL8hsKBWp2RfFTUvmeef1s9mxCfIaMhwZgC3AeDw/LF/F8IhOcXLaDLlyB8mJHfctbRdbJ5XNgHbK42WX+XKY/iL16bg2LJs33JnNm9IzvrbPNdkJBEbgIS+ITsdNw== 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 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=9DLYzvGEMv0IDMqahuWSqExac14WlEC6dktqRTDQ4IM=; b=qHOImsBG+eIXxBqvQGtBaZ2VpjuzmJe+aVoUkKEXNbbKE0XhBEVqlFLgdXaf79iSf4taG7X8gvJjdBGja1V/yl/zNJ97U/mErFdD3LmdXMm+KLmOop63LDTxkDghE7kdCzT8qFDl32rR8TBhwkd1/HUe8xwVC0q4xj+Jtk2VChU= Received: from MN2PR03CA0002.namprd03.prod.outlook.com (2603:10b6:208:23a::7) by PH0PR12MB8821.namprd12.prod.outlook.com (2603:10b6:510:28d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.21; Thu, 19 Oct 2023 21:21:56 +0000 Received: from BL02EPF0001A105.namprd05.prod.outlook.com (2603:10b6:208:23a:cafe::6b) by MN2PR03CA0002.outlook.office365.com (2603:10b6:208:23a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.21 via Frontend Transport; Thu, 19 Oct 2023 21:21: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 BL02EPF0001A105.mail.protection.outlook.com (10.167.241.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6907.21 via Frontend Transport; Thu, 19 Oct 2023 21:21:56 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 19 Oct 2023 16:21:51 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 19 Oct 2023 16:21:38 -0500 Received: from hwentlanrmb.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Thu, 19 Oct 2023 16:21:37 -0500 From: Harry Wentland To: Subject: [RFC PATCH v2 02/17] drm: Don't treat 0 as -1 in drm_fixp2int_ceil Date: Thu, 19 Oct 2023 17:21:18 -0400 Message-ID: <20231019212133.245155-3-harry.wentland@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231019212133.245155-1-harry.wentland@amd.com> References: <20231019212133.245155-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A105:EE_|PH0PR12MB8821:EE_ X-MS-Office365-Filtering-Correlation-Id: 930db49a-9797-416e-7a27-08dbd0e96bfe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CiRbx2NTtM6EpfVbX5NkVDt0lP30dIietC9OqC8nL3gbg95iqbMUQS31leeecN49bhDKBZlzCSuvQsE/uDjZTz9vcI2emW9X1e67SQw+fqjSR7wYcEwGv8qHZZfI0FaGRTt5+5cU+yx/K1ktpjVWThlapBgMkpkq/5BYVXub0k/bEGiekDuiUEb+DTFZw4A4q9zmBrVSOb/ygm4/2nPLgNpFeDpKAmPp5osxi4yWPbst13DxR9dzUPTY8eWpXkqZqcxNdzrGW2/dd5lcDLw62VHvMU4jpxC9ThBo+7u+prg1tztMi/iS+PM8F9n94aWhb5toNVKnos52SIWiwcrfEuBh4RkQ/3AklRyTduYw9D6STUJEcsfZPygfX3o1YSrkxFm5iP9cHElIXBVoLrH54minUJ+kyowW5DpKoLlEb/IXhkNdO7YtVcjjiBrl4ClBoZMLaDpNelJv3HdCSl+Kzp0slBtdUjKOqpt/L0KgU/MNOjokB1I4SUwQwm3UG7s3VvKfvrZLEr+P6uABRDknXdEnSgkdWsFN/NitPaQ5nlIxZWJ5NBjscpDx2H5+aVR0K6iBx9O37PbPpzZ3pu6R4GrB/QWclYHFsQjtXZ7Gi7AkTKivgMOFswsEQZxwuJ9jZcvGfvC0NjA+V+/GUOLitQy6U8yOFF02u6s+1xaCBXCq/4Tl7PYhUSPJTJIgo9ynoNilaLsA7nEDrmH0mgXvjoLyv1iCIzjV5f235Ma8VqjvbRiw/GIwerSBfCqUXA5919/l2pKiSaX4C9oZ03i54w== 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:(13230031)(4636009)(376002)(346002)(136003)(396003)(39860400002)(230922051799003)(64100799003)(1800799009)(451199024)(82310400011)(186009)(36840700001)(40470700004)(46966006)(81166007)(7416002)(82740400003)(40460700003)(8936002)(4326008)(8676002)(41300700001)(5660300002)(44832011)(356005)(86362001)(2906002)(70206006)(40480700001)(2616005)(7696005)(478600001)(47076005)(66574015)(336012)(6666004)(426003)(36756003)(1076003)(83380400001)(26005)(54906003)(70586007)(36860700001)(6916009)(316002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2023 21:21:56.0385 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 930db49a-9797-416e-7a27-08dbd0e96bfe 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: BL02EPF0001A105.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8821 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: , Cc: Sasha McIntosh , Liviu Dudau , Victoria Brekenfeld , =?utf-8?q?Michel_D=C3=A4nzer?= , Arthur Grillo , Sebastian Wick , Shashank Sharma , wayland-devel@lists.freedesktop.org, =?utf-8?q?Jonas_=C3=85dahl?= , Uma Shankar , Abhinav Kumar , Naseer Ahmed , Melissa Wen , Aleix Pol , Christopher Braga , Pekka Paalanen , Hector Martin , Xaver Hugl , Joshua Ashton Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Unit testing this in VKMS shows that passing 0 into this function returns -1, which is highly counter- intuitive. Fix it by checking whether the input is >= 0 instead of > 0. Signed-off-by: Harry Wentland Cc: Ville Syrjala Cc: Pekka Paalanen Cc: Simon Ser Cc: Harry Wentland Cc: Melissa Wen Cc: Jonas Ådahl Cc: Sebastian Wick Cc: Shashank Sharma Cc: Alexander Goins Cc: Joshua Ashton Cc: Michel Dänzer Cc: Aleix Pol Cc: Xaver Hugl Cc: Victoria Brekenfeld Cc: Sima Cc: Uma Shankar Cc: Naseer Ahmed Cc: Christopher Braga Cc: Abhinav Kumar Cc: Arthur Grillo Cc: Hector Martin Cc: Liviu Dudau Cc: Sasha McIntosh --- include/drm/drm_fixed.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/drm/drm_fixed.h b/include/drm/drm_fixed.h index 6ea339d5de08..0c9f917a4d4b 100644 --- a/include/drm/drm_fixed.h +++ b/include/drm/drm_fixed.h @@ -95,7 +95,7 @@ static inline int drm_fixp2int_round(s64 a) static inline int drm_fixp2int_ceil(s64 a) { - if (a > 0) + if (a >= 0) return drm_fixp2int(a + DRM_FIXED_ALMOST_ONE); else return drm_fixp2int(a - DRM_FIXED_ALMOST_ONE); From patchwork Thu Oct 19 21:21:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13429849 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 2356DC001DF for ; Thu, 19 Oct 2023 21:22:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B198B10E545; Thu, 19 Oct 2023 21:22:02 +0000 (UTC) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2040.outbound.protection.outlook.com [40.107.220.40]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7860D10E542; Thu, 19 Oct 2023 21:22:00 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PYQz5MeujiWOVF0zJqTBIqJTAx9FlhfFfiogl2LIA0l11QDonrwIePCGOBh9ARXKKH1S+tujB/eG1toLZvwMcFBByZ64lSu9I0gsFyyHzWqY1zrLEv6/rfN/ezyVzAAEsBYPyBA6AqK5Na5kM7mln+nmKOx6sAmuSro/Va+4OelWrVNW7GI3Xt/AtArO0gwhlXIrAHjv/jHX5OeVxp649bu4nufDvpXwzfpDuyrwD+xckNE/5YACnelPMjZ+Myih77oJPO1qDQPuyocaKf6iKqk0QDgBW3ut/e1Q9qF4VDs8ZJyx13YHtFLEozqqvEYKINGuEeaZdu7nWokkQDSmGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LLilZR0ghwRwX3dN2z7hPDxqBvmYxPVG26jLiuH3Ito=; b=kZhOdr8PCNdgpB6OypxPKDV1u3kpl8rLq0ALm2lrHJlin3qKCk0N4ea+QoPZZ94a92TzxoR32xl+BviiMsLShKKJYbDaePbrIHUkjwErx14VkvBT28r54rw2pjREi9pOc3VNEBl3v9JSHx72vu/01dp/SQa+Kg586eRJgUNd6cHseAAJiVGJKNFVviFxfbdIKzIuvXc42m5zs5MBboNsU7+NA8QwllrsG5cbznQUwXP0xVjGKgjEZfeBG0s5a3Nx1Wue72eblkD+66br2Kg1seFeEYcXQcGn05jT0R4Mev9OIUuXsXtxDSRdrTcc9cnnby5hKnzbDKPe6+HO9IVOAA== 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 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=LLilZR0ghwRwX3dN2z7hPDxqBvmYxPVG26jLiuH3Ito=; b=ZwRC6y0sEzzqCCEs9JosTIHaAzMIhV7s1/PRtJb4ByZfRMmQtOVRmPLQbmkwyGqi+6YP037wLyTJ0SI865Zrp06TnZV6ha0Qf6LUMngLZiICwHI8sarCxY/ke7wdMukL4o7SQWP2v8SWO43PCrNyS1+9Y4e0JYUmKiKsJQ3d2i0= Received: from BL1PR13CA0314.namprd13.prod.outlook.com (2603:10b6:208:2c1::19) by DM4PR12MB5841.namprd12.prod.outlook.com (2603:10b6:8:64::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Thu, 19 Oct 2023 21:21:56 +0000 Received: from BL02EPF0001A103.namprd05.prod.outlook.com (2603:10b6:208:2c1:cafe::38) by BL1PR13CA0314.outlook.office365.com (2603:10b6:208:2c1::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.21 via Frontend Transport; Thu, 19 Oct 2023 21:21: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 BL02EPF0001A103.mail.protection.outlook.com (10.167.241.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6907.20 via Frontend Transport; Thu, 19 Oct 2023 21:21:56 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 19 Oct 2023 16:21:52 -0500 Received: from hwentlanrmb.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Thu, 19 Oct 2023 16:21:51 -0500 From: Harry Wentland To: Subject: [RFC PATCH v2 03/17] drm/vkms: Create separate Kconfig file for VKMS Date: Thu, 19 Oct 2023 17:21:19 -0400 Message-ID: <20231019212133.245155-4-harry.wentland@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231019212133.245155-1-harry.wentland@amd.com> References: <20231019212133.245155-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A103:EE_|DM4PR12MB5841:EE_ X-MS-Office365-Filtering-Correlation-Id: 3aac46b5-94f4-474a-3d14-08dbd0e96c29 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9T0omeq2N+GOJ1ZVMrDmZyt9qhsQkJBjjpKe+BqxZuf2k167MSYqXnjoWMSgx39ZgqsPnUSyc45/1CRoUdFK+19FWf1W1NDdVhugGlawlt1gUuJgok3i344wzVW//+TPsjVZgBnY4ejkc/GbyELLHS/GnRzrM/Wl7+rpt/qBv7XF4grat1RsQACYWYVtRTCFEDP/YoxPh4mjfN2eGufHeHo9VTpDfhpeuxfNx9pg7f1qLig/TIH2ekDzrm/6NEgzECzRu2W9dLhVjUX/8vygDYhwcdBf3lxG1wfu09zmVlhQlxiHB/4tD4lG9HvQI6ttNCDe2LNK+o6BgBsR2MhiAklTSWNAz6uVtZU6m6axGAGn28GFBwCL3Zut/XKWy4kr6nzb/fQmRsOeFx/FVzYhWFn72mR5+p9axqPU1kAPlsf2nujM/yY/3td+SU86hWGaGZ4tyJU67Cbq+NqbvbNAYAxttz/v18j7Pxu/VbAzxUkP65bYXnRWQMIoLv0kp/ok1Ra/CQCbOE34mVPoyFcpfTpbSSEKlOfNkMJwbUZriuOJW0zy8Mbxy3LQvMI7Sizq/1tNcMQz7VJ+mJqnocqvbTvw8/h8fKKJxZWBm7vdWNqOLV4slAc/RtInfPoJh1SJwRgNNwTUzH1MkvzvL/3sn8Wc6ayCdXJNaI7ibDLQkH94UnmISo2X+SLD82JeChmx8Rjqdf6Mb0FiM0cXIPAvI0E506JBf7W9THi/xi28FPUmlJ00yNnl7/paCGwIRck3RPEUCL4V6UMmHVE9XzrOeQ== 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:(13230031)(4636009)(39860400002)(136003)(396003)(376002)(346002)(230922051799003)(64100799003)(1800799009)(186009)(82310400011)(451199024)(46966006)(40470700004)(36840700001)(83380400001)(6666004)(7696005)(478600001)(356005)(82740400003)(2616005)(26005)(81166007)(336012)(1076003)(426003)(36860700001)(40460700003)(5660300002)(41300700001)(8936002)(4326008)(70586007)(8676002)(6916009)(44832011)(47076005)(54906003)(40480700001)(70206006)(86362001)(2906002)(7416002)(36756003)(316002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2023 21:21:56.3187 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3aac46b5-94f4-474a-3d14-08dbd0e96c29 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: BL02EPF0001A103.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5841 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: , Cc: Sasha McIntosh , Liviu Dudau , Victoria Brekenfeld , =?utf-8?q?Michel_D=C3=A4nzer?= , Arthur Grillo , Sebastian Wick , Shashank Sharma , wayland-devel@lists.freedesktop.org, =?utf-8?q?Jonas_=C3=85dahl?= , Uma Shankar , Abhinav Kumar , Naseer Ahmed , Melissa Wen , Aleix Pol , Christopher Braga , Pekka Paalanen , Hector Martin , Xaver Hugl , Joshua Ashton Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This aligns with most other DRM drivers and will allow us to add new VKMS config options without polluting the DRM Kconfig. Signed-off-by: Harry Wentland Cc: Ville Syrjala Cc: Pekka Paalanen Cc: Simon Ser Cc: Harry Wentland Cc: Melissa Wen Cc: Jonas Ådahl Cc: Sebastian Wick Cc: Shashank Sharma Cc: Alexander Goins Cc: Joshua Ashton Cc: Michel Dänzer Cc: Aleix Pol Cc: Xaver Hugl Cc: Victoria Brekenfeld Cc: Sima Cc: Uma Shankar Cc: Naseer Ahmed Cc: Christopher Braga Cc: Abhinav Kumar Cc: Arthur Grillo Cc: Hector Martin Cc: Liviu Dudau Cc: Sasha McIntosh --- drivers/gpu/drm/Kconfig | 14 +------------- drivers/gpu/drm/vkms/Kconfig | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 13 deletions(-) create mode 100644 drivers/gpu/drm/vkms/Kconfig diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index 48ca28a2e4ff..61ebd682c9b0 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -286,19 +286,7 @@ config DRM_VGEM as used by Mesa's software renderer for enhanced performance. If M is selected the module will be called vgem. -config DRM_VKMS - tristate "Virtual KMS (EXPERIMENTAL)" - depends on DRM && MMU - select DRM_KMS_HELPER - select DRM_GEM_SHMEM_HELPER - select CRC32 - default n - help - Virtual Kernel Mode-Setting (VKMS) is used for testing or for - running GPU in a headless machines. Choose this option to get - a VKMS. - - If M is selected the module will be called vkms. +source "drivers/gpu/drm/vkms/Kconfig" source "drivers/gpu/drm/exynos/Kconfig" diff --git a/drivers/gpu/drm/vkms/Kconfig b/drivers/gpu/drm/vkms/Kconfig new file mode 100644 index 000000000000..1816562381a2 --- /dev/null +++ b/drivers/gpu/drm/vkms/Kconfig @@ -0,0 +1,15 @@ +# SPDX-License-Identifier: GPL-2.0+ + +config DRM_VKMS + tristate "Virtual KMS (EXPERIMENTAL)" + depends on DRM && MMU + select DRM_KMS_HELPER + select DRM_GEM_SHMEM_HELPER + select CRC32 + default n + help + Virtual Kernel Mode-Setting (VKMS) is used for testing or for + running GPU in a headless machines. Choose this option to get + a VKMS. + + If M is selected the module will be called vkms. From patchwork Thu Oct 19 21:21:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13429854 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 A805BC07480 for ; Thu, 19 Oct 2023 21:22:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 274B310E540; Thu, 19 Oct 2023 21:22:11 +0000 (UTC) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2040.outbound.protection.outlook.com [40.107.92.40]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2B88010E545; Thu, 19 Oct 2023 21:22:00 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aFU4zfOGjCjtxvLlWkrSx9+k0zOdfijjDlhJViD5KHr1Kio1bfJXnpcgqHZYIbLA71d2EveZuAZmgjvbIi2nSVokUTXkVax+XU3zlJRnlsTgi8MftZETcl6ZXL8I2aQvh3kgv4wTJ+sLBw3Y/GBc1wgKeOWTH7ZQHxXtGh0ipIRaiP2MiqzZ+xSSNzTsMZvycDT7r6xHpERgToYURjGyB1PG3TQUxpW7QKUU1NbXP5gwj5qM+Pm564Z89lz5XKgkx9kRjEXr/Jungn7Q/NAeig9As9i4LnGC/ZvO2imYjkYs1SB9TS4bmrgSCZZzbZ9tqMqAJ8cbHTpRNoQIRE71XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=GclRxBmu5NVYrsQxBuoXS07ZIxXO+YUpKHyMpsOMrjQ=; b=mTo2OFsDHqgl3pPxE2tjQgAqBhEMBffFUjCmxWhRzhQhuS/HyS5dowjZJMhjOreq6p3QMJGUjkTLfAfjEGC5VzkC63ID+fkGCOGfb6bCM8dx8mfYAzvJGhSrh4gZKCOJaezNrtH9yKyDn0BuEuJJvW7P9bT9l3325nGRkPVa9AGLeycmw3oI0ldOW4TTXMJ80s9/S2YAZZ9PKoplKDv1hFC5fT+YI7qSsmwBLUwtI3EWOt8GP6aU4m9KcknHSGrsxzqqIRKDLd5v8LudvQJOz6Fsy7emhAG+wJ7/dmmS7CB1R48S96m5NGhChjui81pvf98kCsjPIPdo0cVZUU0nZg== 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 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=GclRxBmu5NVYrsQxBuoXS07ZIxXO+YUpKHyMpsOMrjQ=; b=uP0TKIEp6KxsrrHGf2UN7xYw5BGHOIpn1YWe5N+8KaqdLl8xVPEqRCOoMbr3+jyjyXZ2glj6SUdlUfP8HwWZvB4AlCRf5GJjfHl8yNXnWj8vajMgFukscqt/375n3A/tyI4jm+QULCwQCRH1bPGOvE8lS24gRCcdnxVTBm8kE/M= Received: from BL1PR13CA0325.namprd13.prod.outlook.com (2603:10b6:208:2c1::30) by PH7PR12MB6562.namprd12.prod.outlook.com (2603:10b6:510:212::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.26; Thu, 19 Oct 2023 21:21:57 +0000 Received: from BL02EPF0001A103.namprd05.prod.outlook.com (2603:10b6:208:2c1:cafe::9e) by BL1PR13CA0325.outlook.office365.com (2603:10b6:208:2c1::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.18 via Frontend Transport; Thu, 19 Oct 2023 21:21: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 BL02EPF0001A103.mail.protection.outlook.com (10.167.241.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6907.20 via Frontend Transport; Thu, 19 Oct 2023 21:21:56 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 19 Oct 2023 16:21:53 -0500 Received: from hwentlanrmb.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Thu, 19 Oct 2023 16:21:52 -0500 From: Harry Wentland To: Subject: [RFC PATCH v2 04/17] drm/vkms: Add kunit tests for VKMS LUT handling Date: Thu, 19 Oct 2023 17:21:20 -0400 Message-ID: <20231019212133.245155-5-harry.wentland@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231019212133.245155-1-harry.wentland@amd.com> References: <20231019212133.245155-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A103:EE_|PH7PR12MB6562:EE_ X-MS-Office365-Filtering-Correlation-Id: 04cd6582-e60a-4dd1-3a2c-08dbd0e96c67 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 07sA1JL0rm4ebERK3lXz0+BIXfpi7Z6LBvsvnyWbXXob0tI3clnR6DiKsYi2+yBb6D+ImbmiJN5oCW2fREwrSPgz9Elu4IdtQRmulrUG6Vq0r3I1W5vYQTq816FnTIs2LSMEfcesLGTqm47mNkZHzQcnEqHuur3AcTVbU/zc/jBWkwU4fOJ/PL/u1kxITDB9tOCS6MN8+8HYqYb03NoqIE5p/MBH9OhLQ3LMq6KJBOGIVgu9HPGsjzbc+zpaq6g4rHGis5kmQ8TOP5GYZa+yo487Dt5gsogtj3L3S94h3IJ+APJu4QlMj0rgHNtcyAOgWh2KFhKWmgO/k+nAIo4r7mR6w7kdRXxb0WYU6111Tewe/G2MRuI9aOfQ7SvZrRz1/LKLHB0gIjPNbyErGakNW/+b9Jr2lpVoe4DkjEAj6nKoebHnh+y9P7a8MY+xDqNeXzlBod8jqVMppXhwf0ITAMNaVE+OHTUrVteNgjZlkjTOi+Pbnl8F9xVqPhzh8IVWGjrQm4oG5J1KA9Fn3K5jl6+i+bLJEHs4kaQD+6PYxL/D8e5p8FZm4lN7Ma2bPLgEuvqFxtxfwBHqrThupTzbsv7Zf8GC/9581zXdvFm8Mx2NZb1xwXhn2Qo2PhdCUCJY4lXq2dIEOhNiWMCW3Ondfb2JvS+9PLwRaO+MWGRW6yrcS+gL/WbyCHDfeoI+BcSXoIrU+Aeybs4Gpp1GBNABmYq6wpEfOvL6Ci11SEGQUadCLAzH+4FisUUDlKQWcg/ss6P7DARrWK9ULQCejAR09g== 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:(13230031)(4636009)(136003)(39860400002)(346002)(396003)(376002)(230922051799003)(451199024)(64100799003)(1800799009)(82310400011)(186009)(46966006)(40470700004)(36840700001)(40460700003)(2906002)(70586007)(70206006)(54906003)(316002)(6916009)(6666004)(478600001)(8676002)(8936002)(36756003)(5660300002)(41300700001)(44832011)(4326008)(86362001)(7416002)(7696005)(47076005)(36860700001)(2616005)(1076003)(81166007)(83380400001)(356005)(26005)(426003)(336012)(40480700001)(82740400003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2023 21:21:56.7250 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 04cd6582-e60a-4dd1-3a2c-08dbd0e96c67 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: BL02EPF0001A103.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6562 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: , Cc: Sasha McIntosh , Liviu Dudau , Victoria Brekenfeld , =?utf-8?q?Michel_D=C3=A4nzer?= , Arthur Grillo , Sebastian Wick , Shashank Sharma , wayland-devel@lists.freedesktop.org, =?utf-8?q?Jonas_=C3=85dahl?= , Uma Shankar , Abhinav Kumar , Naseer Ahmed , Melissa Wen , Aleix Pol , Christopher Braga , Pekka Paalanen , Hector Martin , Xaver Hugl , Joshua Ashton Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Debugging LUT math is much easier when we can unit test it. Add kunit functionality to VKMS and add tests for - get_lut_index - lerp_u16 Signed-off-by: Harry Wentland Cc: Ville Syrjala Cc: Pekka Paalanen Cc: Simon Ser Cc: Harry Wentland Cc: Melissa Wen Cc: Jonas Ådahl Cc: Sebastian Wick Cc: Shashank Sharma Cc: Alexander Goins Cc: Joshua Ashton Cc: Michel Dänzer Cc: Aleix Pol Cc: Xaver Hugl Cc: Victoria Brekenfeld Cc: Sima Cc: Uma Shankar Cc: Naseer Ahmed Cc: Christopher Braga Cc: Abhinav Kumar Cc: Arthur Grillo Cc: Hector Martin Cc: Liviu Dudau Cc: Sasha McIntosh --- drivers/gpu/drm/vkms/Kconfig | 5 ++ drivers/gpu/drm/vkms/Makefile | 2 + drivers/gpu/drm/vkms/tests/.kunitconfig | 4 ++ drivers/gpu/drm/vkms/tests/Makefile | 4 ++ drivers/gpu/drm/vkms/tests/vkms_color_tests.c | 64 +++++++++++++++++++ drivers/gpu/drm/vkms/vkms_composer.c | 4 +- drivers/gpu/drm/vkms/vkms_composer.h | 11 ++++ 7 files changed, 92 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_tests.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 1816562381a2..372cc5fa92f1 100644 --- a/drivers/gpu/drm/vkms/Kconfig +++ b/drivers/gpu/drm/vkms/Kconfig @@ -13,3 +13,8 @@ config DRM_VKMS a VKMS. If M is selected the module will be called vkms. + +config DRM_VKMS_KUNIT_TESTS + tristate "Tests for VKMS" if !KUNIT_ALL_TESTS + depends on DRM_VKMS && KUNIT + default KUNIT_ALL_TESTS diff --git a/drivers/gpu/drm/vkms/Makefile b/drivers/gpu/drm/vkms/Makefile index 1b28a6a32948..d3440f228f46 100644 --- a/drivers/gpu/drm/vkms/Makefile +++ b/drivers/gpu/drm/vkms/Makefile @@ -9,3 +9,5 @@ vkms-y := \ vkms_writeback.o obj-$(CONFIG_DRM_VKMS) += vkms.o + +obj-y += tests/ \ No newline at end of file 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..761465332ff2 --- /dev/null +++ b/drivers/gpu/drm/vkms/tests/Makefile @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0+ + +obj-$(CONFIG_DRM_VKMS_KUNIT_TESTS) += \ + vkms_color_tests.o \ No newline at end of file diff --git a/drivers/gpu/drm/vkms/tests/vkms_color_tests.c b/drivers/gpu/drm/vkms/tests/vkms_color_tests.c new file mode 100644 index 000000000000..843b2e1d607e --- /dev/null +++ b/drivers/gpu/drm/vkms/tests/vkms_color_tests.c @@ -0,0 +1,64 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#include + +#include + +#include "../vkms_composer.h" + +#define TEST_LUT_SIZE 16 + +static struct drm_color_lut test_linear_array[TEST_LUT_SIZE] = { + { 0x0, 0x0, 0x0, 0 }, + { 0x1111, 0x1111, 0x1111, 0 }, + { 0x2222, 0x2222, 0x2222, 0 }, + { 0x3333, 0x3333, 0x3333, 0 }, + { 0x4444, 0x4444, 0x4444, 0 }, + { 0x5555, 0x5555, 0x5555, 0 }, + { 0x6666, 0x6666, 0x6666, 0 }, + { 0x7777, 0x7777, 0x7777, 0 }, + { 0x8888, 0x8888, 0x8888, 0 }, + { 0x9999, 0x9999, 0x9999, 0 }, + { 0xaaaa, 0xaaaa, 0xaaaa, 0 }, + { 0xbbbb, 0xbbbb, 0xbbbb, 0 }, + { 0xcccc, 0xcccc, 0xcccc, 0 }, + { 0xdddd, 0xdddd, 0xdddd, 0 }, + { 0xeeee, 0xeeee, 0xeeee, 0 }, + { 0xffff, 0xffff, 0xffff, 0 }, +}; + +const struct vkms_color_lut test_linear_lut = { + .base = test_linear_array, + .lut_length = TEST_LUT_SIZE, + .channel_value2index_ratio = 0xf000fll +}; + + +static void vkms_color_test_get_lut_index(struct kunit *test) +{ + int i; + + KUNIT_EXPECT_EQ(test, drm_fixp2int(get_lut_index(&test_linear_lut, test_linear_array[0].red)), 0); + + for (i = 0; i < TEST_LUT_SIZE; i++) + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&test_linear_lut, test_linear_array[i].red)), i); +} + +static void vkms_color_test_lerp(struct kunit *test) +{ + KUNIT_EXPECT_EQ(test, lerp_u16(0x0, 0x10, 0x80000000), 0x8); +} + +static struct kunit_case vkms_color_test_cases[] = { + KUNIT_CASE(vkms_color_test_get_lut_index), + KUNIT_CASE(vkms_color_test_lerp), + {} +}; + +static struct kunit_suite vkms_color_test_suite = { + .name = "vkms-color", + .test_cases = vkms_color_test_cases, +}; +kunit_test_suite(vkms_color_test_suite); + +MODULE_LICENSE("GPL"); \ No newline at end of file diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index 3c99fb8b54e2..a0a3a6fd2926 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -91,7 +91,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) +u16 lerp_u16(u16 a, u16 b, s64 t) { s64 a_fp = drm_int2fixp(a); s64 b_fp = drm_int2fixp(b); @@ -101,7 +101,7 @@ static u16 lerp_u16(u16 a, u16 b, s64 t) return drm_fixp2int(a_fp + delta); } -static s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel_value) +s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel_value) { s64 color_channel_fp = drm_int2fixp(channel_value); diff --git a/drivers/gpu/drm/vkms/vkms_composer.h b/drivers/gpu/drm/vkms/vkms_composer.h new file mode 100644 index 000000000000..11c5de9cc961 --- /dev/null +++ b/drivers/gpu/drm/vkms/vkms_composer.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef _VKMS_COMPOSER_H_ +#define _VKMS_COMPOSER_H_ + +#include "vkms_drv.h" + +s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel_value); +u16 lerp_u16(u16 a, u16 b, s64 t); + +#endif /* _VKMS_COMPOSER_H_ */ \ No newline at end of file From patchwork Thu Oct 19 21:21:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13429853 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 2E9A7C00A98 for ; Thu, 19 Oct 2023 21:22:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AB1CF10E54D; Thu, 19 Oct 2023 21:22:09 +0000 (UTC) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2080.outbound.protection.outlook.com [40.107.94.80]) by gabe.freedesktop.org (Postfix) with ESMTPS id 26DF610E542; Thu, 19 Oct 2023 21:22:00 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bA3gPEAXdcyOYHR+Rrqe+Jt6zlPiMXf1ltzISv1YffZUhpcVreHc6tWD4dnWJxR1KF+NhzAL+3lTIouTtgg52ymj6475NY6mWw3BjoyK9BJS9yBJwuTLEmvgJjs19NqugCpIRJ6gj2OfbcXrCr1PyYi+ujBlC7V7ZM1HusSK/usnSPTFxjvIGX+IWs9B6MBZhNdr7TEPJQpkvR9iLUMLHuuINcRgDB4bQ/08v+lRLZxIEbLDXvlFRkm+Wr1MuLtMTMzr5wNqNRybF4w2+8atHt5XYhsS8YBOJV2cVP+4RIYkvcSG7ecMMiHISBKDEASit8S0WI6sbD7P1c1Vfac8Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bLZAgmCFSndkojjyuMbU45qAmsVffkjnMXyJhfP5UZs=; b=kdKl3jgbq/VsalowGhMjgZo/pvjHZRUlLcTmP1/pxNDVjH4myLt7rSu1AIo/xcj9gJoNWcfMU7zQjVt360YSI4UB/h0hY71Kzj6oxluYxKlfiQojJzvLwGx+pNIIFYnYvdrHCgYjHa3mQ1xTxMiultV+d4XtjVz2krwPPl6HlfoyCzs1orSVOEsmOma0hvwKsXF7dL0V9RmKLIQgmmi3mmK3wDkseMZqjHUna/ZUDx+0FEid8ipKVuBrQCBMTrF05wDDCJ2qlTglfwB/6fPqyOp4f6h6hPeDzJal2G+gMRUsqU2XTSQajrhra9cauh0IB8zlieoSBPFaklOul/bveg== 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 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=bLZAgmCFSndkojjyuMbU45qAmsVffkjnMXyJhfP5UZs=; b=e8B0qQWViDhOtakGmVhWQPDaE/E+RSTgIIod8AVq1JL1rOlOoVJ2FXG30Tf46aXb50wkLbfu/bIVHwEhy2QX3yjhjQoBioywP878/rx9fm8YZpP13/0PVA6EWTVGNbaAH5rc+MLE9cU+WyfiKYUyKJrsMTqZa8rO4V2GqdeEPSc= Received: from MN2PR03CA0029.namprd03.prod.outlook.com (2603:10b6:208:23a::34) by DM6PR12MB4121.namprd12.prod.outlook.com (2603:10b6:5:220::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.38; Thu, 19 Oct 2023 21:21:57 +0000 Received: from BL02EPF0001A105.namprd05.prod.outlook.com (2603:10b6:208:23a:cafe::7b) by MN2PR03CA0029.outlook.office365.com (2603:10b6:208:23a::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.26 via Frontend Transport; Thu, 19 Oct 2023 21:21: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 BL02EPF0001A105.mail.protection.outlook.com (10.167.241.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6907.21 via Frontend Transport; Thu, 19 Oct 2023 21:21:57 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) 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.27; Thu, 19 Oct 2023 16:21:55 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 19 Oct 2023 14:21:55 -0700 Received: from hwentlanrmb.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Thu, 19 Oct 2023 16:21:54 -0500 From: Harry Wentland To: Subject: [RFC PATCH v2 05/17] drm/vkms: Avoid reading beyond LUT array Date: Thu, 19 Oct 2023 17:21:21 -0400 Message-ID: <20231019212133.245155-6-harry.wentland@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231019212133.245155-1-harry.wentland@amd.com> References: <20231019212133.245155-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A105:EE_|DM6PR12MB4121:EE_ X-MS-Office365-Filtering-Correlation-Id: e2ed8ab0-50c8-418e-ae11-08dbd0e96c94 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KIs6/QgR1CXSYCqHCzdmFT6XW2HORswA+eLv/gijTimhqvKMvax7TdvxsFqPA/acLi7P3hu9SRj+VjTfMLA0iHGO4bPl4aBdvW/pnPxS1HY1L6R7ZbMQnsiAhzStRNOCmfG3eW3Kr7VcLkQb706VmMb5fsvLlxEbosmEqofE/m/3VGpAMTbyhd6wiw+N4jBYFQh0cu4kbLca+/ApjDsz46HPokdU1sroddki8K1m4EuD/02Cv7tS0F2Ni7aC1mZM1HlyBDxVIic4EmIU44PMLJ5GGZPRCl9/JUJ4apch64R88lHjZIyNd+8B+uw1oIaj3qIYkAAFmjSKDZy76NDMbgPKrpN887XEUv3D0QLFL+3ac9rJmS2RcWAxRU1z7IKq4tS603L/Iv1wGif+cg3WCG3Wy0EmGcsqBmvFd6FyrrszsYqTdQa1opuowyqlFeCbMHGLtZQk9GkHOOpB/TVk849K0UqcTLMNZPqPPpzQfIVvetWd1YMyskOfNSRJf8ofp8x3B4jVoLmBjzR6RPMDByjZGjACTkhF/BMmTVzTzhv1+lbWlp8L+q4CfQbbheFxSLF/QH1jVBFh5ZQpKexV/IdzWzmCe5kiVZ1ACZSZf3FTgKKm9d0KU8BmFzYdLjh13ggnS9k1MOXCBMuSlKo0q12yNjJ2SwtmMlAKJk6kBjIFUgDXn/scQuDnNNqHrmPoOmxiIFT9mJROg4MSzfCcUfwA8XoAYS0lAb04nUdOiec0WXNlqn42MF5YNN2W5uTS7U2mGESKrx5c2qUi47Y2mQ== 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:(13230031)(4636009)(346002)(396003)(376002)(136003)(39860400002)(230922051799003)(1800799009)(186009)(451199024)(82310400011)(64100799003)(40470700004)(36840700001)(46966006)(2616005)(1076003)(7416002)(7696005)(2906002)(44832011)(5660300002)(8676002)(8936002)(4326008)(6666004)(41300700001)(70586007)(54906003)(70206006)(6916009)(83380400001)(40460700003)(316002)(478600001)(336012)(26005)(40480700001)(426003)(47076005)(356005)(36756003)(82740400003)(36860700001)(81166007)(86362001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2023 21:21:57.0229 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e2ed8ab0-50c8-418e-ae11-08dbd0e96c94 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: BL02EPF0001A105.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4121 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: , Cc: Sasha McIntosh , Liviu Dudau , Victoria Brekenfeld , =?utf-8?q?Michel_D=C3=A4nzer?= , Arthur Grillo , Sebastian Wick , Shashank Sharma , wayland-devel@lists.freedesktop.org, =?utf-8?q?Jonas_=C3=85dahl?= , Uma Shankar , Abhinav Kumar , Naseer Ahmed , Melissa Wen , Aleix Pol , Christopher Braga , Pekka Paalanen , Hector Martin , Xaver Hugl , Joshua Ashton Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" When the floor LUT index (drm_fixp2int(lut_index) is the last index of the array the ceil LUT index will point to an entry beyond the array. Make sure we guard against it and use the value of the floot LUT index. Blurb about LUT creation and how first element should be 0x0 and last one 0xffff. Hold on, is that even correct? What should the ends of a LUT be? How does UNORM work and how does it apply to LUTs? Signed-off-by: Harry Wentland Cc: Ville Syrjala Cc: Pekka Paalanen Cc: Simon Ser Cc: Harry Wentland Cc: Melissa Wen Cc: Jonas Ådahl Cc: Sebastian Wick Cc: Shashank Sharma Cc: Alexander Goins Cc: Joshua Ashton Cc: Michel Dänzer Cc: Aleix Pol Cc: Xaver Hugl Cc: Victoria Brekenfeld Cc: Sima Cc: Uma Shankar Cc: Naseer Ahmed Cc: Christopher Braga Cc: Abhinav Kumar Cc: Arthur Grillo Cc: Hector Martin Cc: Liviu Dudau Cc: Sasha McIntosh --- drivers/gpu/drm/vkms/vkms_composer.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index a0a3a6fd2926..cf1dff162920 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -123,6 +123,8 @@ static u16 apply_lut_to_channel_value(const struct vkms_color_lut *lut, u16 chan enum lut_channel channel) { s64 lut_index = get_lut_index(lut, channel_value); + u16 *floor_lut_value, *ceil_lut_value; + u16 floor_channel_value, ceil_channel_value; /* * This checks if `struct drm_color_lut` has any gap added by the compiler @@ -130,11 +132,15 @@ static u16 apply_lut_to_channel_value(const struct vkms_color_lut *lut, u16 chan */ static_assert(sizeof(struct drm_color_lut) == sizeof(__u16) * 4); - u16 *floor_lut_value = (__u16 *)&lut->base[drm_fixp2int(lut_index)]; - u16 *ceil_lut_value = (__u16 *)&lut->base[drm_fixp2int_ceil(lut_index)]; + floor_lut_value = (__u16 *)&lut->base[drm_fixp2int(lut_index)]; + if (drm_fixp2int(lut_index) == (lut->lut_length - 1)) + /* We're at the end of the LUT array, use same value for ceil and floor */ + ceil_lut_value = floor_lut_value; + else + ceil_lut_value = (__u16 *)&lut->base[drm_fixp2int_ceil(lut_index)]; - u16 floor_channel_value = floor_lut_value[channel]; - u16 ceil_channel_value = ceil_lut_value[channel]; + floor_channel_value = floor_lut_value[channel]; + ceil_channel_value = ceil_lut_value[channel]; return lerp_u16(floor_channel_value, ceil_channel_value, lut_index & DRM_FIXED_DECIMAL_MASK); From patchwork Thu Oct 19 21:21:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13429856 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 C0E27C001DF for ; Thu, 19 Oct 2023 21:22:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9CF4910E559; Thu, 19 Oct 2023 21:22:12 +0000 (UTC) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2072.outbound.protection.outlook.com [40.107.92.72]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3F41A10E545; Thu, 19 Oct 2023 21:22:01 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cHm645gHdWhF9XR+f09hoDbYfdfxpja8rGcnNotmycNNITJLt8kfEYnaNMENY4xzeN3TNu+u1e6JwrUCmc9cOrSYxm8XSp5tQqfSYx4w7Kafjg1Q644T8h5fP+/juiegampSOdVq9EC4b03sl/xFg91sIt2i5t9NYGjZ0n1ymYMD8pQF7N/G3iIaNunIWg+bVKCNjiXFbhBAsROq8Ti17OUv16wwCPdQUWibRgDxWo1So7CIqNy8Qj6Q7Gr4RVqKqxIOLE/KV6Igujq3dHb+TVBUd5x5tyl6Y+NKUfyHrKNFWS29Ti5nyPGEf0fEF2yOgDdTEPLarWX7QN1hAAvXcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=U7+SMbaONraBoxcbP54wBE46eArIdjbEPCPDApLiwS0=; b=oDcUN+Tdeqa3/B+sk918w/vp20OCvqgBdtrJiUFsR2v7zP9t1DHlnyKTFwne4tRlq+POch9LB/T9Kfg81sP2AN1jV2y+tld/4sbDDrbvNQAnTqOpjGehpXY0p/Fe5Hy8Eq29A2ToK1m55dGv6elXJQykyyTbXBd3jneq4n3gG5nuUfJTY7R+TJ77j9RgSbk1Hhts05aPGRn2TQV8y4hppiFj+oyIDVXwxvp8/bmOm6e9pDzV4qJFFZcKP7wT1C5eUdKPFW+l0iij3oBKnKWczXEG7lvUKsM5EU/p/HC/11duH4r//WaCeLX2b1+x6wu8RgGNRsJvLsNjQk5n5Cs7Xg== 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 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=U7+SMbaONraBoxcbP54wBE46eArIdjbEPCPDApLiwS0=; b=lvoHk7DwMgk3kGit/lE9uMRrUV2t08JLxkdba9RP2TLM1WJ6DT+Yw/ldmVFnfN88Jq+FrqYYvVpBeU82bL2WTisrruUd2MjH9fgk2O/chKkhe446AeMdnWPDg1CF2rKs3IBYUH0eX762SpnWOztad8jViDB5t7iK4KVkz/y9EB8= Received: from MN2PR07CA0015.namprd07.prod.outlook.com (2603:10b6:208:1a0::25) by CH2PR12MB4232.namprd12.prod.outlook.com (2603:10b6:610:a4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.37; Thu, 19 Oct 2023 21:21:57 +0000 Received: from BL6PEPF0001AB77.namprd02.prod.outlook.com (2603:10b6:208:1a0:cafe::f2) by MN2PR07CA0015.outlook.office365.com (2603:10b6:208:1a0::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.26 via Frontend Transport; Thu, 19 Oct 2023 21:21: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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BL6PEPF0001AB77.mail.protection.outlook.com (10.167.242.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6907.20 via Frontend Transport; Thu, 19 Oct 2023 21:21:57 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 19 Oct 2023 16:21:57 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 19 Oct 2023 14:21:56 -0700 Received: from hwentlanrmb.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Thu, 19 Oct 2023 16:21:55 -0500 From: Harry Wentland To: Subject: [RFC PATCH v2 06/17] drm/doc/rfc: Describe why prescriptive color pipeline is needed Date: Thu, 19 Oct 2023 17:21:22 -0400 Message-ID: <20231019212133.245155-7-harry.wentland@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231019212133.245155-1-harry.wentland@amd.com> References: <20231019212133.245155-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB77:EE_|CH2PR12MB4232:EE_ X-MS-Office365-Filtering-Correlation-Id: 98bafea6-b881-4cc3-55d5-08dbd0e96ccd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: isEP6TVT4V7vj/AjHsvdTPWt38Ybvixtu7kWm5w0iow7D2Xm+xpvqZmmETUiyawR5TKDsK1uziSBe528so6eSoLQcCYCp8UTb2RlcRpq686PWJNDqEOk4EJjaEA8okH01/YrQ8GokNpp4kRimu3XO4CgF9YfL3InlJpV5yLERNeYGUunB1712Dqv93mfWvDFZp4e2VvYmlRvNKiMvVstwxVOAbfSl9TRlHJTH5gul9JAXbVI2lAHp3hGA+RRU2Q+I1baQDFUPEP30aStGVAdLXHy7aMqhfeCRs7mNbim6v6bdTLz6N3oQzXa3GCAs2crsQYANUpb3tk6TEVX5IBux4QP8d/hGSGmvACU+NvDTcDw07kQIkUyPdBttT7YqWHAoSx/3ys/KHMn4f2Nv5TMUcN75EP1e7H9gycxlPsmp41jjjjPajunub+lCJtiqv2BzcRFRdUTwQDxBVfos+x7QDrFC5xfOadogY6/NKFGSJO76NxdUsTTUOiwyjSwk6SL2VvTaG2AIwXoOm1jvQc9vNLkze+rc6dEIty+OTwdX+F6yQoReItX3PEsVh+ewHOKxXereRe02l9kvhrGS5Uscvonz//6axy6kLABCjvTHIOBiQhPEWmffy24E6p2bK1xtF7LVykfWC9qc+attpMJC0k90rjpZqn+xJ/6rG6RvQBh1uNNiedrFq5MJoypiP0d4ee9m0pSkOkZYXCAGtTWISNA77dWu/vyk3vDzacbXI1/RGbp2Hd+oqiSlrF3PFEGPFqih4e/PGwoony4aV+OaQ== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(346002)(376002)(396003)(136003)(39860400002)(230922051799003)(64100799003)(451199024)(186009)(1800799009)(82310400011)(40470700004)(36840700001)(46966006)(8676002)(40460700003)(30864003)(966005)(1076003)(7696005)(26005)(478600001)(4326008)(6666004)(66574015)(6916009)(426003)(2906002)(83380400001)(7416002)(47076005)(5660300002)(8936002)(54906003)(70586007)(316002)(41300700001)(70206006)(44832011)(2616005)(356005)(81166007)(82740400003)(36860700001)(86362001)(336012)(36756003)(40480700001)(66899024)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2023 21:21:57.3941 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 98bafea6-b881-4cc3-55d5-08dbd0e96ccd X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB77.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4232 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: , Cc: Sasha McIntosh , Liviu Dudau , Victoria Brekenfeld , =?utf-8?q?Michel_D=C3=A4nzer?= , Arthur Grillo , Sebastian Wick , Shashank Sharma , wayland-devel@lists.freedesktop.org, =?utf-8?q?Jonas_=C3=85dahl?= , Uma Shankar , Abhinav Kumar , Naseer Ahmed , Melissa Wen , Aleix Pol , Christopher Braga , Pekka Paalanen , Hector Martin , Xaver Hugl , Joshua Ashton Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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) Signed-off-by: Harry Wentland Cc: Ville Syrjala Cc: Pekka Paalanen Cc: Simon Ser Cc: Harry Wentland Cc: Melissa Wen Cc: Jonas Ådahl Cc: Sebastian Wick Cc: Shashank Sharma Cc: Alexander Goins Cc: Joshua Ashton Cc: Michel Dänzer Cc: Aleix Pol Cc: Xaver Hugl Cc: Victoria Brekenfeld Cc: Sima Cc: Uma Shankar Cc: Naseer Ahmed Cc: Christopher Braga Cc: Abhinav Kumar Cc: Arthur Grillo Cc: Hector Martin Cc: Liviu Dudau Cc: Sasha McIntosh --- Documentation/gpu/rfc/color_pipeline.rst | 347 +++++++++++++++++++++++ 1 file changed, 347 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..af5f2ea29116 --- /dev/null +++ b/Documentation/gpu/rfc/color_pipeline.rst @@ -0,0 +1,347 @@ +======================== +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 & IOCTLs +=========================== + +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. + +Just like other DRM objects the drm_colorop objects are discovered via +IOCTLs: + +DRM_IOCTL_MODE_GETCOLOROPRESOURCES: This IOCTL is used to retrieve the +number of all drm_colorop objects. + +DRM_IOCTL_MODE_GETCOLOROP: This IOCTL is used to read one drm_colorop. +It includes the ID for the colorop object, as well as the plane_id of +the associated plane. All other values should be registered as +properties. + +Each drm_colorop has three core properties: + +TYPE: 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. While setting other properties might fail atomic check, +setting the BYPASS property to true should never fail. 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} + ├─ "LUT_1D_SIZE": immutable range = 4096 + ├─ "LUT_1D": 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} + ├─ "LUT_3D_SIZE": immutable range = 17 + ├─ "LUT_3D": blob + └─ "NEXT": immutable color operation ID = 73 + + +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 '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. + +In the case where drivers have custom support for pre-blending color +processing those drivers shall reject atomic commits that are trying to +use both the custom color properties, as well as the COLOR_PIPELINE +property. + +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. Read all drm_colorop objects +2. Get the COLOR_PIPELINE property of the plane +3. iterate all COLOR_PIPELINE enum values +4. 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 + +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 + ├─ "MATRIX_3_4": 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 + ├─ "LUT_1D_SIZE": immutable range = 4096 + ├─ "LUT_1D_DATA": blob + └─ "NEXT" (immutable) = 48 + + Color operation 48 + ├─ "TYPE" (immutable) = 3D LUT + ├─ "LUT_3D_SIZE" (immutable) = 17 + ├─ "LUT_3D_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 atomic_check/commit as desired + +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 (input CSC) + └─ "BYPASS" = true + + Color operation 44 (DeGamma) + └─ "BYPASS" = true + + Color operation 45 (gamut remap) + └─ "BYPASS" = true + + Color operation 46 (shaper LUT RAM) + └─ "BYPASS" = true + + Color operation 47 (3D LUT RAM) + └─ "LUT_3D_DATA" = Gamut mapping + tone mapping + night mode + + Color operation 48 (blend gamma) + └─ "CURVE_1D_TYPE" = PQ EOTF + + +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. 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 +disabled 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 From patchwork Thu Oct 19 21:21:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13429855 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 6E1B8C001DF for ; Thu, 19 Oct 2023 21:22:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 432F810E54A; Thu, 19 Oct 2023 21:22:10 +0000 (UTC) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2061e.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e88::61e]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1082A10E540; Thu, 19 Oct 2023 21:22:03 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gXnq7EFVGaRIohZjZNKWJPLwijyYoOiSurLXCHMKkF+mWpZyoR9E4gPK4InyvkFT5pFlIG8Ofh/1UPNoXVLg+LALCivQM2vnGBIKTMCcMQYlfVdfPMU5wlntyijDW5ZJIq1NqNcfQ6BWFQRLu0nOZdvn96qYNvfNGFRej17gpXhwBLLrfBBz/lbsdd//fXRId1fkNxlfjM6G81gQ+Hx5JyBnxKcTBylfQPyd1aRKBrVKTCTuzsVMDLK3M+12l4LrBVgvifeygSruFtykYsFoJJsQAoeL6Rw+btCWWA3qUw530YVjD+KHmB40coMyinnF9Zxu0qyztxf3ujwh5ujfNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=KAoHopPcyyIUVcu8ChVxd4B7OQIU8Qb2C9NWSgmp474=; b=AOv9QAHWj9bEO7pO/5OCc67oKBe0xzZJXu+ELb61Je/425aNd7+Dfc01HmPeZTD1ifDwZBSNaTJ+gKy7ssU2tM6Msn9fl+7D+tFOdzSYQrev4+yCiojxfPnCwIgFgOD+i1Hhp/qBmNV46Jf+eHQrIgq2oH2T292PZyNaKCVh4usMfWgUPML0k/eBL4jwl0CN2GXiSDx0rVOdxk654X51x/fAo2oDEFyQtxtEfZbGFTcqrXkDFjTbMrpa5s6rIuUGrZwUJov4/CpfZgscHJO0ZOvKFsWSj0it2xcB1Y8i9GMlmHA5mFC3/t1j95HG/4YBQK+SYpFThPelZNGbISRGXQ== 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 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=KAoHopPcyyIUVcu8ChVxd4B7OQIU8Qb2C9NWSgmp474=; b=UFZlCLh7t16zC57D46v3SmVyU7uFsN16ZgmgQ+iX8uEDVCwiq1gr89dSEL9qzqMrZRtVt0VlDagSxmM5J4EW3l+8wD8EvYduZbPh+SERmpxczUJgwDraFffPjCJpkdT+dZ+s9Z0hP+VDihAUUj6IBlvcBSW6/uEitMTZOI8chIk= Received: from BL0PR03CA0003.namprd03.prod.outlook.com (2603:10b6:208:2d::16) by SN7PR12MB8169.namprd12.prod.outlook.com (2603:10b6:806:32f::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Thu, 19 Oct 2023 21:21:59 +0000 Received: from BL02EPF0001A108.namprd05.prod.outlook.com (2603:10b6:208:2d:cafe::3a) by BL0PR03CA0003.outlook.office365.com (2603:10b6:208:2d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.26 via Frontend Transport; Thu, 19 Oct 2023 21:21:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL02EPF0001A108.mail.protection.outlook.com (10.167.241.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6907.20 via Frontend Transport; Thu, 19 Oct 2023 21:21:58 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 19 Oct 2023 16:21:58 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 19 Oct 2023 16:21:58 -0500 Received: from hwentlanrmb.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Thu, 19 Oct 2023 16:21:56 -0500 From: Harry Wentland To: Subject: [RFC PATCH v2 07/17] drm/colorop: Introduce new drm_colorop mode object Date: Thu, 19 Oct 2023 17:21:23 -0400 Message-ID: <20231019212133.245155-8-harry.wentland@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231019212133.245155-1-harry.wentland@amd.com> References: <20231019212133.245155-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A108:EE_|SN7PR12MB8169:EE_ X-MS-Office365-Filtering-Correlation-Id: 891a7d6d-ec48-4344-ad05-08dbd0e96d9d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YzqWz9hsmx/MyQ9a25JbbVKRhsYmqu186/lvhZeezvi117vBxbJc+EOKZsYZ3gv0kjU0MX/f8O1mYKB/ereG7y8K50EN463+Fz7HaVsaJj1idYN3q2Pte8ltYJn43aT3cBq0Xxl8aPSm8wC9XcIjxlWKwCxR+XgaKowJpeDQpH3txhQdWPNC3SDS6XZM6YWf6ojNuCbx1ryPVbvAW9oM1RHchP1pckpieYPNhsQJLeJ80Y5V/6xzpfeSlP3yH6mKmGNxptWFPeHWvinKEj0Wa4Gwf7kDmCkXPuCKDQQOK1NXD6YRQ7Fw/7+0ca4okPVjvCw9fQCuzWoCehqnnvU6XMhzywiVk1zm8nqz67EkEd+n20TKdlEW7gnsrMgN4awBY4sADSKRD5XjrNiNEsf5g+vYwqrckWp56+W9jZmhVB4Dt2GuTi/M1hQ9+/ggvRjjjm7ZWt1+RepzXEQcajfnauvuqncz3d7SypXtTzWC5p4ySpE3QiSP5DAolxHaU6K1VEzs6XTB4dGYo2HHbIRlcDMhJB+UxOnmGqVHirAmf43HngSC6yRCOrVp36clhzQPplez4GDM9+WLjTTHbL24VcBcb7eh7rscFtvCHUn4vLnQMavn9t9QObhEAp/ZLY4qzg1j6mfJP/s3TWCmstS5yEBpuc3BrGXz5jGjTi9TKcysS71V38ycoidKgUhaN+9ZdvKyxK6S/tlqHpICw/S3AaAUEsT37zOgrDlyTY88z3NxsPX9m/3lgoeAh36R8glCiJt58YzG6cFSLDT7+OoBvg== 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:(13230031)(4636009)(376002)(39860400002)(346002)(136003)(396003)(230922051799003)(451199024)(64100799003)(186009)(82310400011)(1800799009)(36840700001)(40470700004)(46966006)(2616005)(66899024)(40460700003)(40480700001)(36860700001)(47076005)(356005)(7696005)(83380400001)(70206006)(44832011)(6666004)(81166007)(36756003)(66574015)(26005)(70586007)(54906003)(478600001)(426003)(6916009)(1076003)(336012)(316002)(41300700001)(86362001)(7416002)(82740400003)(2906002)(4326008)(8676002)(5660300002)(8936002)(30864003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2023 21:21:58.7595 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 891a7d6d-ec48-4344-ad05-08dbd0e96d9d 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: BL02EPF0001A108.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8169 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: , Cc: Sasha McIntosh , Liviu Dudau , Victoria Brekenfeld , =?utf-8?q?Michel_D=C3=A4nzer?= , Arthur Grillo , Sebastian Wick , Shashank Sharma , wayland-devel@lists.freedesktop.org, =?utf-8?q?Jonas_=C3=85dahl?= , Uma Shankar , Abhinav Kumar , Naseer Ahmed , Melissa Wen , Aleix Pol , Christopher Braga , Pekka Paalanen , Hector Martin , Xaver Hugl , Joshua Ashton Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This patches introduces a new drm_colorop mode object. This object represents color transformations and can be used to define color pipelines. We also introduce the drm_colorop_state here, as well as various helpers and state tracking bits. Signed-off-by: Harry Wentland Cc: Ville Syrjala Cc: Pekka Paalanen Cc: Simon Ser Cc: Harry Wentland Cc: Melissa Wen Cc: Jonas Ådahl Cc: Sebastian Wick Cc: Shashank Sharma Cc: Alexander Goins Cc: Joshua Ashton Cc: Michel Dänzer Cc: Aleix Pol Cc: Xaver Hugl Cc: Victoria Brekenfeld Cc: Sima Cc: Uma Shankar Cc: Naseer Ahmed Cc: Christopher Braga Cc: Abhinav Kumar Cc: Arthur Grillo Cc: Hector Martin Cc: Liviu Dudau Cc: Sasha McIntosh --- drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/drm_atomic.c | 79 +++++++++++++ drivers/gpu/drm/drm_atomic_helper.c | 12 ++ drivers/gpu/drm/drm_atomic_uapi.c | 48 ++++++++ drivers/gpu/drm/drm_colorop.c | 169 ++++++++++++++++++++++++++++ drivers/gpu/drm/drm_mode_config.c | 7 ++ drivers/gpu/drm/drm_plane_helper.c | 2 +- include/drm/drm_atomic.h | 82 ++++++++++++++ include/drm/drm_atomic_uapi.h | 1 + include/drm/drm_colorop.h | 157 ++++++++++++++++++++++++++ include/drm/drm_mode_config.h | 18 +++ include/drm/drm_plane.h | 2 + include/uapi/drm/drm.h | 3 + include/uapi/drm/drm_mode.h | 1 + 14 files changed, 581 insertions(+), 1 deletion(-) 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 8e1bde059170..7ba67f9775e7 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -16,6 +16,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 f1a503aafe5a..d55db5a06940 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" @@ -108,6 +109,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); @@ -139,6 +141,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 @@ -250,6 +256,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; @@ -571,6 +591,65 @@ 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; + struct drm_plane_state *plane_state; + + WARN_ON(!state->acquire_ctx); + + colorop_state = drm_atomic_get_existing_colorop_state(state, colorop); + if (colorop_state) + return colorop_state; + + /* TODO where is the unlock? */ + 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); + + /* TODO is this necessary? */ + + plane_state = drm_atomic_get_plane_state(state, + colorop->plane); + if (IS_ERR(plane_state)) + return ERR_CAST(plane_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 71d399397107..54c3d66d008f 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -2985,6 +2985,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; @@ -3062,6 +3064,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; + } + 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 98d3b10c08ae..21da1b327ee9 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 @@ -664,6 +665,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) @@ -926,6 +947,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; @@ -1061,6 +1092,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..78d6a0067f5b --- /dev/null +++ b/drivers/gpu/drm/drm_colorop.c @@ -0,0 +1,169 @@ +/* + * 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" + +/* TODO big colorop doc, including properties, etc. */ + +/* Init Helpers */ + +int drm_colorop_init(struct drm_device *dev, struct drm_colorop *colorop, + struct drm_plane *plane) +{ + struct drm_mode_config *config = &dev->mode_config; + 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->plane = plane; + + list_add_tail(&colorop->head, &config->colorop_list); + colorop->index = config->num_colorop++; + + /* add properties */ + return ret; +} +EXPORT_SYMBOL(drm_colorop_init); + +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_destroy_state - release colorop state + * @state: colorop state object to release + * + * Releases all resources stored in the colorop state without actually freeing + * the memory of the colorop state. This is useful for drivers that subclass the + * colorop state. + */ +void __drm_colorop_destroy_state(struct drm_colorop_state *state) +{ + /* TODO might need this later */ +} + +/** + * drm_colorop_destroy_state - default state destroy hook + * @colorop: drm colorop + * @state: colorop state object to release + * + * Default colorop state destroy hook for drivers which don't have their own + * subclassed colorop state structure. + */ +void drm_colorop_destroy_state(struct drm_colorop *colorop, + struct drm_colorop_state *state) +{ + kfree(state); +} +EXPORT_SYMBOL(drm_colorop_destroy_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. + */ +void __drm_colorop_state_reset(struct drm_colorop_state *colorop_state, + struct drm_colorop *colorop) +{ + colorop_state->colorop = colorop; +} +EXPORT_SYMBOL(__drm_colorop_state_reset); + +/** + * __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. + */ +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; +} + +/** + * 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) +{ + if (colorop->state) + __drm_colorop_destroy_state(colorop->state); + + kfree(colorop->state); + colorop->state = kzalloc(sizeof(*colorop->state), GFP_KERNEL); + + if (colorop->state) + __drm_colorop_reset(colorop, colorop->state); +} +EXPORT_SYMBOL(drm_colorop_reset); diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c index 8525ef851540..30c6fb10353b 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); @@ -413,6 +418,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); @@ -434,6 +440,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/drivers/gpu/drm/drm_plane_helper.c b/drivers/gpu/drm/drm_plane_helper.c index 5e95089676ff..912580eca1e5 100644 --- a/drivers/gpu/drm/drm_plane_helper.c +++ b/drivers/gpu/drm/drm_plane_helper.c @@ -310,4 +310,4 @@ int drm_plane_helper_atomic_check(struct drm_plane *plane, struct drm_atomic_sta DRM_PLANE_NO_SCALING, false, false); } -EXPORT_SYMBOL(drm_plane_helper_atomic_check); +EXPORT_SYMBOL(drm_plane_helper_atomic_check); \ No newline at end of file diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h index cf8e1220a4ac..634b2827765f 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; @@ -398,6 +404,7 @@ struct drm_atomic_state { * states. */ bool duplicated : 1; + struct __drm_colorops_state *colorops; struct __drm_planes_state *planes; struct __drm_crtcs_state *crtcs; int num_connector; @@ -501,6 +508,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); @@ -630,6 +640,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 @@ -877,6 +936,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..3dd169b0317d --- /dev/null +++ b/include/drm/drm_colorop.h @@ -0,0 +1,157 @@ +/* + * 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; + + /* colorop properties */ + + /** @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 plane. + */ + unsigned index; + + /* TODO do we need a separate mutex or will we tag along with the plane mutex? */ + + /** @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. Either by + * going through the &struct drm_atomic_state pointers, see + * for_each_oldnew_plane_in_state(), for_each_old_plane_in_state() and + * for_each_new_plane_in_state(). Or through careful ordering of atomic + * commit operations as implemented in the atomic helpers, see + * &struct drm_crtc_commit. + * + * TODO keep, remove, or rewrite above plane references? + */ + struct drm_colorop_state *state; + + /* colorop properties */ + + /** @properties: property tracking for this plane */ + struct drm_object_properties properties; + +}; + +#define obj_to_colorop(x) container_of(x, struct drm_colorop, base) + +/** + * drm_crtc_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; +} + +int drm_colorop_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); + +void drm_colorop_atomic_destroy_state(struct drm_colorop *colorop, + struct drm_colorop_state *state); + +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 973119a9176b..492b8c120c80 100644 --- a/include/drm/drm_mode_config.h +++ b/include/drm/drm_mode_config.h @@ -505,6 +505,24 @@ struct drm_mode_config { */ struct list_head plane_list; + /** + * @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; + + /** + * @colorops_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 79d62856defb..57bbd0cd73a9 100644 --- a/include/drm/drm_plane.h +++ b/include/drm/drm_plane.h @@ -227,6 +227,8 @@ struct drm_plane_state { */ enum drm_scaling_filter scaling_filter; + 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.h b/include/uapi/drm/drm.h index 794c1d857677..b22adfabc677 100644 --- a/include/uapi/drm/drm.h +++ b/include/uapi/drm/drm.h @@ -1198,6 +1198,9 @@ extern "C" { #define DRM_IOCTL_SYNCOBJ_EVENTFD DRM_IOWR(0xCF, struct drm_syncobj_eventfd) +#define DRM_IOCTL_MODE_GETCOLOROPRESOURCES DRM_IOWR(0xD0, struct drm_mode_get_colorop_res) +#define DRM_IOCTL_MODE_GETCOLOROP DRM_IOWR(0xD1, struct drm_mode_get_colorop) + /* * Device specific ioctls should only be in their respective headers * The device specific ioctl range is from 0x40 to 0x9f. diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index ea1b639bcb28..009a800676ac 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -629,6 +629,7 @@ struct drm_mode_connector_set_property { #define DRM_MODE_OBJECT_FB 0xfbfbfbfb #define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb #define DRM_MODE_OBJECT_PLANE 0xeeeeeeee +#define DRM_MODE_OBJECT_COLOROP 0xfafafafa #define DRM_MODE_OBJECT_ANY 0 struct drm_mode_obj_get_properties { From patchwork Thu Oct 19 21:21:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13429852 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 E7C03C004C0 for ; Thu, 19 Oct 2023 21:22:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 83AB610E548; Thu, 19 Oct 2023 21:22:09 +0000 (UTC) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on20606.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eab::606]) by gabe.freedesktop.org (Postfix) with ESMTPS id 41BB510E548; Thu, 19 Oct 2023 21:22:03 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SubGtVwiUfNnvCMumNLiaTR+4hu8/77fWffgxJ98LmhgpKMqeMC62NJKzHHJNKpPEzWXWZ/Mhr0S07LBvcLSFUFMje9rpDCJTbaI64gtVZp3Xdt10ZEAuBVgW8TCFDjmeek4new93ILQp28roaaGe5v7b6B+tR8hxCxbCGCOl/OSzslGHYnZah3es3ditRhRJxlHN2XrlbNLJoMQ2zqey/PcNIfdGcTeHm+C2PvAQn7xBZVh5zpbprHEmT9ER9emwWv09eJstSl+alO/A7dBH2sxk/vcxu12gHwY4/bQ45OkR3ZdNIRpd6YXB/puM2QBnlbb+5WvbuSOOXBeUr1Pcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=U8HqNo1KFeFGWkxo7u+LS0xHnIJKfR0yeQpbK+V/uvU=; b=k14JGPloHA6mkhpKm3wS6C/CX0VZrgXpotEgo+ZbGHvHMvtHvMtalXbRQDcR9dXPNHr+iW6Rl7gRq+SC3WZlvUBKaCmn+IbjTtFJHNnZSmAvAfgHEsgK/TplQotKSV43cDe9qZ6Jx3bInPfgFjJsAsLNg0WCqu+I831bfX8RtDqp7QRNKo8lvYmqpxcoEhDDSiRCoBTVMo82aUKeAALZ5SSk8Eso7oyXh60ENoCOa8jY1E4llKugOPHlAcyc25lFIzj+rm25ZjQ/zDCzVJE5pG8utMvc6rM6DEh8QMIQeptGfnzItP++tZXYCWK8hABU/WLqgSET9MXpAadVDaF1Mw== 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 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=U8HqNo1KFeFGWkxo7u+LS0xHnIJKfR0yeQpbK+V/uvU=; b=Uqg/xsu7fmCtj74ITIG3Thiy7//l7BwhPGSyzy45HZrCS34FuNGhDawDDSi8MY9BwNZVGGJ82g9uFhZpdF0KqnCqiCTPndEXwnHtLbRxoFlNczC6ZZKU6b15doUfNoVG6XE+EaiUVp+cXcG5wnMjfgt7zhoKM97zjzfWhK6xRbE= Received: from BL0PR03CA0032.namprd03.prod.outlook.com (2603:10b6:208:2d::45) by MW4PR12MB7189.namprd12.prod.outlook.com (2603:10b6:303:224::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.21; Thu, 19 Oct 2023 21:22:01 +0000 Received: from BL02EPF0001A108.namprd05.prod.outlook.com (2603:10b6:208:2d:cafe::fd) by BL0PR03CA0032.outlook.office365.com (2603:10b6:208:2d::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.24 via Frontend Transport; Thu, 19 Oct 2023 21:22:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL02EPF0001A108.mail.protection.outlook.com (10.167.241.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6907.20 via Frontend Transport; Thu, 19 Oct 2023 21:22:00 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 19 Oct 2023 16:21:59 -0500 Received: from hwentlanrmb.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Thu, 19 Oct 2023 16:21:58 -0500 From: Harry Wentland To: Subject: [RFC PATCH v2 08/17] drm/colorop: Add TYPE property Date: Thu, 19 Oct 2023 17:21:24 -0400 Message-ID: <20231019212133.245155-9-harry.wentland@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231019212133.245155-1-harry.wentland@amd.com> References: <20231019212133.245155-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A108:EE_|MW4PR12MB7189:EE_ X-MS-Office365-Filtering-Correlation-Id: b09c0675-2f82-438b-7729-08dbd0e96eeb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: W0RjdE6HEm156Evk+TtPH8EjgC2coVeRFVbK9Fh58tBgpAr7WlsbsKK0XquiZ8egio6an5LIDRIeU7+nNHOafxT27h+v84iDVrMmnzkasnHrXhL9cYD9RRVtjTFHlLtAoWiLJQYj/83z2s7nXwjeJ+mm6I7RNN0VC9LRjjgOipMU0eDt3jNjvDiiDWfIHSGmZCXScMLhe72TwsQ3/Vux/rdYCXkIxsGg5LtrDelS2hCMZUhfsSCuoml/+b9odSAP08OjOPzrCImgjrSdMt3BtFMZsVhIQZqrVrE0LF3BLEXXImSLdDHljRTCY/TbTuFRSVKiMcvOb1YheAPXoqFzY3kBwO9pj0OeySp7yvNvmrTkMMtF7IjIRh8cjoBPNoBWgBA6lWdErigkKkYrGZi4jQBBoPGO022RlUt22a8X5n51PxmWbyYidnWqVVtiSQcataunwXeY2j8HyEerjm401MFpFhUA0FP0le1KXbTAiMcudQR+kwbL8PUbfnNZ+/hMkJjXqil7kOfWrHEI/MaxfyQ1uzX3L51S6ll8J4MDBBsfxTHdHcpyjCLXn0WgKEVkDVMxN22lioNAPjgUoiaoU8VayeljJvqVcj0x77tF99HKmb4KnX5qr3Uo42chzVK2GoUAtMJSYBKPUJrP0T7FCob47ZBwwkDVJYQAtJb+EuyfKvW1tFTzMVQaYsnv/2RZM44ykxj+yiAKkLlEE3TIILPc2OTdeMRcwwAHl6NQlI3XPSTmCMmQ+cgjo+LVgLZGO7ffrz3wtt/LevdXTD5pdA== 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:(13230031)(4636009)(39860400002)(136003)(346002)(396003)(376002)(230922051799003)(451199024)(64100799003)(186009)(1800799009)(82310400011)(40470700004)(46966006)(36840700001)(82740400003)(6916009)(40460700003)(316002)(70586007)(70206006)(1076003)(26005)(40480700001)(2616005)(83380400001)(426003)(47076005)(336012)(36860700001)(86362001)(356005)(81166007)(36756003)(54906003)(478600001)(2906002)(7416002)(5660300002)(41300700001)(6666004)(7696005)(44832011)(8676002)(8936002)(4326008)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2023 21:22:00.9470 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b09c0675-2f82-438b-7729-08dbd0e96eeb 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: BL02EPF0001A108.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7189 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: , Cc: Sasha McIntosh , Liviu Dudau , Victoria Brekenfeld , =?utf-8?q?Michel_D=C3=A4nzer?= , Arthur Grillo , Sebastian Wick , Shashank Sharma , wayland-devel@lists.freedesktop.org, =?utf-8?q?Jonas_=C3=85dahl?= , Uma Shankar , Abhinav Kumar , Naseer Ahmed , Melissa Wen , Aleix Pol , Christopher Braga , Pekka Paalanen , Hector Martin , Xaver Hugl , Joshua Ashton Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add a read-only TYPE property. The TYPE specifies the colorop type, such as enumerated curve, 1D LUT, CTM, 3D LUT, PWL LUT, etc. For now we're only introducing an enumerated 1D LUT type to illustrate the concept. Signed-off-by: Harry Wentland Cc: Ville Syrjala Cc: Pekka Paalanen Cc: Simon Ser Cc: Harry Wentland Cc: Melissa Wen Cc: Jonas Ådahl Cc: Sebastian Wick Cc: Shashank Sharma Cc: Alexander Goins Cc: Joshua Ashton Cc: Michel Dänzer Cc: Aleix Pol Cc: Xaver Hugl Cc: Victoria Brekenfeld Cc: Sima Cc: Uma Shankar Cc: Naseer Ahmed Cc: Christopher Braga Cc: Abhinav Kumar Cc: Arthur Grillo Cc: Hector Martin Cc: Liviu Dudau Cc: Sasha McIntosh --- drivers/gpu/drm/drm_atomic.c | 4 +-- drivers/gpu/drm/drm_atomic_uapi.c | 8 +++++- drivers/gpu/drm/drm_colorop.c | 43 ++++++++++++++++++++++++++++++- include/drm/drm_colorop.h | 21 ++++++++++++++- 4 files changed, 71 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index d55db5a06940..524bec520287 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -636,8 +636,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); /* TODO is this necessary? */ diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index 21da1b327ee9..f22bd8671236 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -682,7 +682,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 78d6a0067f5b..33e7dbf4dbe4 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -32,12 +32,17 @@ /* TODO big colorop doc, including properties, etc. */ +static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { + { DRM_COLOROP_1D_CURVE, "1D Curve" }, +}; + /* Init Helpers */ int drm_colorop_init(struct drm_device *dev, struct drm_colorop *colorop, - struct drm_plane *plane) + 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); @@ -46,12 +51,28 @@ int drm_colorop_init(struct drm_device *dev, struct drm_colorop *colorop, 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 | DRM_MODE_PROP_ATOMIC, + "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; } EXPORT_SYMBOL(drm_colorop_init); @@ -167,3 +188,23 @@ void drm_colorop_reset(struct drm_colorop *colorop) __drm_colorop_reset(colorop, colorop->state); } EXPORT_SYMBOL(drm_colorop_reset); + + +static const char * const colorop_type_name[] = { + [DRM_COLOROP_1D_CURVE] = "1D Curve", +}; + +/** + * drm_get_colorop_type_name - return a string for colorop type + * @range: 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) +{ + 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 3dd169b0317d..22a217372428 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -30,6 +30,10 @@ #include #include +enum drm_colorop_type { + DRM_COLOROP_1D_CURVE +}; + /** * struct drm_colorop_state - mutable colorop state */ @@ -103,6 +107,21 @@ struct drm_colorop { /** @properties: property tracking for this plane */ struct drm_object_properties properties; + /** + * @type: + * + * Read-only + * Type of color operation + */ + enum drm_colorop_type type; + + /** + * @type_property: + * + * Read-only "TYPE" enum 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) @@ -127,7 +146,7 @@ static inline struct drm_colorop *drm_colorop_find(struct drm_device *dev, } int drm_colorop_init(struct drm_device *dev, struct drm_colorop *colorop, - struct drm_plane *plane); + struct drm_plane *plane, enum drm_colorop_type type); struct drm_colorop_state * drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop); From patchwork Thu Oct 19 21:21:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13429857 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 DA382C00A98 for ; Thu, 19 Oct 2023 21:22:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0A4BC10E543; Thu, 19 Oct 2023 21:22:44 +0000 (UTC) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2071.outbound.protection.outlook.com [40.107.94.71]) by gabe.freedesktop.org (Postfix) with ESMTPS id 324DF10E543; Thu, 19 Oct 2023 21:22:41 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EK0ca3XsQQ7iVSaNdO96lYC4OO7Mj/SXh3KiGvctTpoHDGthIFVMNlD1KVrI/E5uZ3w+fSf/pV0Bpa4VFGVS1MgUP1BaVvWpKiedmajB6YqOvppjrEbOukICrKu/Qf7b6P+1HcOkKYy89wZXYNlBh3vC4YNoBxKR2y9D0qT5IHrPy54j786NWr4O+coooLGHlVeBbSKi8/TS03oIDoCZS13KJEnjT+GX/ZEsC9bwt9xRhaqmGjl/BTba/9+PM5T128bZSktc3lJbgqd791W337sbywZsHgwsWrdYyeyyhkFfF0RDx/4nwmLDg3pPnH6sUMmxmXOqEhAPkzqkJVOV6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8pYSasPhzF6O4apvMs2KJGYvba7mLEWPjdgKKnjjYHA=; b=WzTIa4ZiioFmrrRz5ISoNSSYV4JIYbKaoG9WvjqRjcTi2co0gjSY/0oDg/Bg5ATUQbP7P1/MVzviYBnKXtcnNTf8KRztl3z/vGkZMqBdBZgWGfy0UEklr3Q28xiVBbSYJyuvn0t2qGX4X8rTzEhrxoTF5AUj6LGnhfNzhx/LG7BI0jTW5j0TxBk2aJstrCuI6XlnRS6kZ9bxZzJJbHoZC6ahbUNFemuI1vK2Ngz/62IWy0aFGKHCxIRNPAS3HjB7ZTYmVpp9FtcFaoRxef3oPSgFdBkqOwrVemx7RpZeKhpE2SBAtB3cqG9qaYA6gti6BcmKT7pIIn1g9+J/yhQ4mg== 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 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=8pYSasPhzF6O4apvMs2KJGYvba7mLEWPjdgKKnjjYHA=; b=EOE/35syLYcTl5Oeb0a2adM4iOXMOfGXbqnfxg7FSyy0yBxCR0GVPQr5XPOcg+3t0A8uNUQQo6fQFtLiDaHYbkm0ZNyxBFQlkYhhK0zsHvejpXKIG8+GUJrcXD4PWOVg8HaZAOV1LYlD308ESK3pWQYlqMJCx6RPwBh5ZvcgpjY= Received: from MN2PR16CA0054.namprd16.prod.outlook.com (2603:10b6:208:234::23) by DM4PR12MB5296.namprd12.prod.outlook.com (2603:10b6:5:39d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Thu, 19 Oct 2023 21:22:38 +0000 Received: from BL02EPF0001A104.namprd05.prod.outlook.com (2603:10b6:208:234:cafe::f4) by MN2PR16CA0054.outlook.office365.com (2603:10b6:208:234::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.21 via Frontend Transport; Thu, 19 Oct 2023 21:22: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 BL02EPF0001A104.mail.protection.outlook.com (10.167.241.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6907.20 via Frontend Transport; Thu, 19 Oct 2023 21:22:37 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 19 Oct 2023 16:22:01 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 19 Oct 2023 16:22:01 -0500 Received: from hwentlanrmb.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Thu, 19 Oct 2023 16:21:59 -0500 From: Harry Wentland To: Subject: [RFC PATCH v2 09/17] drm/color: Add 1D Curve subtype Date: Thu, 19 Oct 2023 17:21:25 -0400 Message-ID: <20231019212133.245155-10-harry.wentland@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231019212133.245155-1-harry.wentland@amd.com> References: <20231019212133.245155-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A104:EE_|DM4PR12MB5296:EE_ X-MS-Office365-Filtering-Correlation-Id: ae6960f7-82bf-4a06-f778-08dbd0e984fe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OYU2gG8lXTGfXoBjJ1+yRcIG/p92MzlI03KtB2PrekuZJPc/GwYSQLKiqnUphMxvHdXe7df3Ybq8rfPjN21tGXwV84ANdcXhWLa3a2LYGUpCm/OFT0tFsXmIsAv5WueWQ//BAaqknJKzDphOJ2CRZDxZhw+052I9C4ZpWqiCc92xrsm+PssDR7wm26qx+PoOzYtrOPUA4jDliO1SfezSWCNCPIlDr6cZblaxMsdonwABrjF3PcL6gVHhPKsNhPxDwos5QNbN+FOmJqo5Ckvl5pey9q5zua1dHOPvwgfZDtPCBNJXvikpXn94WyZI27EN3VOmvREsjACvJXpaeU3bUVmGT/bSLGBd2DDS74KBDe2FR+0OTzND3HKgQMXl3MA0Y0WEI9ukOYKf1ExV5yvYKXGUpptjqMrLXmD/tTh8SxW5YYvm+1TdTMPPLeHV27/1oy1Wil8zqH4MmzYqXjbHNUaK99YTKpgnuwAoP/ghqnrCLzxQxCjtlVyn51gOZt9+WEXO49nFP5eHeV/Ax362yozyaSt56jwQ4412UXVzlFKiYq1Ai0+dgC9I5OFK+D0ILqMPD30kxrITbRBC1wUg/x2thdIsObOpOLe+SR60RqG8hjZvA9sIQFf76d7+ODyw31EskQ1pInbOqL+xQKdHX7sPn0RISSSNaCTujZzNIc/NicK7Y3molwfHHE+BU/nNi+b/qeDmouHGB63XWskx4pBIvbIyyGNt+hJVBxZzBBrwcm8k+mKdLF33lSGSmC8KOS0/d6J38VShptuTxJ11AQ== 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:(13230031)(4636009)(396003)(39860400002)(346002)(136003)(376002)(230922051799003)(82310400011)(186009)(64100799003)(1800799009)(451199024)(40470700004)(46966006)(36840700001)(36756003)(40480700001)(40460700003)(54906003)(1076003)(6916009)(86362001)(26005)(81166007)(82740400003)(356005)(426003)(316002)(336012)(83380400001)(6666004)(7696005)(2616005)(8936002)(5660300002)(70586007)(2906002)(70206006)(47076005)(8676002)(41300700001)(478600001)(36860700001)(44832011)(7416002)(4326008)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2023 21:22:37.9379 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ae6960f7-82bf-4a06-f778-08dbd0e984fe 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: BL02EPF0001A104.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5296 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: , Cc: Sasha McIntosh , Liviu Dudau , Victoria Brekenfeld , =?utf-8?q?Michel_D=C3=A4nzer?= , Arthur Grillo , Sebastian Wick , Shashank Sharma , wayland-devel@lists.freedesktop.org, =?utf-8?q?Jonas_=C3=85dahl?= , Uma Shankar , Abhinav Kumar , Naseer Ahmed , Melissa Wen , Aleix Pol , Christopher Braga , Pekka Paalanen , Hector Martin , Xaver Hugl , Joshua Ashton Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Signed-off-by: Harry Wentland Cc: Ville Syrjala Cc: Pekka Paalanen Cc: Simon Ser Cc: Harry Wentland Cc: Melissa Wen Cc: Jonas Ådahl Cc: Sebastian Wick Cc: Shashank Sharma Cc: Alexander Goins Cc: Joshua Ashton Cc: Michel Dänzer Cc: Aleix Pol Cc: Xaver Hugl Cc: Victoria Brekenfeld Cc: Sima Cc: Uma Shankar Cc: Naseer Ahmed Cc: Christopher Braga Cc: Abhinav Kumar Cc: Arthur Grillo Cc: Hector Martin Cc: Liviu Dudau Cc: Sasha McIntosh --- drivers/gpu/drm/drm_atomic_uapi.c | 18 ++++++++++---- drivers/gpu/drm/drm_colorop.c | 39 +++++++++++++++++++++++++++++++ include/drm/drm_colorop.h | 20 ++++++++++++++++ 3 files changed, 72 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index f22bd8671236..52b9b48e5757 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -670,11 +670,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 @@ -684,6 +690,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 33e7dbf4dbe4..8d8f9461950f 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -36,6 +36,11 @@ static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { { DRM_COLOROP_1D_CURVE, "1D Curve" }, }; +static const struct drm_prop_enum_list drm_colorop_curve_1d_type_enum_list[] = { + { DRM_COLOROP_1D_CURVE_SRGB_EOTF, "sRGB EOTF" }, + { DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF, "sRGB Inverse EOTF" }, +}; + /* Init Helpers */ int drm_colorop_init(struct drm_device *dev, struct drm_colorop *colorop, @@ -73,6 +78,20 @@ int drm_colorop_init(struct drm_device *dev, struct drm_colorop *colorop, colorop->type_property, colorop->type); + /* curve_1d_type */ + /* TODO move to mode_config? */ + prop = drm_property_create_enum(dev, DRM_MODE_PROP_ATOMIC, + "CURVE_1D_TYPE", + drm_colorop_curve_1d_type_enum_list, + ARRAY_SIZE(drm_colorop_curve_1d_type_enum_list)); + if (!prop) + return -ENOMEM; + + colorop->curve_1d_type_property = prop; + drm_object_attach_property(&colorop->base, + colorop->curve_1d_type_property, + 0); + return ret; } EXPORT_SYMBOL(drm_colorop_init); @@ -194,6 +213,11 @@ static const char * const colorop_type_name[] = { [DRM_COLOROP_1D_CURVE] = "1D Curve", }; +static const char * const colorop_curve_1d_type_name[] = { + [DRM_COLOROP_1D_CURVE_SRGB_EOTF] = "sRGB EOTF", + [DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF] = "sRGB Inverse EOTF", +}; + /** * drm_get_colorop_type_name - return a string for colorop type * @range: colorop type to compute name of @@ -208,3 +232,18 @@ const char *drm_get_colorop_type_name(enum drm_colorop_type type) return colorop_type_name[type]; } + +/** + * drm_get_colorop_curve_1d_type_name - return a string for 1D curve type + * @range: 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) +{ + if (WARN_ON(type >= ARRAY_SIZE(colorop_curve_1d_type_name))) + return "unknown"; + + return colorop_curve_1d_type_name[type]; +} diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h index 22a217372428..7701b61ff7e9 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -34,6 +34,11 @@ enum drm_colorop_type { DRM_COLOROP_1D_CURVE }; +enum drm_colorop_curve_1d_type { + DRM_COLOROP_1D_CURVE_SRGB_EOTF, + DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF +}; + /** * struct drm_colorop_state - mutable colorop state */ @@ -43,6 +48,13 @@ struct drm_colorop_state { /* colorop properties */ + /** + * @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 +134,14 @@ struct drm_colorop { * this color operation. The type is enum drm_colorop_type. */ struct drm_property *type_property; + + /** + * @curve_1d_type: + * + * 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) From patchwork Thu Oct 19 21:21:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13429858 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 972DCC001DF for ; Thu, 19 Oct 2023 21:22:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DAF0A10E54F; Thu, 19 Oct 2023 21:22:50 +0000 (UTC) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2088.outbound.protection.outlook.com [40.107.220.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5327410E54E; Thu, 19 Oct 2023 21:22:45 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IT6KBqZSBbmOjBR5AIRfPy1uIU0W/4CgWUvO+gpnsKbopHIvv+HUil2/PUOkNUSMq2ZGGrK0Q/NP9RZWCMRzmdTOQAolUoNQEbuYj8sjIJOXqf7oAwXasLrnZwhTNnL+1U/dRctf/Iose6TvvATlm1L3Xvsq+wo7iQt4YoRiFddSDfNLYdrMcJJuZds5VAUqU2E60fuMn3TYnZG+B1N0ksyBZb0LMB1cSq1wDP7p4thjquY7/bbI/TnYxotpyxhwLNywt7O21MNKsl60/PfHQ1YW9T0VHYv1RaUrIvDv7vZus+0DdtTJTacetuVs270+CuW25WL+xShIQaNhHA2X9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PvqBuDZKsZAMSJwz8uK2Ce4ZPJm1dhfFntbefpf4QyY=; b=GxRdNq35p9tEFa27UhJ9EroSP3ENPcQewcKK9a3nNgiiMWx4gJ3CkewlB+y2ECjhRGveKI+3UTPgWp6uQRehiUEe4eo2/hsOuT7KHs8CDblzdrFDecMJJ5y/wgfGhNm6KRBZH/llAHosRPl+f5U1skL3BVAdZTuMQ/d9RxgOw19kvnP7eRzyY0XX+KBNeDDU+NuWTb6RXTGyJ40+chCgM1Iuo7F2tDkMCf6fjAkurA5zmlhY+XaFb1I1b8qrOIkiFLGDedqHzHrRpwWvOZFq7zWmfC0WLC6KaJQV2qOLteUvWYNsP9FphFDHj9CzvIduu/ufEArCcYLALyDvpE1UUw== 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 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=PvqBuDZKsZAMSJwz8uK2Ce4ZPJm1dhfFntbefpf4QyY=; b=weXdXNIaebtF8mIVW2PHaIap4HOsUd3an+bpNpilaMe+t9yF1T4AAt1ocAxKUe5N21BJ5KSXj7S7by59B14j4qJ8ksozSdRBuUBg1wWxO2QBtO6/3C5HFpC+IClJaiu1lAUwKknAT9Wr6YLioo9cyDPfrextHGNwcDukbhgHcpA= Received: from MN2PR16CA0037.namprd16.prod.outlook.com (2603:10b6:208:234::6) by MW4PR12MB7240.namprd12.prod.outlook.com (2603:10b6:303:226::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.25; Thu, 19 Oct 2023 21:22:43 +0000 Received: from BL02EPF0001A108.namprd05.prod.outlook.com (2603:10b6:208:234:cafe::55) by MN2PR16CA0037.outlook.office365.com (2603:10b6:208:234::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36 via Frontend Transport; Thu, 19 Oct 2023 21:22: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 BL02EPF0001A108.mail.protection.outlook.com (10.167.241.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6907.20 via Frontend Transport; Thu, 19 Oct 2023 21:22:42 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) 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.27; Thu, 19 Oct 2023 16:22:38 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 19 Oct 2023 14:22:02 -0700 Received: from hwentlanrmb.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Thu, 19 Oct 2023 16:22:01 -0500 From: Harry Wentland To: Subject: [RFC PATCH v2 10/17] drm/colorop: Add BYPASS property Date: Thu, 19 Oct 2023 17:21:26 -0400 Message-ID: <20231019212133.245155-11-harry.wentland@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231019212133.245155-1-harry.wentland@amd.com> References: <20231019212133.245155-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A108:EE_|MW4PR12MB7240:EE_ X-MS-Office365-Filtering-Correlation-Id: cafdb6cf-e631-4647-0141-08dbd0e987bb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KLCknX/HB+8bUOX7U44oyqxI2adXqFXesfn72fMHFvxpRF/qQjyhkTYsgOCxrLq3JqE9XOZjEy3lv4FwSBbgxqvPcUeFfFZugLhLaxshsMnOhWPkcKiwNoYaxHl2849TdeADwE/4jEjLGP7EncS5P1uWe78nUQgnlLsauwm1kG8JD/3veY/zWgS4iKqXazPrlRr2/ByVxPx/yq1pBItDoBLytmboO5TbETe3to/KZ+x2/Nx0gGF0B+EnRV31/faOebvkp2zE3ADqsewiPoTwaA2PD71WbnwQZO4R6T7gFxRym+PHLNvXD8r10M89RBP6mI9ariUmm+TVdlMsgSbZupbqA5UYgStygIcTLot0/gAIQafnPStacp9o4aJAdn//9aLouzvBokH0R+cu1zHIR6KXscZQTV57I4xu+VdhIb0UthYUTECqQg4g50kfa5a91JKtuxhgkBx+RarPgL8EmqKHCnDrNpVhF0auZGv6clnRFHOxWAqFPu1lRVinkW6mxEtmgUPJRMDxGoWF4BRp72I3bbAL9uzUepPJeaiK+v3SNsEuAM+eWuNoriwd2xFPd2PvK9BmELvR1gtQA0zJobIlXp+aVNb4583zICd+VsqOgMzsusvdxoZiGhP6B95jOowH9gS5tG9/VTT77I9UX27hiIfPkZFOsFhpg4JWw0BTGhOoJssSykuVFWQ9yrIeN64iFFi6/L5F/aintwT+dNZZTqVnRM44r3iHI8wW5kHwMBXzbnASKLUGyB2nM48OR3N5mO1MBjU+DPQ1ntGvhQ== 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:(13230031)(4636009)(39860400002)(136003)(376002)(346002)(396003)(230922051799003)(82310400011)(451199024)(1800799009)(64100799003)(186009)(46966006)(40470700004)(36840700001)(40460700003)(36756003)(36860700001)(66574015)(8676002)(5660300002)(8936002)(44832011)(7416002)(426003)(336012)(83380400001)(26005)(1076003)(47076005)(2616005)(7696005)(6666004)(40480700001)(70206006)(70586007)(82740400003)(2906002)(4326008)(86362001)(41300700001)(81166007)(356005)(478600001)(54906003)(6916009)(316002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2023 21:22:42.5725 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cafdb6cf-e631-4647-0141-08dbd0e987bb 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: BL02EPF0001A108.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7240 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: , Cc: Sasha McIntosh , Liviu Dudau , Victoria Brekenfeld , =?utf-8?q?Michel_D=C3=A4nzer?= , Arthur Grillo , Sebastian Wick , Shashank Sharma , wayland-devel@lists.freedesktop.org, =?utf-8?q?Jonas_=C3=85dahl?= , Uma Shankar , Abhinav Kumar , Naseer Ahmed , Melissa Wen , Aleix Pol , Christopher Braga , Pekka Paalanen , Hector Martin , Xaver Hugl , Joshua Ashton Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" We want to be able to bypass each colorop at all times. Introduce a new BYPASS boolean property for this. Signed-off-by: Harry Wentland Cc: Ville Syrjala Cc: Pekka Paalanen Cc: Simon Ser Cc: Harry Wentland Cc: Melissa Wen Cc: Jonas Ådahl Cc: Sebastian Wick Cc: Shashank Sharma Cc: Alexander Goins Cc: Joshua Ashton Cc: Michel Dänzer Cc: Aleix Pol Cc: Xaver Hugl Cc: Victoria Brekenfeld Cc: Sima Cc: Uma Shankar Cc: Naseer Ahmed Cc: Christopher Braga Cc: Abhinav Kumar Cc: Arthur Grillo Cc: Hector Martin Cc: Liviu Dudau Cc: Sasha McIntosh --- drivers/gpu/drm/drm_atomic_uapi.c | 6 +++++- drivers/gpu/drm/drm_colorop.c | 15 +++++++++++++++ include/drm/drm_colorop.h | 20 ++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index 52b9b48e5757..a8f7a8a6639a 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -670,7 +670,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, @@ -690,6 +692,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 8d8f9461950f..ff6331fe5d5e 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -78,6 +78,18 @@ int drm_colorop_init(struct drm_device *dev, struct drm_colorop *colorop, colorop->type_property, colorop->type); + /* bypass */ + /* TODO can we reuse the mode_config->active_prop? */ + 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); + /* curve_1d_type */ /* TODO move to mode_config? */ prop = drm_property_create_enum(dev, DRM_MODE_PROP_ATOMIC, @@ -100,6 +112,8 @@ void __drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop, struct drm_colorop_state *state) { memcpy(state, colorop->state, sizeof(*state)); + + state->bypass = true; } struct drm_colorop_state * @@ -164,6 +178,7 @@ void __drm_colorop_state_reset(struct drm_colorop_state *colorop_state, struct drm_colorop *colorop) { colorop_state->colorop = colorop; + colorop_state->bypass = true; } EXPORT_SYMBOL(__drm_colorop_state_reset); diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h index 7701b61ff7e9..69636f6752a0 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -48,6 +48,14 @@ struct drm_colorop_state { /* colorop properties */ + /** + * @bypass: + * + * True if colorop shall be bypassed. False if colorop is + * enabled. + */ + bool bypass; + /** * @curve_1d_type: * @@ -135,6 +143,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: * From patchwork Thu Oct 19 21:21:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13429859 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 2708BC19F5C for ; Thu, 19 Oct 2023 21:22:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A325C10E555; Thu, 19 Oct 2023 21:22:51 +0000 (UTC) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on20620.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8d::620]) by gabe.freedesktop.org (Postfix) with ESMTPS id E86C310E543; Thu, 19 Oct 2023 21:22:42 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fbrQzSwLhNOXAAvuj0sMYgolGVcuepKQi5TUvU35hUMpIVKqgvDUPX/K8LrYDk7EoW0UpgP+XrHS4Qozqy/1ghrjjtlHP+qTy1C61tnUqZzqxbMl+KvXatUbabapLuCMkaHFUyoMXTxiWW7RI7HNPrSP2vm0lEzBlc2v9KJ/QUIWeP630vLKh33Xt/CE1/ka05GshvKHYB3d57ehefvFi6M/FJjrC0epUl3uK/7gyCi6p7xBhbn2aMekrN0wUGPzE4fvhKtjEpiocBUQQh2FtGGMNe26AJ+OkX13lajucjf/08a+MM2fkwPU0mUbcedM5SfebTnTSiGBwG+VYi2haw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=z7jEv3BTWUQxVPNi5abENN9M1I3utYtWgsVh/hURNjk=; b=e3imaIH1aob6hHHA4FQnKIL3ZzYnO5R18ArWPtQZ5ngBTiOSv2UqAVqwPjS0K9kgbkEZeNgfqKrUb2GvOwbXbdTTD26K+oIQFVxrBbYZ5sZXbXBgPNO0J5JdwHiCy387/HqN6eZDfkgoTm3Fu5qxZJPiixJzPIRR3SEWQFB0Z7v6VCzSHcJkZgpHBwrppROJW5mr/ec7u7yXU/cuUgbTK6dLYlO5N/MGh381repZ8LeqRIwyhzU6m+3MoA1YIXqMtBkyORccv4nqPID0fxKHiR09gen9YWD/BMVVhyxTKOoWb8l7CNiBi/TBrF2D50h/AkaTiGQAd0mh+kKXlYmEeA== 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 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=z7jEv3BTWUQxVPNi5abENN9M1I3utYtWgsVh/hURNjk=; b=WGL29CQHowPzgTf+zj2vGWY5/uN73eEIXXJWcaLIydDZSn105PfF/1zAxnkEeELqPZ6ytUGFbqP5Dd5X6Xhcd6mTGolsxEWQP3u+FZxDuGfAudzWuVawprFwZjff2w0MezjZooqY2I5y1OgEMu0MWx/fsIiDvRRm4baPHPVWi6E= Received: from BL1PR13CA0144.namprd13.prod.outlook.com (2603:10b6:208:2bb::29) by DM4PR12MB5037.namprd12.prod.outlook.com (2603:10b6:5:39a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.26; Thu, 19 Oct 2023 21:22:40 +0000 Received: from BL6PEPF0001AB72.namprd02.prod.outlook.com (2603:10b6:208:2bb:cafe::80) by BL1PR13CA0144.outlook.office365.com (2603:10b6:208:2bb::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.8 via Frontend Transport; Thu, 19 Oct 2023 21:22:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BL6PEPF0001AB72.mail.protection.outlook.com (10.167.242.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6907.20 via Frontend Transport; Thu, 19 Oct 2023 21:22:40 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 19 Oct 2023 16:22:39 -0500 Received: from hwentlanrmb.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Thu, 19 Oct 2023 16:22:38 -0500 From: Harry Wentland To: Subject: [RFC PATCH v2 11/17] drm/colorop: Add NEXT property Date: Thu, 19 Oct 2023 17:21:27 -0400 Message-ID: <20231019212133.245155-12-harry.wentland@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231019212133.245155-1-harry.wentland@amd.com> References: <20231019212133.245155-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB72:EE_|DM4PR12MB5037:EE_ X-MS-Office365-Filtering-Correlation-Id: 645f2902-a52d-480c-038a-08dbd0e98680 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 45cjFLSEuI+AlVSRXewh8w2U9UMs8InbsQTZswGsaG9TKPKU7J/krCVzM1T31/OptvilymnP/iT4rtrNOxinJ2Btjuq/05biLAVOSHMlvHG4XnjQlCBnD4qXJJBjQO3c7YNUEIF9lMhEm0Qhmwp5tIh1w20AfouHJR66/cC+Bz7GdjL8AawXegLBmCYUU+MbYsKR8r8fwTJPsff+RhHkNc2WEC8Rd0gknO2h8yYs6SYSLzGHHzSzyTdBigJ7REk8lmgbMGj1S2DgdGMgUDj15Bb5R7s1UMgdRIYqMDlHBLORnI2EtDFoOtW58AAMSNRfQHmhNxmxDQ0fQyG11B89t6h7v90D/yZcpurZ1pJfJZY3tPA6lh2fbJrfG5jRmmDZkr8A1cEPM6om7q8V0IiiulPv1r3wH90P1dgJchdWBDgMAWfbzNEu8MQk9mOoDIJzMN0iVgVlDt8ugrpjueWLSoSoiz2rjta1TnAxjJaQAXjFMS1K1h6mmE9q69zVSe/m4ShU8ZnWXCQ32GsDDlmi4tj91hVl7aFNOipDq2FFyiYR58IvkWCyX1hPlfeFo25c1139NI8mBK7ysgtBH90uMSHiLP4um2gEUMORTpJyMOdyKrflRNdjPSewNy7LZVZTQyiAaTB2SiwBa1JLPznaHkSk/wbnUnqHGBdKI6x1R66McZ51bARGsftLuuDwcLdTc8K5SeIR+889HwM8gJ2rR8sOAwhaDGI3Mx8jFeKHLIJH3YUDRXmh8/7n+VXPOW39TwryI5gUR5B1WRlX2JeMrA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(396003)(136003)(376002)(346002)(39860400002)(230922051799003)(64100799003)(451199024)(1800799009)(186009)(82310400011)(36840700001)(46966006)(40470700004)(40460700003)(86362001)(2906002)(47076005)(7416002)(4326008)(36756003)(41300700001)(44832011)(8676002)(1076003)(82740400003)(26005)(7696005)(336012)(81166007)(426003)(356005)(36860700001)(2616005)(5660300002)(40480700001)(6666004)(478600001)(8936002)(70586007)(70206006)(54906003)(316002)(6916009)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2023 21:22:40.5238 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 645f2902-a52d-480c-038a-08dbd0e98680 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB72.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5037 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: , Cc: Sasha McIntosh , Liviu Dudau , Victoria Brekenfeld , =?utf-8?q?Michel_D=C3=A4nzer?= , Arthur Grillo , Sebastian Wick , Shashank Sharma , wayland-devel@lists.freedesktop.org, =?utf-8?q?Jonas_=C3=85dahl?= , Uma Shankar , Abhinav Kumar , Naseer Ahmed , Melissa Wen , Aleix Pol , Christopher Braga , Pekka Paalanen , Hector Martin , Xaver Hugl , Joshua Ashton Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" We'll construct color pipelines out of drm_colorop by chaining them via the NEXT pointer. NEXT will point to the next drm_colorop in the pipeline, or by 0 if we're at the end of the pipeline. Signed-off-by: Harry Wentland Cc: Ville Syrjala Cc: Pekka Paalanen Cc: Simon Ser Cc: Harry Wentland Cc: Melissa Wen Cc: Jonas Ådahl Cc: Sebastian Wick Cc: Shashank Sharma Cc: Alexander Goins Cc: Joshua Ashton Cc: Michel Dänzer Cc: Aleix Pol Cc: Xaver Hugl Cc: Victoria Brekenfeld Cc: Sima Cc: Uma Shankar Cc: Naseer Ahmed Cc: Christopher Braga Cc: Abhinav Kumar Cc: Arthur Grillo Cc: Hector Martin Cc: Liviu Dudau Cc: Sasha McIntosh --- drivers/gpu/drm/drm_colorop.c | 27 +++++++++++++++++++++++++++ include/drm/drm_colorop.h | 12 ++++++++++++ 2 files changed, 39 insertions(+) diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c index ff6331fe5d5e..bc1250718baf 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -104,6 +104,15 @@ int drm_colorop_init(struct drm_device *dev, struct drm_colorop *colorop, colorop->curve_1d_type_property, 0); + 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; } EXPORT_SYMBOL(drm_colorop_init); @@ -262,3 +271,21 @@ const char *drm_get_colorop_curve_1d_type_name(enum drm_colorop_curve_1d_type ty return colorop_curve_1d_type_name[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->base.id); +} +EXPORT_SYMBOL(drm_colorop_set_next_property); diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h index 69636f6752a0..1ddd0e65fe36 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -162,10 +162,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_crtc_find - look up a Colorop object from its ID * @dev: DRM device @@ -212,5 +222,7 @@ 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) +void drm_colorop_set_next_property(struct drm_colorop *colorop, struct drm_colorop *next); + #endif /* __DRM_COLOROP_H__ */ From patchwork Thu Oct 19 21:21:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13429861 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 C4A25C07480 for ; Thu, 19 Oct 2023 21:23:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8185A10E566; Thu, 19 Oct 2023 21:23:04 +0000 (UTC) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2044.outbound.protection.outlook.com [40.107.237.44]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7B0D410E553; Thu, 19 Oct 2023 21:22:46 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=boz7Kf4bUfRRtzNhUOXVJyWXwFgkRLiBj2I4rj4oe42hzXd4jFelDw28sw82vWO0UmS9padzBumPs7ZnR6pt0ccPBvZbHQ1DdqIdjt/2NNggeRMuuUXcOYMe+0kVz/flgC9sAC2rg54uhdLj09iZkzvZ6GfWwPIP+ZwfDgZUnpu+rywODWo1jgSLE/LFmrUmgBity0yMK8Y0Yov9csf3Lazb2W6mqJndLKEjuuNUlLyFmAqrJy7QGKejnMbrI+HklZg63d03NQ2n5oGyAWvQpQ7uD4mdNUtO8r/YPbQl/jGr2WT2GDlpWuoZ0KLeIvdBrExn1Q1DPgIKK+G/WhBk3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4nn206DqeQRJWvwv8qf4IkdJ/1RSZZqxhIGsL/7deFo=; b=QSi7h7U77+QUuOlSGZVV5Z2PZuEHZoHCwUAlz9pVVxmFdPVIK87uJIVG4PA1GwtPk0o4MsfXN0W8GE8kwx/+yxYHrJpUTPJZfNLzjIEU6L/2m85t03BCZCeoYpIiOY6VuLV9mzDUVrzTjTJioBWXPR2Uoy48khMwwuiTWA9NvBefA/hcw7aEJkmMI3j8klUDz7Oyjp0Rbh1dTgrposdFWuxr9iXi2XY9cMb2cLz5YWogqVVQJ6dl3lnm7T0nsKEIcwR1YOLeF0yA+UVMiAxNZgfhPy+5DqRdw3zIh7aOIKTHX9iiDMXJ3s3Qxhxr8TYIa5HdGsONGdfieOU3r9kxpg== 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 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=4nn206DqeQRJWvwv8qf4IkdJ/1RSZZqxhIGsL/7deFo=; b=WOjY0jN416I0VpxNAlBal/IuxT4XI3q33IMSWia5gu7bXlaK3ceoxe+WMfPm1WxP7u7PahviavmmUbAVEiW5jo12njwmj4KNH0bzgs5wv61uHx85mv9O9DyGDEgLSDHj/++KXGkOAWjZBqc/JSm0jSEeSa0hKVVEz0rzOOgwiZ4= Received: from MN2PR07CA0017.namprd07.prod.outlook.com (2603:10b6:208:1a0::27) by DM4PR12MB7504.namprd12.prod.outlook.com (2603:10b6:8:110::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.26; Thu, 19 Oct 2023 21:22:42 +0000 Received: from BL6PEPF0001AB77.namprd02.prod.outlook.com (2603:10b6:208:1a0:cafe::c5) by MN2PR07CA0017.outlook.office365.com (2603:10b6:208:1a0::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.26 via Frontend Transport; Thu, 19 Oct 2023 21:22:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BL6PEPF0001AB77.mail.protection.outlook.com (10.167.242.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6907.20 via Frontend Transport; Thu, 19 Oct 2023 21:22:42 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 19 Oct 2023 16:22:41 -0500 Received: from hwentlanrmb.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Thu, 19 Oct 2023 16:22:39 -0500 From: Harry Wentland To: Subject: [RFC PATCH v2 12/17] drm/colorop: Add atomic state print for drm_colorop Date: Thu, 19 Oct 2023 17:21:28 -0400 Message-ID: <20231019212133.245155-13-harry.wentland@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231019212133.245155-1-harry.wentland@amd.com> References: <20231019212133.245155-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB77:EE_|DM4PR12MB7504:EE_ X-MS-Office365-Filtering-Correlation-Id: 9775a0c0-28ff-4cf8-5203-08dbd0e9878a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MS4UQebQ0HNMzz1KN9vfpnvvkDMuVjyEG3TAhpom6KV80Yt8Sv2Sh31OngOic2SDPKJ9xjTk0bKysaMTKtmtWtypGluFB1g9clfxVMGyBWjvZiPjfAo56o3sf4u9cDnEsw6v8b4Q063E1YSVHBB9rNmrd5H67IGsGaNrePmQs9XfzVnYZyHqSa4eaJ84CuOI6L2oBYnItVUuUTWGiQk60eU8lcvUqHFip46BuI6eSxN+5cjXOc5Y67YbHvU9k9Y6Jorctuij8lDLVc4lYxqEGUeoIMe/psjpXgccIybnvKNAQIIV3giBXQiEjjm1eL4Mjyn1Db/Dfc8QtT/ZQhIKwLEHiPOirDTMuyjfKZI8zmwz+P7CbFAISgJNc9jzrQVmmq6gWR6hWoFxO4tLNGAqiKOrBINakyCcNVvhgfFWUDxutyf9zSCWLGxFF4j/12vEqHB8zT9GmwZyGe/pb5ds9t74g+75Vcxi2/afXXcIaz3kjr5NicoKChUwDKvYSnI4pGG9rs1nE285LtMgvh4zRvikijs/zr5jUSwyGZjDd9pUfkogO6+njGa0gkFfiL+YBwrpBWltwGyJ3k95hSJ/p+z5JrBDyQSKOmYtB8po1sl7YPHeM1cvbmrUcVgFbnxa4q5NViaAmTWzySIM8ridicrh60uZhzHtxv8aUl64RRyNgLRU6UTubGX2lhmnDFfmY6W7bR5fkb8ITQo8dgNg+7v8K/3opHciJ8H6oGB4iZq9DwWodB/r2S+CsG0X7D5gkhWNH4WsolMiOOLWJoyI7w== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(396003)(376002)(39860400002)(136003)(346002)(230922051799003)(186009)(1800799009)(451199024)(82310400011)(64100799003)(46966006)(40470700004)(36840700001)(6916009)(2906002)(40460700003)(7416002)(5660300002)(44832011)(8676002)(36756003)(8936002)(4326008)(40480700001)(41300700001)(316002)(66574015)(70206006)(54906003)(86362001)(478600001)(6666004)(70586007)(2616005)(7696005)(1076003)(26005)(426003)(81166007)(356005)(336012)(36860700001)(82740400003)(83380400001)(47076005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2023 21:22:42.2534 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9775a0c0-28ff-4cf8-5203-08dbd0e9878a X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB77.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7504 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: , Cc: Sasha McIntosh , Liviu Dudau , Victoria Brekenfeld , =?utf-8?q?Michel_D=C3=A4nzer?= , Arthur Grillo , Sebastian Wick , Shashank Sharma , wayland-devel@lists.freedesktop.org, =?utf-8?q?Jonas_=C3=85dahl?= , Uma Shankar , Abhinav Kumar , Naseer Ahmed , Melissa Wen , Aleix Pol , Christopher Braga , Pekka Paalanen , Hector Martin , Xaver Hugl , Joshua Ashton Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Signed-off-by: Harry Wentland Cc: Ville Syrjala Cc: Pekka Paalanen Cc: Simon Ser Cc: Harry Wentland Cc: Melissa Wen Cc: Jonas Ådahl Cc: Sebastian Wick Cc: Shashank Sharma Cc: Alexander Goins Cc: Joshua Ashton Cc: Michel Dänzer Cc: Aleix Pol Cc: Xaver Hugl Cc: Victoria Brekenfeld Cc: Sima Cc: Uma Shankar Cc: Naseer Ahmed Cc: Christopher Braga Cc: Abhinav Kumar Cc: Arthur Grillo Cc: Hector Martin Cc: Liviu Dudau Cc: Sasha McIntosh --- drivers/gpu/drm/drm_atomic.c | 29 +++++++++++++++++++++++++++++ include/drm/drm_colorop.h | 5 +++++ 2 files changed, 34 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 524bec520287..15bd18c9e2be 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -792,6 +792,19 @@ static int drm_atomic_plane_check(const struct drm_plane_state *old_plane_state, return 0; } + + +static void drm_atomic_colorop_print_state(struct drm_printer *p, + const struct drm_colorop_state *state) +{ + struct drm_colorop *colorop = state->colorop; + + drm_printf(p, "colorop[%u]:\n", colorop->base.id); + drm_printf(p, "\ttype=%s\n", drm_get_colorop_type_name(colorop->type)); + drm_printf(p, "\tbypass=%u\n", state->bypass); + drm_printf(p, "\tcurve_1d_type=%s\n", drm_get_colorop_curve_1d_type_name(state->curve_1d_type)); +} + static void drm_atomic_plane_print_state(struct drm_printer *p, const struct drm_plane_state *state) { @@ -812,6 +825,13 @@ static void drm_atomic_plane_print_state(struct drm_printer *p, drm_get_color_encoding_name(state->color_encoding)); drm_printf(p, "\tcolor-range=%s\n", drm_get_color_range_name(state->color_range)); +#if 0 + drm_printf(p, "\tcolor-pipeline=%s\n", + drm_get_color_pipeline_name(state->color_pipeline)); +#else + drm_printf(p, "\tcolor-pipeline=%d\n", + state->color_pipeline ? state->color_pipeline->base.id : 0); +#endif if (plane->funcs->atomic_print_state) plane->funcs->atomic_print_state(p, state); @@ -1848,6 +1868,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; @@ -1856,6 +1877,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); diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h index 1ddd0e65fe36..622a671d2458 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -222,6 +222,11 @@ 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) +const char *drm_get_color_pipeline_name(struct drm_colorop *colorop); + +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); From patchwork Thu Oct 19 21:21:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13429860 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 7CD42C001DF for ; Thu, 19 Oct 2023 21:23:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2F4DF10E568; Thu, 19 Oct 2023 21:23:03 +0000 (UTC) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20631.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e88::631]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1CD0B10E54E; Thu, 19 Oct 2023 21:22:48 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QwXLdZwf+WAOyYottOzZJzoItAYIT7qHO7UZEjKgR5kSYl4VSGRnaF1U6dkZYo9LiQXZ/S8nNcfo9YDK89m1/VYr9G3+G/ZuKqbHl0Bhepq8ziAf9eRHmYW3Y4Mf6up04K41+9Nzb/v5gfPIiFNbV0mnDx2ocHVr/A0oWo70sADITsfTZ3m/Ehe4B1AI8j7aMCQJ+nS0EWHcxulTE6ZXG0WMJxZA7HI+67p1Vp4M/hwyyavIbKt6LsMRU+BxZLvfVpu/UdV1PWwRujmhncBVeYeJe011Loe9YP/U4tkA82lG81b1hO+gxBQ6IHPImpANzCNyAfNR9KniagJ70bSlkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ttubomwN/OpCoz4E4NiUcH3OcPQ11gsS/g82jclU64I=; b=ccbUVoILCtjAY/vsNsHG79/fwUmc8iB1Szmv/b1S98LLmlIrnXD1Kdii1UZ1w85Hm/okoWM4AvmIa5nFwYVPRTM3a8zeybpY3cKRFV4eO91CWRuuTKB+54TD/A0pZTZcZ3qvj7gNjS1G63dsgAMT2IHkWeQGtdkY82Z7dRHO5ieDxyDhTUmGzNcJupqWeSh9kWdyNyuHgFFiG1+7mbEBlFM5NfTe75jALkBMwutw8Tx0nO4KmS9KcKl4X5Th6xrVmamOTycqLH8JuDfxUC8CissX2Kzqs6m0tva3GDGLvJMh+NHL654GTUMJlDaZ4T9Po35lOaAjKqeus/q4Y6HXlQ== 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 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=ttubomwN/OpCoz4E4NiUcH3OcPQ11gsS/g82jclU64I=; b=YYnjryAVWlczmu5MLGmGSclCWAeZ4tV5oE9Tc6SE6+XLBjTpXFh23rB0+M6LlLvOQr20XmPrKRUTtsToMcUzVf2oj3jj8d5J7ksuXMhG3fPvwwUhKD5Ld/QuPu/1RZPvVeRS8PJTKZNRLdkxukTuRqLkGZR0jUoGsXN0rnS6fBY= Received: from MN2PR03CA0018.namprd03.prod.outlook.com (2603:10b6:208:23a::23) by DM4PR12MB7719.namprd12.prod.outlook.com (2603:10b6:8:101::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.26; Thu, 19 Oct 2023 21:22:44 +0000 Received: from BL02EPF0001A105.namprd05.prod.outlook.com (2603:10b6:208:23a:cafe::f8) by MN2PR03CA0018.outlook.office365.com (2603:10b6:208:23a::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.24 via Frontend Transport; Thu, 19 Oct 2023 21:22:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL02EPF0001A105.mail.protection.outlook.com (10.167.241.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6907.21 via Frontend Transport; Thu, 19 Oct 2023 21:22:43 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 19 Oct 2023 16:22:43 -0500 Received: from hwentlanrmb.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Thu, 19 Oct 2023 16:22:42 -0500 From: Harry Wentland To: Subject: [RFC PATCH v2 13/17] drm/colorop: Add new IOCTLs to retrieve drm_colorop objects Date: Thu, 19 Oct 2023 17:21:29 -0400 Message-ID: <20231019212133.245155-14-harry.wentland@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231019212133.245155-1-harry.wentland@amd.com> References: <20231019212133.245155-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A105:EE_|DM4PR12MB7719:EE_ X-MS-Office365-Filtering-Correlation-Id: dd414f6d-2bc8-4cfb-1e81-08dbd0e98872 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 51J6x+9tTRlXRzyRWOwIcDqKQhVTJhVUbNe05U4kCF9kdk3cnkMCjOA2Sjo80CG4LH9Scth28AYTEj3+CYKxIvYxRe34owdqX/ni9A6t7/C9sMqF/i0CyA5K/Q4Hc4OHFpZhNZQ6lfCmihOOc24h0n2MHE775fowmvfE1bFKWu/fF4YOZqDFF8pjxgnkOBOpQ3HJlq6Fk/e55mDWnRJm4M1ostrpjifyEIB5foyPGTRY3iU+tjvbiF/EsR7YhXmMYUclKZ3Xm25x+/qZtM6hKseNj1zPj8GlVrkkJy/hMYg52+AUGoBe4l5PIze+cAoulyDO6tQNgPFxSUVU0U2mZCZ3pCxZ+v8MA/y0fEjtVxJC+ncPIN5vtKE3gVj4XoaHHaEoSLm24uXsPNbG1Zvope5zSG4DMC1Z7LZHLFUuOpj47mi6AjNFPgUuh0Dqpj6PcVviVbAq4C3DObK3t7Y9CDqRVgxLcXzNDvBBIzksdWk1euf2h7FacDVPneVnrH1+u/DR4uA61hXBJumlFU72F6IpTAntgin/75RobKRdQ7jciB+k9saAJwildg6lSS9QFB3as/Qfvo4L0hE+BpPK+e38f62QmK3P8bXkkvNaf9VFB4eEeiNjAek4vqB0jn5IAV+t7/KurOAw0d/e1us5/HPUck6Yah8vd4Q/zqq5cx9OknmHPPgyTeJDNZkwX8QzVJmaK9YujknMiJSXAwJYO4TxMY+9S6xqSMnO59dprZ8FKcMJy6jGlgtuUKMPX1LUZlqAQQx3a04OOa+FXRlhNQ== 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:(13230031)(4636009)(39860400002)(376002)(396003)(136003)(346002)(230922051799003)(64100799003)(1800799009)(82310400011)(451199024)(186009)(36840700001)(46966006)(40470700004)(40460700003)(86362001)(47076005)(44832011)(41300700001)(36756003)(5660300002)(7696005)(4326008)(7416002)(2906002)(1076003)(82740400003)(40480700001)(26005)(81166007)(356005)(336012)(426003)(36860700001)(2616005)(478600001)(8676002)(6666004)(8936002)(70206006)(70586007)(6916009)(316002)(54906003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2023 21:22:43.7726 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dd414f6d-2bc8-4cfb-1e81-08dbd0e98872 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: BL02EPF0001A105.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7719 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: , Cc: Sasha McIntosh , Liviu Dudau , Victoria Brekenfeld , =?utf-8?q?Michel_D=C3=A4nzer?= , Arthur Grillo , Sebastian Wick , Shashank Sharma , wayland-devel@lists.freedesktop.org, =?utf-8?q?Jonas_=C3=85dahl?= , Uma Shankar , Abhinav Kumar , Naseer Ahmed , Melissa Wen , Aleix Pol , Christopher Braga , Pekka Paalanen , Hector Martin , Xaver Hugl , Joshua Ashton Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Since we created a new DRM object we need new IOCTLs (and new libdrm functions) to retrieve those objects. TODO: Can we make these IOCTLs and libdrm functions generic to allow for new DRM objects in the future without the need for new IOCTLs and libdrm functions? Signed-off-by: Harry Wentland Cc: Ville Syrjala Cc: Pekka Paalanen Cc: Simon Ser Cc: Harry Wentland Cc: Melissa Wen Cc: Jonas Ådahl Cc: Sebastian Wick Cc: Shashank Sharma Cc: Alexander Goins Cc: Joshua Ashton Cc: Michel Dänzer Cc: Aleix Pol Cc: Xaver Hugl Cc: Victoria Brekenfeld Cc: Sima Cc: Uma Shankar Cc: Naseer Ahmed Cc: Christopher Braga Cc: Abhinav Kumar Cc: Arthur Grillo Cc: Hector Martin Cc: Liviu Dudau Cc: Sasha McIntosh --- drivers/gpu/drm/drm_colorop.c | 51 +++++++++++++++++++++++++++++ drivers/gpu/drm/drm_crtc_internal.h | 4 +++ drivers/gpu/drm/drm_ioctl.c | 5 +++ include/uapi/drm/drm_mode.h | 21 ++++++++++++ 4 files changed, 81 insertions(+) diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c index bc1250718baf..1afd5fbe8776 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -32,6 +32,57 @@ /* TODO big colorop doc, including properties, etc. */ +/* IOCTLs */ + +int drm_mode_getcolorop_res(struct drm_device *dev, void *data, + struct drm_file *file_priv) +{ + struct drm_mode_get_colorop_res *colorop_resp = data; + struct drm_colorop *colorop; + uint32_t __user *colorop_ptr; + int count = 0; + + if (!drm_core_check_feature(dev, DRIVER_MODESET)) + return -EOPNOTSUPP; + + colorop_ptr = u64_to_user_ptr(colorop_resp->colorop_id_ptr); + + /* + * This ioctl is called twice, once to determine how much space is + * needed, and the 2nd time to fill it. + */ + drm_for_each_colorop(colorop, dev) { + if (drm_lease_held(file_priv, colorop->base.id)) { + if (count < colorop_resp->count_colorops && + put_user(colorop->base.id, colorop_ptr + count)) + return -EFAULT; + count++; + } + } + colorop_resp->count_colorops = count; + + return 0; +} + +int drm_mode_getcolorop(struct drm_device *dev, void *data, + struct drm_file *file_priv) +{ + struct drm_mode_get_colorop *colorop_resp = data; + struct drm_colorop *colorop; + + if (!drm_core_check_feature(dev, DRIVER_MODESET)) + return -EOPNOTSUPP; + + colorop = drm_colorop_find(dev, file_priv, colorop_resp->colorop_id); + if (!colorop) + return -ENOENT; + + colorop_resp->colorop_id = colorop->base.id; + colorop_resp->plane_id = colorop->plane ? colorop->plane->base.id : 0; + + return 0; +} + static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { { DRM_COLOROP_1D_CURVE, "1D Curve" }, }; diff --git a/drivers/gpu/drm/drm_crtc_internal.h b/drivers/gpu/drm/drm_crtc_internal.h index 8556c3b3ff88..252cd7e607e3 100644 --- a/drivers/gpu/drm/drm_crtc_internal.h +++ b/drivers/gpu/drm/drm_crtc_internal.h @@ -278,6 +278,10 @@ int drm_mode_getplane(struct drm_device *dev, void *data, struct drm_file *file_priv); int drm_mode_setplane(struct drm_device *dev, void *data, struct drm_file *file_priv); +int drm_mode_getcolorop_res(struct drm_device *dev, void *data, + struct drm_file *file_priv); +int drm_mode_getcolorop(struct drm_device *dev, void *data, + struct drm_file *file_priv); int drm_mode_cursor_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv); int drm_mode_cursor2_ioctl(struct drm_device *dev, diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index 77590b0f38fa..8a4b7d8d8a0b 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -717,6 +717,11 @@ static const struct drm_ioctl_desc drm_ioctls[] = { DRM_IOCTL_DEF(DRM_IOCTL_MODE_LIST_LESSEES, drm_mode_list_lessees_ioctl, DRM_MASTER), DRM_IOCTL_DEF(DRM_IOCTL_MODE_GET_LEASE, drm_mode_get_lease_ioctl, DRM_MASTER), DRM_IOCTL_DEF(DRM_IOCTL_MODE_REVOKE_LEASE, drm_mode_revoke_lease_ioctl, DRM_MASTER), + + DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETCOLOROPRESOURCES, drm_mode_getcolorop_res, 0), + /* TODO do we need GETCOLOROP? */ + DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETCOLOROP, drm_mode_getcolorop, 0), + }; #define DRM_CORE_IOCTL_COUNT ARRAY_SIZE(drm_ioctls) diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index 009a800676ac..5c71eb011181 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -357,6 +357,27 @@ struct drm_mode_get_plane { __u64 format_type_ptr; }; +struct drm_mode_get_colorop_res { + __u64 colorop_id_ptr; + __u32 count_colorops; +}; + + +/** + * struct drm_mode_get_colorop - Get colorop metadata. + * + * Userspace can perform a GETCOLOROP ioctl to retrieve information about a + * colorop. + */ +struct drm_mode_get_colorop { + /** + * @colorop_id: Object ID of the colorop whose information should be + * retrieved. Set by caller. + */ + __u32 colorop_id; + __u32 plane_id; +}; + struct drm_mode_get_plane_res { __u64 plane_id_ptr; __u32 count_planes; From patchwork Thu Oct 19 21:21:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13429862 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 C980EC07545 for ; Thu, 19 Oct 2023 21:23:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 24BD510E561; Thu, 19 Oct 2023 21:23:05 +0000 (UTC) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2083.outbound.protection.outlook.com [40.107.244.83]) by gabe.freedesktop.org (Postfix) with ESMTPS id F264710E553; Thu, 19 Oct 2023 21:22:47 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KbqlXjwlouRiZqh0vQzRH/Yg4w/xMd90ZJnqzi9nAijHc8TU3kHNqPU/H1DJu4qviVtom80jC5x1kEoTUwDPhxVTCFB1h3/Nd6rQTHaZst1kiBifGqjQZE2s+6oDzwWkR7IuwYdaZURiRgEq0/gD/dgXzQCqxJWHY9RpM69tP9bfh23c6HDjakiY5Pl4VtG7mpLjvsUEsEux1/wCmQuYuUasq/ErQj3OV0uyVOg56wvLyULMwgNcXJzP5BQzV3ux+BsaBZN5etfxZuJqYfwO4OL5YPRtkf/bcfpPvFE39ZPsD8qpZ3YCkrRxSokitns2gioQXT1/6DQuPl5VzY9L4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=pOigC+oGc/lrW6GC9FWtUA7Lr9q5xuHjiAp4dCE2jek=; b=NLV833oA7v+tNp1UV2/f2TR4gkIbBIXP/MSdc+HIBToQuywagHrcYpsXi5r2KlsOr4kgAhMThgJTNxHpNt5sLmAIEyM6jkHllfLUxT63C5FYxpI9jY2b8khD5VlVxZIv+VJKwhCqsrIGoFZtJzwP9UwdBACEUjW/XPOlEBghhC/OuvhwrqmWMPnS7a9pTocWiL/uHaNkrV7X410qlC1/RxBR68JG0kSijdSM3XolKrM0IGHamf/Wmq6OB0C19MvcQ0G+Q/msoOjxDyDHWG2CFME8XckyWkubAvpPgVtwnLeaOAn1OrtRi7YRlIr5aFCklfTgC18q7C+zckUSzw0l2A== 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 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=pOigC+oGc/lrW6GC9FWtUA7Lr9q5xuHjiAp4dCE2jek=; b=NmMtOfk3cUxRI+I4nHAOwwE8Bmx6JY/sy7LF2TwXCJlIoY9jF0VcaNENwTtcUuWROKy1rNzoUA3GJahrnhMN6T1lxrMiRwIlnLTVFBFgFl3UBYwTp2EicwB1hoAusexwlbBW5Lmuky/EHkLeFrjgOYW7Mz02xsopdpKbg0abz8U= Received: from MN2PR17CA0010.namprd17.prod.outlook.com (2603:10b6:208:15e::23) by CH0PR12MB5107.namprd12.prod.outlook.com (2603:10b6:610:be::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.26; Thu, 19 Oct 2023 21:22:45 +0000 Received: from BL6PEPF0001AB78.namprd02.prod.outlook.com (2603:10b6:208:15e:cafe::c1) by MN2PR17CA0010.outlook.office365.com (2603:10b6:208:15e::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.26 via Frontend Transport; Thu, 19 Oct 2023 21:22:45 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BL6PEPF0001AB78.mail.protection.outlook.com (10.167.242.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6907.21 via Frontend Transport; Thu, 19 Oct 2023 21:22:45 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 19 Oct 2023 16:22:45 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 19 Oct 2023 16:22:44 -0500 Received: from hwentlanrmb.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Thu, 19 Oct 2023 16:22:43 -0500 From: Harry Wentland To: Subject: [RFC PATCH v2 14/17] drm/plane: Add COLOR PIPELINE property Date: Thu, 19 Oct 2023 17:21:30 -0400 Message-ID: <20231019212133.245155-15-harry.wentland@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231019212133.245155-1-harry.wentland@amd.com> References: <20231019212133.245155-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB78:EE_|CH0PR12MB5107:EE_ X-MS-Office365-Filtering-Correlation-Id: 66eea343-e1af-44c3-1584-08dbd0e98986 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qfQiCUDu3HC3tlYrT4IDdshuX4uMitnkIIo1WpqZp4bo1WJV5/pgr6hYvaXT2nZu5zBExtumiMU8zasBsK0K+8Mmvdsj7uUjuIbwUwNv9kMH3ePWwgtaTfEocTN3ZhRvxJRDIM2LUM3lX4W9P8k0l7d1Vtbd6gPyToI9O8N6rGIp52quosJw5IocS0nDLb8d/TfrdAD30TXANGteWvl7vUo2iQ1Xo9MMEfnR8rzX/7QF3Ia2Rc6I4N3SEVu9HG0XOoIaNDe8WrNxgCuGwugvuMW3Gng3iXVrDTjNu1AQlbULVKIz+6TAaerc5H4pcANn95Wbo1qbc/rWh5PymiuM3mA5OnQdXK6xtB4hhG/bhtIAlYBqUwbi7/TwAMoqYHPzrADuE1QnlCjfu2TBy+ykb2iLcuJ8Y143ufkiJWbvWNRQApiO3dAHRjjZbVW5DVQsfWRYC1Yw2iUrgWI2e72ogQaQ5TZUa32xkVxWHbmpqNcnmI2xDfm+jxbocqHidl9BwpopsDrg6VEq20tj/WX2MvarQe3uOFSUX+S6twYFm4ygPyr4TBlu+DlniDQ8M30lg2gVfXjhyk+X1nnUDWtpzwAa4HxVMmlA4kR0h42ZCQqFtpVhSUmGYPzxOTaSvA8o8qXZYKCpiwSVuRTD4X/zG9wlkbLLFLy91UTwfVx8Q/GZE0YLCTbnPIS+oQGCcaGBYh4RtRm1u9UjzFnVmA8gcVhJ2F1+t7eirSjbupnuL/7Tu2JP9tTGPhDyrY03zD/aTiSW1k5FdRuuncZ9aqBJGw== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(136003)(396003)(346002)(376002)(39860400002)(230922051799003)(451199024)(186009)(64100799003)(82310400011)(1800799009)(46966006)(40470700004)(36840700001)(86362001)(40460700003)(70586007)(70206006)(54906003)(6916009)(316002)(8676002)(6666004)(478600001)(8936002)(36756003)(5660300002)(44832011)(41300700001)(2906002)(40480700001)(4326008)(7696005)(7416002)(47076005)(36860700001)(2616005)(83380400001)(66574015)(81166007)(356005)(26005)(426003)(336012)(82740400003)(1076003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2023 21:22:45.5967 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 66eea343-e1af-44c3-1584-08dbd0e98986 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB78.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5107 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: , Cc: Sasha McIntosh , Liviu Dudau , Victoria Brekenfeld , =?utf-8?q?Michel_D=C3=A4nzer?= , Arthur Grillo , Sebastian Wick , Shashank Sharma , wayland-devel@lists.freedesktop.org, =?utf-8?q?Jonas_=C3=85dahl?= , Uma Shankar , Abhinav Kumar , Naseer Ahmed , Melissa Wen , Aleix Pol , Christopher Braga , Pekka Paalanen , Hector Martin , Xaver Hugl , Joshua Ashton Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" We're adding a new enum COLOR PIPELINE property. This property will have entries for each COLOR PIPELINE by referencing the DRM object ID of the first drm_colorop of the pipeline. 0 disables the entire COLOR PIPELINE. Userspace can use this to discover the available color pipelines, as well as set the desired one. The color pipelines are programmed via properties on the actual drm_colorop objects. Signed-off-by: Harry Wentland Cc: Ville Syrjala Cc: Pekka Paalanen Cc: Simon Ser Cc: Harry Wentland Cc: Melissa Wen Cc: Jonas Ådahl Cc: Sebastian Wick Cc: Shashank Sharma Cc: Alexander Goins Cc: Joshua Ashton Cc: Michel Dänzer Cc: Aleix Pol Cc: Xaver Hugl Cc: Victoria Brekenfeld Cc: Sima Cc: Uma Shankar Cc: Naseer Ahmed Cc: Christopher Braga Cc: Abhinav Kumar Cc: Arthur Grillo Cc: Hector Martin Cc: Liviu Dudau Cc: Sasha McIntosh --- drivers/gpu/drm/drm_atomic.c | 46 +++++++++++++++++++++++ drivers/gpu/drm/drm_atomic_state_helper.c | 5 +++ drivers/gpu/drm/drm_atomic_uapi.c | 44 ++++++++++++++++++++++ include/drm/drm_atomic_uapi.h | 2 + include/drm/drm_plane.h | 8 ++++ 5 files changed, 105 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 15bd18c9e2be..781bd3aa1849 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -1472,6 +1472,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 784e63d70a42..3c5f2c8e33d0 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 a8f7a8a6639a..c6629fdaa114 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -256,6 +256,38 @@ 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 + * + * Changing the assigned framebuffer for a plane requires us to grab a reference + * to the new fb and drop the reference to the old fb, if there is one. This + * function takes care of all these details besides updating the pointer in the + * state object itself. + */ +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 @@ -581,6 +613,16 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane, state->color_encoding = val; } else if (property == plane->color_range_property) { state->color_range = val; + } else if (property == plane->color_pipeline_property) { + /* find DRM colorop object */ + struct drm_colorop *colorop = NULL; + colorop = drm_colorop_find(dev, file_priv, val); + + if (val && !colorop) + return -EACCES; + + /* set it on drm_plane_state */ + drm_atomic_set_colorop_for_plane(state, colorop); } else if (property == config->prop_fb_damage_clips) { ret = drm_atomic_replace_property_blob_from_id(dev, &state->fb_damage_clips, @@ -647,6 +689,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/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 57bbd0cd73a9..e65074f266c0 100644 --- a/include/drm/drm_plane.h +++ b/include/drm/drm_plane.h @@ -745,6 +745,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. From patchwork Thu Oct 19 21:21:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13429864 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 F3C99C004C0 for ; Thu, 19 Oct 2023 21:23:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 257B610E56A; Thu, 19 Oct 2023 21:23:21 +0000 (UTC) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20620.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eaa::620]) by gabe.freedesktop.org (Postfix) with ESMTPS id 26CB910E55E; Thu, 19 Oct 2023 21:22:58 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KFF6NSOkSIxxD2e86z8kAZ+yDycZb3s0o4H5GCXDMjI3DolRGJSczt+oRyWiyQO6ojHfotqcwGNFu6x9/TghMUcfS0RJZAaL1NCCKoLyAYHakeVOaCCNftWV9I223UlJzsorqoUepq5RHLm85E1FERHXbiPhbyDNWMr8sTJuBZHilpEqQEgM4mQrnI4qPou8zr2kkmGn0HiJBEhyAqwpkoTkw3mSOE9r7B0yRvcHwGYgGkMnqGzajoYFBwyT5E+BE19h+WYokHwv+8s6rzhNhJWSYLnWnuQ/kJL7g/NiefthfhicvdyuDODVwxs8KGOuwd00aeGsPsWmMtZgfRzNBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8EvYN6XvGkXknfyJzGpmQnPnHf752ScvE6yDm6rs2yc=; b=USw1INJx9+jGfR6uEXDqH4jplW3hutQdGqcyOPL23UYXf0WxqvX+QSrzcTINEiltj8VljoUsRZdu2paYSEKYbWe5kfIs5VRz380hjyA7w7uw8BBMDYdq3Fy9rgF2Jwf/8kiDPzhEVgIFBF/xW/KWRH+roGg+Q96vrs9rQBjClootYDx2aRy0uS1k0ETA1gzdelwQ+2z80fdtRtGisLR6otiNRD1wvintebqvXLm5u3mpiXheVy8HC2h31iTCjlUoqzEMPrc1BUl5gKwGanr4kwZSoYbJ3+hJxWz3+U8Oxw4RN7SZlVxf5NEKq008GG+WotPNm+RG8+YXyS0isC+9gg== 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 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=8EvYN6XvGkXknfyJzGpmQnPnHf752ScvE6yDm6rs2yc=; b=PbdiWOguM47vCKdVXXSkRonUa0gR5RgpGc9nu3QbKAO8pIEtkzgzUF4tYVL+QIkSWf1VyZM63FfiMxs73qPJrPg/l5+hMdYNVvk9ForlEQf/5BhcvwyuM9Qh7dOeVT16W5FytmttK0DMCSKS+SseEsFmxWSrgKGsvwGz5HZCtkg= Received: from MN2PR03CA0026.namprd03.prod.outlook.com (2603:10b6:208:23a::31) by DM6PR12MB4155.namprd12.prod.outlook.com (2603:10b6:5:221::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.37; Thu, 19 Oct 2023 21:22:53 +0000 Received: from BL02EPF0001A105.namprd05.prod.outlook.com (2603:10b6:208:23a:cafe::c8) by MN2PR03CA0026.outlook.office365.com (2603:10b6:208:23a::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.25 via Frontend Transport; Thu, 19 Oct 2023 21:22: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 BL02EPF0001A105.mail.protection.outlook.com (10.167.241.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6907.21 via Frontend Transport; Thu, 19 Oct 2023 21:22:53 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 19 Oct 2023 16:22:46 -0500 Received: from hwentlanrmb.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Thu, 19 Oct 2023 16:22:45 -0500 From: Harry Wentland To: Subject: [RFC PATCH v2 15/17] drm/colorop: Add NEXT to colorop state print Date: Thu, 19 Oct 2023 17:21:31 -0400 Message-ID: <20231019212133.245155-16-harry.wentland@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231019212133.245155-1-harry.wentland@amd.com> References: <20231019212133.245155-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A105:EE_|DM6PR12MB4155:EE_ X-MS-Office365-Filtering-Correlation-Id: 4e370bae-b20f-4b1f-d797-08dbd0e98e41 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wXSPs7ipnMUr30Yv9V+P80B6Xum1U5iubMsO5vsV+EKAahIP6oQsIDo/qrbvcQXaH/HnNY5O0NMzkGMjNG30S8h7nSxSIUvqAXwIocTNP6DN24pfrVU0bGVgLkgY1PMaDThP47XCsixMu3se8BF2W7ba/X/JRlbklu10x4UDkks7hOO7geBbl5a/AD5ZVSp1lbCFzei9qguRRkkANGYkoFOZDiu30NgyqPm1RCrgg+a1+z7fzRK7+ioNE6IxbcLuHaI8EqhQPusixxP8cHk9Csf3K7oFqf3uUYC8C0/HMasHBY7xzVmXsOhI0ahfykLA0ywy4MWVZPjlcOn0GxehtpislWKEiVtxuzZAk+J8jiUiJzqTYRAmoIJnwcf4qCf3vHkYFVm6Ni1DzkgEyHliCpsX2+ZLXtBuAzC4Ir4H6RfExOyPuLwb8hgufPpN1+mxkAPUe8nOK4k48O1gnUc/STHnZIOSVDFui2u9VjgXADLpgx1EUgFNe/A0WrmmVk93Fc1Txmdwpuq0kbROZBjmOvi4861iA1FYKdJLLkykpeeqMIzg6v8iA+tPu7dMPEgHgJoniGOwA5gJVYwhuBwkY5eNXeEFYSHo3Hac46XzTgfsWbHbRHWeLipHcYlGyLqOHZvcy8cNfqNwNs7G0eFSWCCytR6GuNi7DiILOuq9pEZ5ET4/uDqXIe07tKXbup8Oule2+W8JTFA+ObAa3LFrK6jr44F8y405pvwHaPpFPRrexjiZszJQsZJSCOSvmGwll7+97HdffgXtbRtBDuVQHQ== 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:(13230031)(4636009)(396003)(136003)(346002)(376002)(39860400002)(230922051799003)(64100799003)(1800799009)(186009)(451199024)(82310400011)(46966006)(40470700004)(36840700001)(2906002)(41300700001)(6666004)(8676002)(2616005)(1076003)(70586007)(40480700001)(82740400003)(36860700001)(7696005)(316002)(478600001)(44832011)(86362001)(36756003)(356005)(81166007)(40460700003)(426003)(47076005)(7416002)(336012)(5660300002)(6916009)(4326008)(8936002)(70206006)(54906003)(26005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2023 21:22:53.5225 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4e370bae-b20f-4b1f-d797-08dbd0e98e41 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: BL02EPF0001A105.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4155 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: , Cc: Sasha McIntosh , Liviu Dudau , Victoria Brekenfeld , =?utf-8?q?Michel_D=C3=A4nzer?= , Arthur Grillo , Sebastian Wick , Shashank Sharma , wayland-devel@lists.freedesktop.org, =?utf-8?q?Jonas_=C3=85dahl?= , Uma Shankar , Abhinav Kumar , Naseer Ahmed , Melissa Wen , Aleix Pol , Christopher Braga , Pekka Paalanen , Hector Martin , Xaver Hugl , Joshua Ashton Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Signed-off-by: Harry Wentland Cc: Ville Syrjala Cc: Pekka Paalanen Cc: Simon Ser Cc: Harry Wentland Cc: Melissa Wen Cc: Jonas Ådahl Cc: Sebastian Wick Cc: Shashank Sharma Cc: Alexander Goins Cc: Joshua Ashton Cc: Michel Dänzer Cc: Aleix Pol Cc: Xaver Hugl Cc: Victoria Brekenfeld Cc: Sima Cc: Uma Shankar Cc: Naseer Ahmed Cc: Christopher Braga Cc: Abhinav Kumar Cc: Arthur Grillo Cc: Hector Martin Cc: Liviu Dudau Cc: Sasha McIntosh --- drivers/gpu/drm/drm_atomic.c | 1 + drivers/gpu/drm/drm_colorop.c | 42 +++++++++++++++++++++++++++++++++++ include/drm/drm_colorop.h | 2 ++ 3 files changed, 45 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 781bd3aa1849..cfe9199a15d2 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -803,6 +803,7 @@ static void drm_atomic_colorop_print_state(struct drm_printer *p, drm_printf(p, "\ttype=%s\n", drm_get_colorop_type_name(colorop->type)); drm_printf(p, "\tbypass=%u\n", state->bypass); drm_printf(p, "\tcurve_1d_type=%s\n", drm_get_colorop_curve_1d_type_name(state->curve_1d_type)); + drm_printf(p, "\tnext=%d\n", drm_colorop_get_next_property(colorop)); } static void drm_atomic_plane_print_state(struct drm_printer *p, diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c index 1afd5fbe8776..ff6f938cc28c 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -340,3 +340,45 @@ void drm_colorop_set_next_property(struct drm_colorop *colorop, struct drm_color next->base.id); } EXPORT_SYMBOL(drm_colorop_set_next_property); + +/** + * drm_colorop_set_next_property - gets the next colorop ID + * @colorop: drm colorop + * + * Returns: + * The DRM object ID of the next colorop + */ +uint32_t drm_colorop_get_next_property(struct drm_colorop *colorop) +{ + uint64_t next_id = 0; + + if (!colorop->next_property) + return 0; + + drm_object_property_get_value(&colorop->base, + colorop->next_property, + &next_id); + + return (uint32_t) next_id; +} +EXPORT_SYMBOL(drm_colorop_get_next_property); + + +/** + * drm_colorop_set_next_property - gets the next colorop ID + * @colorop: drm colorop + * + * Returns: + * The DRM object ID of the next colorop + */ +struct drm_colorop *drm_colorop_get_next(struct drm_colorop *colorop) +{ + uint64_t next_id = drm_colorop_get_next_property(colorop); + + if (!next_id) + return NULL; + + return drm_colorop_find(colorop->dev, NULL, next_id); + +} +EXPORT_SYMBOL(drm_colorop_get_next); \ No newline at end of file diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h index 622a671d2458..2ba506a0ea4d 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -228,6 +228,8 @@ 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); +uint32_t drm_colorop_get_next_property(struct drm_colorop *colorop); +struct drm_colorop *drm_colorop_get_next(struct drm_colorop *colorop); #endif /* __DRM_COLOROP_H__ */ From patchwork Thu Oct 19 21:21:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13429863 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 7E6A8C004C0 for ; Thu, 19 Oct 2023 21:23:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 07DF310E55F; Thu, 19 Oct 2023 21:23:04 +0000 (UTC) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by gabe.freedesktop.org (Postfix) with ESMTPS id 641CE10E560; Thu, 19 Oct 2023 21:22:57 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OXAJ0wD4jIy1Dy/eNeQ1ATw2KnuLZqVV3bnF33r7Ui8QYqlmzzt/EfYzOAqc5XgG5KGp6PoQcNnFlx8qj/lnDWE2iB1udwJ3hYBNpmZvatZBY4PxUQDvNP75vLQ5x18tvOG5sFl7Or7ZRqaBDBohItejRKrbFErne8+9HbyaP9t3kL+MD1sH+xqLKfj5B+GFiIEivFUToXo7YXt6YCIAhiAUMuk9f4Ohxk/QGTj97lc8T7Yvw+ZBNR71cEQnDZW5RKJjDr6ENAwXvelFCtoxZcAHCmKDOI6ip+xdSxfJcqARdafyU815wum5JCQmwwDqx4RwStIbnO07QQsx/5h7mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jkgOKrmaMstEpE+ziDAs7GJ5TS/udvSi02W1RmG3/wA=; b=nADapBHcMGl2mP/+6YHFmtBrwjPkxmRTc5LKzLQuFPT51W9LW1xOUDC0B+NEw62CnvT1P0CukIii7/fR7Mq9lF+AIXY3f2nOMsxhq0A1IgGibvPI5OBkdnEUzBLFxJShdZJ9UkNRv/2I9qw0TwH9lmxH41rUYM/uAVUMfIaC+vRhLk2gYQ9KLOOdYvLKhjXyOMi7+ieg1nvjLK2vba8lpXikXCHGIS2jR8hI6GpDOSLIIwp9vDuQ1k7CENBpVchJj179ZetKy2mazf1KgO3cG+xR1jNP9+ybMaAJhsKLi2kJhJ01TKNjSshAhU6p1QfncCXli9A5uX8SmqylMI3JDg== 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 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=jkgOKrmaMstEpE+ziDAs7GJ5TS/udvSi02W1RmG3/wA=; b=ULBFPpxVinO4eMAmX6DK1fiqg1VUFbsO4Ba0aONiq+ADvRxkCBByQW8BXvoLV/aNSVDWas0EJeXcS1IyYOwyMkO0vpmOsHmT9lGVpN+VJVrZxG7UHL9XdwcVYZVapkGjXznJxfmEp9ssw3zdCj8BuJVSSQZ2OAJsgG7CIoESBuc= Received: from MN2PR03CA0001.namprd03.prod.outlook.com (2603:10b6:208:23a::6) by MN2PR12MB4565.namprd12.prod.outlook.com (2603:10b6:208:26b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.26; Thu, 19 Oct 2023 21:22:54 +0000 Received: from BL02EPF0001A105.namprd05.prod.outlook.com (2603:10b6:208:23a:cafe::8e) by MN2PR03CA0001.outlook.office365.com (2603:10b6:208:23a::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.23 via Frontend Transport; Thu, 19 Oct 2023 21:22: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 BL02EPF0001A105.mail.protection.outlook.com (10.167.241.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6907.21 via Frontend Transport; Thu, 19 Oct 2023 21:22:53 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 19 Oct 2023 16:22:48 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 19 Oct 2023 16:22:47 -0500 Received: from hwentlanrmb.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Thu, 19 Oct 2023 16:22:46 -0500 From: Harry Wentland To: Subject: [RFC PATCH v2 16/17] drm/vkms: Add enumerated 1D curve colorop Date: Thu, 19 Oct 2023 17:21:32 -0400 Message-ID: <20231019212133.245155-17-harry.wentland@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231019212133.245155-1-harry.wentland@amd.com> References: <20231019212133.245155-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A105:EE_|MN2PR12MB4565:EE_ X-MS-Office365-Filtering-Correlation-Id: d9b6f623-8ed9-405c-49d7-08dbd0e98e95 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RxcmQClvU6cissTWK71DFljo87it8LxpkBLcnGoy3uSLadbMwhkJnhlTl3SPxfBM0lFuLRPd4zHI95qSjIVIvK9zP/pOHm9a/NkOjZWTLLlvxlxS7pt/QHI4uxpWeQL7p6edQgHH/1vDoF405iBXr0GLR19eNvppxAClnKL3pYGu0oBEqDhfm4mGEUIYLT/0P2IxdiZsd9j846V5cJ1XNUyNbO6JyeCDKZ/WTjZKv0LNXqCeqjfDizHy61fzbkb/XDXo0ZdNCkw/hmaopuK2z4JF+c6B/AKxRT0vQCFX3bJGBR8aw8WQIcdW18WwWMS1VencDGjcjqwfuWOLWfQC8gDtXKH/j223pBsfnuE9AM/FxQdbTCt/vQ86yMafzyk1d5poIWQVRUmSdua84/k4+EZp0buVGU8uWOjCL9VV2WxTZ94LJ7ehsyc92m51mityFWSD2eJrfPwdU2IlZVnJ1kznjt172sUM0dDRiN3oTCrWN0B2O0k0JM368YVVlhoEhrmCaJq0CsOQ4A5l1s8TTqvHgAnIluCBaqxrVmAZ94huhnf0xyqSnuOOUMgZqraRSdtqoD9k1xXeFGst8jsvb8HFriOO871eHv/weU6dLA3BCvP58AsYn0w+hGGL91fHfsWWreLw4Dk9TVTSqwSmyNP2mTnaOV2SrYNHR1WsXo927yp4/Ekwfe3DNRoQChV+IZz7uaxXAH+QZ7Zjioknss6RH9G0kj6HfK6SAzOdGSbU7Ry7pj0h9aHSzEiFZBC5ote1xZS+bV9F3wjOUxtkbw== 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:(13230031)(4636009)(396003)(346002)(136003)(376002)(39860400002)(230922051799003)(451199024)(1800799009)(82310400011)(64100799003)(186009)(36840700001)(46966006)(40470700004)(40480700001)(40460700003)(41300700001)(2616005)(26005)(426003)(36756003)(1076003)(2906002)(7416002)(30864003)(86362001)(66574015)(4326008)(8936002)(8676002)(336012)(36860700001)(82740400003)(356005)(81166007)(83380400001)(47076005)(7696005)(6666004)(44832011)(5660300002)(6916009)(316002)(478600001)(70206006)(70586007)(54906003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2023 21:22:53.9756 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d9b6f623-8ed9-405c-49d7-08dbd0e98e95 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: BL02EPF0001A105.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4565 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: , Cc: Sasha McIntosh , Liviu Dudau , Victoria Brekenfeld , =?utf-8?q?Michel_D=C3=A4nzer?= , Arthur Grillo , Sebastian Wick , Shashank Sharma , wayland-devel@lists.freedesktop.org, =?utf-8?q?Jonas_=C3=85dahl?= , Uma Shankar , Abhinav Kumar , Naseer Ahmed , Melissa Wen , Aleix Pol , Christopher Braga , Pekka Paalanen , Hector Martin , Xaver Hugl , Joshua Ashton Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This patch introduces a VKMS color pipeline that includes two drm_colorops for named transfer functions. For now the only ones supported are sRGB EOTF, sRGB Inverse EOTF, and a Linear TF. We will expand this in the future but I don't want to do so without accompanying IGT tests. We introduce a new vkms_luts.c file that hard-codes sRGB EOTF, sRGB Inverse EOTF, and a linear EOTF LUT. These have been generated with 256 entries each as IGT is currently testing only 8 bpc surfaces. We will likely need higher precision but I'm reluctant to make that change without clear indication that we need it. We'll revisit and, if necessary, regenerate the LUTs when we have IGT tests for higher precision buffers. v2: - Add commit description - Fix sRGB EOTF LUT definition - Add linear and sRGB inverse EOTF LUTs Signed-off-by: Harry Wentland Cc: Ville Syrjala Cc: Pekka Paalanen Cc: Simon Ser Cc: Harry Wentland Cc: Melissa Wen Cc: Jonas Ådahl Cc: Sebastian Wick Cc: Shashank Sharma Cc: Alexander Goins Cc: Joshua Ashton Cc: Michel Dänzer Cc: Aleix Pol Cc: Xaver Hugl Cc: Victoria Brekenfeld Cc: Sima Cc: Uma Shankar Cc: Naseer Ahmed Cc: Christopher Braga Cc: Abhinav Kumar Cc: Arthur Grillo Cc: Hector Martin Cc: Liviu Dudau Cc: Sasha McIntosh --- drivers/gpu/drm/vkms/Makefile | 4 +- drivers/gpu/drm/vkms/vkms_colorop.c | 85 +++ drivers/gpu/drm/vkms/vkms_composer.c | 46 ++ drivers/gpu/drm/vkms/vkms_drv.h | 4 + drivers/gpu/drm/vkms/vkms_luts.c | 802 +++++++++++++++++++++++++++ drivers/gpu/drm/vkms/vkms_luts.h | 12 + drivers/gpu/drm/vkms/vkms_plane.c | 2 + 7 files changed, 954 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 d3440f228f46..eb208f3e6780 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 diff --git a/drivers/gpu/drm/vkms/vkms_colorop.c b/drivers/gpu/drm/vkms/vkms_colorop.c new file mode 100644 index 000000000000..9a26b9fdc4a2 --- /dev/null +++ b/drivers/gpu/drm/vkms/vkms_colorop.c @@ -0,0 +1,85 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#include +#include +#include +#include +#include + +#define MAX_COLOR_PIPELINES 5 + +const int vkms_initialize_tf_pipeline(struct drm_plane *plane, struct drm_prop_enum_list *list) +{ + + struct drm_colorop *op, *prev_op; + struct drm_device *dev = plane->dev; + int ret; + + /* 1st op: 1d curve */ + op = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL); + if (!op) { + DRM_ERROR("KMS: Failed to allocate colorop\n"); + return -ENOMEM; + } + + ret = drm_colorop_init(dev, op, plane, DRM_COLOROP_1D_CURVE); + if (ret) + return ret; + + list->type = op->base.id; + list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", op->base.id); + + prev_op = op; + + /* 2nd op: 1d curve */ + op = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL); + if (!op) { + DRM_ERROR("KMS: Failed to allocate colorop\n"); + return -ENOMEM; + } + + ret = drm_colorop_init(dev, op, plane, DRM_COLOROP_1D_CURVE); + if (ret) + return ret; + + drm_colorop_set_next_property(prev_op, op); + + return 0; +} + +int vkms_initialize_colorops(struct drm_plane *plane) +{ + struct drm_device *dev = plane->dev; + struct drm_property *prop; + struct drm_prop_enum_list pipelines[MAX_COLOR_PIPELINES]; + int len = 0; + int ret; + + /* Add "Bypass" (i.e. NULL) pipeline */ + pipelines[len].type = 0; + pipelines[len].name = "Bypass"; + len++; + + /* Add pipeline consisting of transfer functions */ + ret = vkms_initialize_tf_pipeline(plane, &(pipelines[len])); + if (ret) + return ret; + len++; + + /* Create COLOR_PIPELINE property and attach */ + prop = drm_property_create_enum(dev, DRM_MODE_PROP_ATOMIC, + "COLOR_PIPELINE", + pipelines, len); + if (!prop) + return -ENOMEM; + + plane->color_pipeline_property = prop; + + drm_object_attach_property(&plane->base, prop, 0); + + /* TODO do we even need this? */ + if (plane->state) + plane->state->color_pipeline = NULL; + + return 0; +} diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index cf1dff162920..73b7d5e94021 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 "vkms_composer.h" +#include "vkms_luts.h" static u16 pre_mul_blend_channel(u16 src, u16 dst, u16 alpha) { @@ -163,6 +165,47 @@ static void apply_lut(const struct vkms_crtc_state *crtc_state, struct line_buff } } +static void pre_blend_color_transform(const struct vkms_plane_state *plane_state, struct line_buffer *output_buffer) +{ + struct drm_colorop *colorop = plane_state->base.base.color_pipeline; + + while (colorop) { + struct drm_colorop_state *colorop_state; + + if (!colorop) + return; + + /* TODO this is probably wrong */ + colorop_state = colorop->state; + + if (!colorop_state) + return; + + for (size_t x = 0; x < output_buffer->n_pixels; x++) { + struct pixel_argb_u16 *pixel = &output_buffer->pixels[x]; + + if (colorop->type == DRM_COLOROP_1D_CURVE && + colorop_state->bypass == false) { + 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: + default: + 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; + } + } + } + + colorop = drm_colorop_get_next(colorop); + } +} + /** * blend - blend the pixels from all planes and compute crc * @wb: The writeback frame buffer metadata @@ -200,6 +243,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 8f5710debb1e..2bcc24c196a2 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -170,4 +170,8 @@ void vkms_writeback_row(struct vkms_writeback_job *wb, const struct line_buffer /* Writeback */ int vkms_enable_writeback_connector(struct vkms_device *vkmsdev); +/* Colorops */ +int vkms_initialize_colorops(struct drm_plane *plane); + + #endif /* _VKMS_DRV_H_ */ diff --git a/drivers/gpu/drm/vkms/vkms_luts.c b/drivers/gpu/drm/vkms/vkms_luts.c new file mode 100644 index 000000000000..6553d6d442b4 --- /dev/null +++ b/drivers/gpu/drm/vkms/vkms_luts.c @@ -0,0 +1,802 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#include + +#include "vkms_drv.h" +#include "vkms_luts.h" + +static struct drm_color_lut linear_array[LUT_SIZE] = { + { 0x0, 0x0, 0x0, 0 }, + { 0x101, 0x101, 0x101, 0 }, + { 0x202, 0x202, 0x202, 0 }, + { 0x303, 0x303, 0x303, 0 }, + { 0x404, 0x404, 0x404, 0 }, + { 0x505, 0x505, 0x505, 0 }, + { 0x606, 0x606, 0x606, 0 }, + { 0x707, 0x707, 0x707, 0 }, + { 0x808, 0x808, 0x808, 0 }, + { 0x909, 0x909, 0x909, 0 }, + { 0xa0a, 0xa0a, 0xa0a, 0 }, + { 0xb0b, 0xb0b, 0xb0b, 0 }, + { 0xc0c, 0xc0c, 0xc0c, 0 }, + { 0xd0d, 0xd0d, 0xd0d, 0 }, + { 0xe0e, 0xe0e, 0xe0e, 0 }, + { 0xf0f, 0xf0f, 0xf0f, 0 }, + { 0x1010, 0x1010, 0x1010, 0 }, + { 0x1111, 0x1111, 0x1111, 0 }, + { 0x1212, 0x1212, 0x1212, 0 }, + { 0x1313, 0x1313, 0x1313, 0 }, + { 0x1414, 0x1414, 0x1414, 0 }, + { 0x1515, 0x1515, 0x1515, 0 }, + { 0x1616, 0x1616, 0x1616, 0 }, + { 0x1717, 0x1717, 0x1717, 0 }, + { 0x1818, 0x1818, 0x1818, 0 }, + { 0x1919, 0x1919, 0x1919, 0 }, + { 0x1a1a, 0x1a1a, 0x1a1a, 0 }, + { 0x1b1b, 0x1b1b, 0x1b1b, 0 }, + { 0x1c1c, 0x1c1c, 0x1c1c, 0 }, + { 0x1d1d, 0x1d1d, 0x1d1d, 0 }, + { 0x1e1e, 0x1e1e, 0x1e1e, 0 }, + { 0x1f1f, 0x1f1f, 0x1f1f, 0 }, + { 0x2020, 0x2020, 0x2020, 0 }, + { 0x2121, 0x2121, 0x2121, 0 }, + { 0x2222, 0x2222, 0x2222, 0 }, + { 0x2323, 0x2323, 0x2323, 0 }, + { 0x2424, 0x2424, 0x2424, 0 }, + { 0x2525, 0x2525, 0x2525, 0 }, + { 0x2626, 0x2626, 0x2626, 0 }, + { 0x2727, 0x2727, 0x2727, 0 }, + { 0x2828, 0x2828, 0x2828, 0 }, + { 0x2929, 0x2929, 0x2929, 0 }, + { 0x2a2a, 0x2a2a, 0x2a2a, 0 }, + { 0x2b2b, 0x2b2b, 0x2b2b, 0 }, + { 0x2c2c, 0x2c2c, 0x2c2c, 0 }, + { 0x2d2d, 0x2d2d, 0x2d2d, 0 }, + { 0x2e2e, 0x2e2e, 0x2e2e, 0 }, + { 0x2f2f, 0x2f2f, 0x2f2f, 0 }, + { 0x3030, 0x3030, 0x3030, 0 }, + { 0x3131, 0x3131, 0x3131, 0 }, + { 0x3232, 0x3232, 0x3232, 0 }, + { 0x3333, 0x3333, 0x3333, 0 }, + { 0x3434, 0x3434, 0x3434, 0 }, + { 0x3535, 0x3535, 0x3535, 0 }, + { 0x3636, 0x3636, 0x3636, 0 }, + { 0x3737, 0x3737, 0x3737, 0 }, + { 0x3838, 0x3838, 0x3838, 0 }, + { 0x3939, 0x3939, 0x3939, 0 }, + { 0x3a3a, 0x3a3a, 0x3a3a, 0 }, + { 0x3b3b, 0x3b3b, 0x3b3b, 0 }, + { 0x3c3c, 0x3c3c, 0x3c3c, 0 }, + { 0x3d3d, 0x3d3d, 0x3d3d, 0 }, + { 0x3e3e, 0x3e3e, 0x3e3e, 0 }, + { 0x3f3f, 0x3f3f, 0x3f3f, 0 }, + { 0x4040, 0x4040, 0x4040, 0 }, + { 0x4141, 0x4141, 0x4141, 0 }, + { 0x4242, 0x4242, 0x4242, 0 }, + { 0x4343, 0x4343, 0x4343, 0 }, + { 0x4444, 0x4444, 0x4444, 0 }, + { 0x4545, 0x4545, 0x4545, 0 }, + { 0x4646, 0x4646, 0x4646, 0 }, + { 0x4747, 0x4747, 0x4747, 0 }, + { 0x4848, 0x4848, 0x4848, 0 }, + { 0x4949, 0x4949, 0x4949, 0 }, + { 0x4a4a, 0x4a4a, 0x4a4a, 0 }, + { 0x4b4b, 0x4b4b, 0x4b4b, 0 }, + { 0x4c4c, 0x4c4c, 0x4c4c, 0 }, + { 0x4d4d, 0x4d4d, 0x4d4d, 0 }, + { 0x4e4e, 0x4e4e, 0x4e4e, 0 }, + { 0x4f4f, 0x4f4f, 0x4f4f, 0 }, + { 0x5050, 0x5050, 0x5050, 0 }, + { 0x5151, 0x5151, 0x5151, 0 }, + { 0x5252, 0x5252, 0x5252, 0 }, + { 0x5353, 0x5353, 0x5353, 0 }, + { 0x5454, 0x5454, 0x5454, 0 }, + { 0x5555, 0x5555, 0x5555, 0 }, + { 0x5656, 0x5656, 0x5656, 0 }, + { 0x5757, 0x5757, 0x5757, 0 }, + { 0x5858, 0x5858, 0x5858, 0 }, + { 0x5959, 0x5959, 0x5959, 0 }, + { 0x5a5a, 0x5a5a, 0x5a5a, 0 }, + { 0x5b5b, 0x5b5b, 0x5b5b, 0 }, + { 0x5c5c, 0x5c5c, 0x5c5c, 0 }, + { 0x5d5d, 0x5d5d, 0x5d5d, 0 }, + { 0x5e5e, 0x5e5e, 0x5e5e, 0 }, + { 0x5f5f, 0x5f5f, 0x5f5f, 0 }, + { 0x6060, 0x6060, 0x6060, 0 }, + { 0x6161, 0x6161, 0x6161, 0 }, + { 0x6262, 0x6262, 0x6262, 0 }, + { 0x6363, 0x6363, 0x6363, 0 }, + { 0x6464, 0x6464, 0x6464, 0 }, + { 0x6565, 0x6565, 0x6565, 0 }, + { 0x6666, 0x6666, 0x6666, 0 }, + { 0x6767, 0x6767, 0x6767, 0 }, + { 0x6868, 0x6868, 0x6868, 0 }, + { 0x6969, 0x6969, 0x6969, 0 }, + { 0x6a6a, 0x6a6a, 0x6a6a, 0 }, + { 0x6b6b, 0x6b6b, 0x6b6b, 0 }, + { 0x6c6c, 0x6c6c, 0x6c6c, 0 }, + { 0x6d6d, 0x6d6d, 0x6d6d, 0 }, + { 0x6e6e, 0x6e6e, 0x6e6e, 0 }, + { 0x6f6f, 0x6f6f, 0x6f6f, 0 }, + { 0x7070, 0x7070, 0x7070, 0 }, + { 0x7171, 0x7171, 0x7171, 0 }, + { 0x7272, 0x7272, 0x7272, 0 }, + { 0x7373, 0x7373, 0x7373, 0 }, + { 0x7474, 0x7474, 0x7474, 0 }, + { 0x7575, 0x7575, 0x7575, 0 }, + { 0x7676, 0x7676, 0x7676, 0 }, + { 0x7777, 0x7777, 0x7777, 0 }, + { 0x7878, 0x7878, 0x7878, 0 }, + { 0x7979, 0x7979, 0x7979, 0 }, + { 0x7a7a, 0x7a7a, 0x7a7a, 0 }, + { 0x7b7b, 0x7b7b, 0x7b7b, 0 }, + { 0x7c7c, 0x7c7c, 0x7c7c, 0 }, + { 0x7d7d, 0x7d7d, 0x7d7d, 0 }, + { 0x7e7e, 0x7e7e, 0x7e7e, 0 }, + { 0x7f7f, 0x7f7f, 0x7f7f, 0 }, + { 0x8080, 0x8080, 0x8080, 0 }, + { 0x8181, 0x8181, 0x8181, 0 }, + { 0x8282, 0x8282, 0x8282, 0 }, + { 0x8383, 0x8383, 0x8383, 0 }, + { 0x8484, 0x8484, 0x8484, 0 }, + { 0x8585, 0x8585, 0x8585, 0 }, + { 0x8686, 0x8686, 0x8686, 0 }, + { 0x8787, 0x8787, 0x8787, 0 }, + { 0x8888, 0x8888, 0x8888, 0 }, + { 0x8989, 0x8989, 0x8989, 0 }, + { 0x8a8a, 0x8a8a, 0x8a8a, 0 }, + { 0x8b8b, 0x8b8b, 0x8b8b, 0 }, + { 0x8c8c, 0x8c8c, 0x8c8c, 0 }, + { 0x8d8d, 0x8d8d, 0x8d8d, 0 }, + { 0x8e8e, 0x8e8e, 0x8e8e, 0 }, + { 0x8f8f, 0x8f8f, 0x8f8f, 0 }, + { 0x9090, 0x9090, 0x9090, 0 }, + { 0x9191, 0x9191, 0x9191, 0 }, + { 0x9292, 0x9292, 0x9292, 0 }, + { 0x9393, 0x9393, 0x9393, 0 }, + { 0x9494, 0x9494, 0x9494, 0 }, + { 0x9595, 0x9595, 0x9595, 0 }, + { 0x9696, 0x9696, 0x9696, 0 }, + { 0x9797, 0x9797, 0x9797, 0 }, + { 0x9898, 0x9898, 0x9898, 0 }, + { 0x9999, 0x9999, 0x9999, 0 }, + { 0x9a9a, 0x9a9a, 0x9a9a, 0 }, + { 0x9b9b, 0x9b9b, 0x9b9b, 0 }, + { 0x9c9c, 0x9c9c, 0x9c9c, 0 }, + { 0x9d9d, 0x9d9d, 0x9d9d, 0 }, + { 0x9e9e, 0x9e9e, 0x9e9e, 0 }, + { 0x9f9f, 0x9f9f, 0x9f9f, 0 }, + { 0xa0a0, 0xa0a0, 0xa0a0, 0 }, + { 0xa1a1, 0xa1a1, 0xa1a1, 0 }, + { 0xa2a2, 0xa2a2, 0xa2a2, 0 }, + { 0xa3a3, 0xa3a3, 0xa3a3, 0 }, + { 0xa4a4, 0xa4a4, 0xa4a4, 0 }, + { 0xa5a5, 0xa5a5, 0xa5a5, 0 }, + { 0xa6a6, 0xa6a6, 0xa6a6, 0 }, + { 0xa7a7, 0xa7a7, 0xa7a7, 0 }, + { 0xa8a8, 0xa8a8, 0xa8a8, 0 }, + { 0xa9a9, 0xa9a9, 0xa9a9, 0 }, + { 0xaaaa, 0xaaaa, 0xaaaa, 0 }, + { 0xabab, 0xabab, 0xabab, 0 }, + { 0xacac, 0xacac, 0xacac, 0 }, + { 0xadad, 0xadad, 0xadad, 0 }, + { 0xaeae, 0xaeae, 0xaeae, 0 }, + { 0xafaf, 0xafaf, 0xafaf, 0 }, + { 0xb0b0, 0xb0b0, 0xb0b0, 0 }, + { 0xb1b1, 0xb1b1, 0xb1b1, 0 }, + { 0xb2b2, 0xb2b2, 0xb2b2, 0 }, + { 0xb3b3, 0xb3b3, 0xb3b3, 0 }, + { 0xb4b4, 0xb4b4, 0xb4b4, 0 }, + { 0xb5b5, 0xb5b5, 0xb5b5, 0 }, + { 0xb6b6, 0xb6b6, 0xb6b6, 0 }, + { 0xb7b7, 0xb7b7, 0xb7b7, 0 }, + { 0xb8b8, 0xb8b8, 0xb8b8, 0 }, + { 0xb9b9, 0xb9b9, 0xb9b9, 0 }, + { 0xbaba, 0xbaba, 0xbaba, 0 }, + { 0xbbbb, 0xbbbb, 0xbbbb, 0 }, + { 0xbcbc, 0xbcbc, 0xbcbc, 0 }, + { 0xbdbd, 0xbdbd, 0xbdbd, 0 }, + { 0xbebe, 0xbebe, 0xbebe, 0 }, + { 0xbfbf, 0xbfbf, 0xbfbf, 0 }, + { 0xc0c0, 0xc0c0, 0xc0c0, 0 }, + { 0xc1c1, 0xc1c1, 0xc1c1, 0 }, + { 0xc2c2, 0xc2c2, 0xc2c2, 0 }, + { 0xc3c3, 0xc3c3, 0xc3c3, 0 }, + { 0xc4c4, 0xc4c4, 0xc4c4, 0 }, + { 0xc5c5, 0xc5c5, 0xc5c5, 0 }, + { 0xc6c6, 0xc6c6, 0xc6c6, 0 }, + { 0xc7c7, 0xc7c7, 0xc7c7, 0 }, + { 0xc8c8, 0xc8c8, 0xc8c8, 0 }, + { 0xc9c9, 0xc9c9, 0xc9c9, 0 }, + { 0xcaca, 0xcaca, 0xcaca, 0 }, + { 0xcbcb, 0xcbcb, 0xcbcb, 0 }, + { 0xcccc, 0xcccc, 0xcccc, 0 }, + { 0xcdcd, 0xcdcd, 0xcdcd, 0 }, + { 0xcece, 0xcece, 0xcece, 0 }, + { 0xcfcf, 0xcfcf, 0xcfcf, 0 }, + { 0xd0d0, 0xd0d0, 0xd0d0, 0 }, + { 0xd1d1, 0xd1d1, 0xd1d1, 0 }, + { 0xd2d2, 0xd2d2, 0xd2d2, 0 }, + { 0xd3d3, 0xd3d3, 0xd3d3, 0 }, + { 0xd4d4, 0xd4d4, 0xd4d4, 0 }, + { 0xd5d5, 0xd5d5, 0xd5d5, 0 }, + { 0xd6d6, 0xd6d6, 0xd6d6, 0 }, + { 0xd7d7, 0xd7d7, 0xd7d7, 0 }, + { 0xd8d8, 0xd8d8, 0xd8d8, 0 }, + { 0xd9d9, 0xd9d9, 0xd9d9, 0 }, + { 0xdada, 0xdada, 0xdada, 0 }, + { 0xdbdb, 0xdbdb, 0xdbdb, 0 }, + { 0xdcdc, 0xdcdc, 0xdcdc, 0 }, + { 0xdddd, 0xdddd, 0xdddd, 0 }, + { 0xdede, 0xdede, 0xdede, 0 }, + { 0xdfdf, 0xdfdf, 0xdfdf, 0 }, + { 0xe0e0, 0xe0e0, 0xe0e0, 0 }, + { 0xe1e1, 0xe1e1, 0xe1e1, 0 }, + { 0xe2e2, 0xe2e2, 0xe2e2, 0 }, + { 0xe3e3, 0xe3e3, 0xe3e3, 0 }, + { 0xe4e4, 0xe4e4, 0xe4e4, 0 }, + { 0xe5e5, 0xe5e5, 0xe5e5, 0 }, + { 0xe6e6, 0xe6e6, 0xe6e6, 0 }, + { 0xe7e7, 0xe7e7, 0xe7e7, 0 }, + { 0xe8e8, 0xe8e8, 0xe8e8, 0 }, + { 0xe9e9, 0xe9e9, 0xe9e9, 0 }, + { 0xeaea, 0xeaea, 0xeaea, 0 }, + { 0xebeb, 0xebeb, 0xebeb, 0 }, + { 0xecec, 0xecec, 0xecec, 0 }, + { 0xeded, 0xeded, 0xeded, 0 }, + { 0xeeee, 0xeeee, 0xeeee, 0 }, + { 0xefef, 0xefef, 0xefef, 0 }, + { 0xf0f0, 0xf0f0, 0xf0f0, 0 }, + { 0xf1f1, 0xf1f1, 0xf1f1, 0 }, + { 0xf2f2, 0xf2f2, 0xf2f2, 0 }, + { 0xf3f3, 0xf3f3, 0xf3f3, 0 }, + { 0xf4f4, 0xf4f4, 0xf4f4, 0 }, + { 0xf5f5, 0xf5f5, 0xf5f5, 0 }, + { 0xf6f6, 0xf6f6, 0xf6f6, 0 }, + { 0xf7f7, 0xf7f7, 0xf7f7, 0 }, + { 0xf8f8, 0xf8f8, 0xf8f8, 0 }, + { 0xf9f9, 0xf9f9, 0xf9f9, 0 }, + { 0xfafa, 0xfafa, 0xfafa, 0 }, + { 0xfbfb, 0xfbfb, 0xfbfb, 0 }, + { 0xfcfc, 0xfcfc, 0xfcfc, 0 }, + { 0xfdfd, 0xfdfd, 0xfdfd, 0 }, + { 0xfefe, 0xfefe, 0xfefe, 0 }, + { 0xffff, 0xffff, 0xffff, 0 }, +}; + +const struct vkms_color_lut linear_eotf = { + .base = linear_array, + .lut_length = LUT_SIZE, + .channel_value2index_ratio = 0xff00ffll +}; + + +static struct drm_color_lut srgb_array[LUT_SIZE] = { + { 0x0, 0x0, 0x0, 0 }, + { 0x13, 0x13, 0x13, 0 }, + { 0x27, 0x27, 0x27, 0 }, + { 0x3b, 0x3b, 0x3b, 0 }, + { 0x4f, 0x4f, 0x4f, 0 }, + { 0x63, 0x63, 0x63, 0 }, + { 0x77, 0x77, 0x77, 0 }, + { 0x8b, 0x8b, 0x8b, 0 }, + { 0x9f, 0x9f, 0x9f, 0 }, + { 0xb3, 0xb3, 0xb3, 0 }, + { 0xc6, 0xc6, 0xc6, 0 }, + { 0xdb, 0xdb, 0xdb, 0 }, + { 0xf0, 0xf0, 0xf0, 0 }, + { 0x107, 0x107, 0x107, 0 }, + { 0x11f, 0x11f, 0x11f, 0 }, + { 0x139, 0x139, 0x139, 0 }, + { 0x153, 0x153, 0x153, 0 }, + { 0x16f, 0x16f, 0x16f, 0 }, + { 0x18c, 0x18c, 0x18c, 0 }, + { 0x1aa, 0x1aa, 0x1aa, 0 }, + { 0x1ca, 0x1ca, 0x1ca, 0 }, + { 0x1eb, 0x1eb, 0x1eb, 0 }, + { 0x20d, 0x20d, 0x20d, 0 }, + { 0x231, 0x231, 0x231, 0 }, + { 0x256, 0x256, 0x256, 0 }, + { 0x27d, 0x27d, 0x27d, 0 }, + { 0x2a4, 0x2a4, 0x2a4, 0 }, + { 0x2ce, 0x2ce, 0x2ce, 0 }, + { 0x2f9, 0x2f9, 0x2f9, 0 }, + { 0x325, 0x325, 0x325, 0 }, + { 0x352, 0x352, 0x352, 0 }, + { 0x381, 0x381, 0x381, 0 }, + { 0x3b2, 0x3b2, 0x3b2, 0 }, + { 0x3e4, 0x3e4, 0x3e4, 0 }, + { 0x418, 0x418, 0x418, 0 }, + { 0x44d, 0x44d, 0x44d, 0 }, + { 0x484, 0x484, 0x484, 0 }, + { 0x4bc, 0x4bc, 0x4bc, 0 }, + { 0x4f6, 0x4f6, 0x4f6, 0 }, + { 0x531, 0x531, 0x531, 0 }, + { 0x56e, 0x56e, 0x56e, 0 }, + { 0x5ad, 0x5ad, 0x5ad, 0 }, + { 0x5ed, 0x5ed, 0x5ed, 0 }, + { 0x62f, 0x62f, 0x62f, 0 }, + { 0x672, 0x672, 0x672, 0 }, + { 0x6b7, 0x6b7, 0x6b7, 0 }, + { 0x6fe, 0x6fe, 0x6fe, 0 }, + { 0x746, 0x746, 0x746, 0 }, + { 0x791, 0x791, 0x791, 0 }, + { 0x7dc, 0x7dc, 0x7dc, 0 }, + { 0x82a, 0x82a, 0x82a, 0 }, + { 0x879, 0x879, 0x879, 0 }, + { 0x8ca, 0x8ca, 0x8ca, 0 }, + { 0x91d, 0x91d, 0x91d, 0 }, + { 0x971, 0x971, 0x971, 0 }, + { 0x9c7, 0x9c7, 0x9c7, 0 }, + { 0xa1f, 0xa1f, 0xa1f, 0 }, + { 0xa79, 0xa79, 0xa79, 0 }, + { 0xad4, 0xad4, 0xad4, 0 }, + { 0xb32, 0xb32, 0xb32, 0 }, + { 0xb91, 0xb91, 0xb91, 0 }, + { 0xbf2, 0xbf2, 0xbf2, 0 }, + { 0xc54, 0xc54, 0xc54, 0 }, + { 0xcb9, 0xcb9, 0xcb9, 0 }, + { 0xd1f, 0xd1f, 0xd1f, 0 }, + { 0xd88, 0xd88, 0xd88, 0 }, + { 0xdf2, 0xdf2, 0xdf2, 0 }, + { 0xe5e, 0xe5e, 0xe5e, 0 }, + { 0xecc, 0xecc, 0xecc, 0 }, + { 0xf3c, 0xf3c, 0xf3c, 0 }, + { 0xfad, 0xfad, 0xfad, 0 }, + { 0x1021, 0x1021, 0x1021, 0 }, + { 0x1096, 0x1096, 0x1096, 0 }, + { 0x110e, 0x110e, 0x110e, 0 }, + { 0x1187, 0x1187, 0x1187, 0 }, + { 0x1203, 0x1203, 0x1203, 0 }, + { 0x1280, 0x1280, 0x1280, 0 }, + { 0x12ff, 0x12ff, 0x12ff, 0 }, + { 0x1380, 0x1380, 0x1380, 0 }, + { 0x1404, 0x1404, 0x1404, 0 }, + { 0x1489, 0x1489, 0x1489, 0 }, + { 0x1510, 0x1510, 0x1510, 0 }, + { 0x1599, 0x1599, 0x1599, 0 }, + { 0x1624, 0x1624, 0x1624, 0 }, + { 0x16b2, 0x16b2, 0x16b2, 0 }, + { 0x1741, 0x1741, 0x1741, 0 }, + { 0x17d2, 0x17d2, 0x17d2, 0 }, + { 0x1865, 0x1865, 0x1865, 0 }, + { 0x18fb, 0x18fb, 0x18fb, 0 }, + { 0x1992, 0x1992, 0x1992, 0 }, + { 0x1a2c, 0x1a2c, 0x1a2c, 0 }, + { 0x1ac8, 0x1ac8, 0x1ac8, 0 }, + { 0x1b65, 0x1b65, 0x1b65, 0 }, + { 0x1c05, 0x1c05, 0x1c05, 0 }, + { 0x1ca7, 0x1ca7, 0x1ca7, 0 }, + { 0x1d4b, 0x1d4b, 0x1d4b, 0 }, + { 0x1df1, 0x1df1, 0x1df1, 0 }, + { 0x1e99, 0x1e99, 0x1e99, 0 }, + { 0x1f44, 0x1f44, 0x1f44, 0 }, + { 0x1ff0, 0x1ff0, 0x1ff0, 0 }, + { 0x209f, 0x209f, 0x209f, 0 }, + { 0x2150, 0x2150, 0x2150, 0 }, + { 0x2203, 0x2203, 0x2203, 0 }, + { 0x22b8, 0x22b8, 0x22b8, 0 }, + { 0x2370, 0x2370, 0x2370, 0 }, + { 0x2429, 0x2429, 0x2429, 0 }, + { 0x24e5, 0x24e5, 0x24e5, 0 }, + { 0x25a3, 0x25a3, 0x25a3, 0 }, + { 0x2663, 0x2663, 0x2663, 0 }, + { 0x2726, 0x2726, 0x2726, 0 }, + { 0x27ea, 0x27ea, 0x27ea, 0 }, + { 0x28b1, 0x28b1, 0x28b1, 0 }, + { 0x297a, 0x297a, 0x297a, 0 }, + { 0x2a45, 0x2a45, 0x2a45, 0 }, + { 0x2b13, 0x2b13, 0x2b13, 0 }, + { 0x2be3, 0x2be3, 0x2be3, 0 }, + { 0x2cb5, 0x2cb5, 0x2cb5, 0 }, + { 0x2d89, 0x2d89, 0x2d89, 0 }, + { 0x2e60, 0x2e60, 0x2e60, 0 }, + { 0x2f39, 0x2f39, 0x2f39, 0 }, + { 0x3014, 0x3014, 0x3014, 0 }, + { 0x30f2, 0x30f2, 0x30f2, 0 }, + { 0x31d2, 0x31d2, 0x31d2, 0 }, + { 0x32b4, 0x32b4, 0x32b4, 0 }, + { 0x3398, 0x3398, 0x3398, 0 }, + { 0x347f, 0x347f, 0x347f, 0 }, + { 0x3569, 0x3569, 0x3569, 0 }, + { 0x3654, 0x3654, 0x3654, 0 }, + { 0x3742, 0x3742, 0x3742, 0 }, + { 0x3832, 0x3832, 0x3832, 0 }, + { 0x3925, 0x3925, 0x3925, 0 }, + { 0x3a1a, 0x3a1a, 0x3a1a, 0 }, + { 0x3b11, 0x3b11, 0x3b11, 0 }, + { 0x3c0b, 0x3c0b, 0x3c0b, 0 }, + { 0x3d07, 0x3d07, 0x3d07, 0 }, + { 0x3e05, 0x3e05, 0x3e05, 0 }, + { 0x3f06, 0x3f06, 0x3f06, 0 }, + { 0x400a, 0x400a, 0x400a, 0 }, + { 0x410f, 0x410f, 0x410f, 0 }, + { 0x4218, 0x4218, 0x4218, 0 }, + { 0x4322, 0x4322, 0x4322, 0 }, + { 0x442f, 0x442f, 0x442f, 0 }, + { 0x453f, 0x453f, 0x453f, 0 }, + { 0x4650, 0x4650, 0x4650, 0 }, + { 0x4765, 0x4765, 0x4765, 0 }, + { 0x487c, 0x487c, 0x487c, 0 }, + { 0x4995, 0x4995, 0x4995, 0 }, + { 0x4ab1, 0x4ab1, 0x4ab1, 0 }, + { 0x4bcf, 0x4bcf, 0x4bcf, 0 }, + { 0x4cf0, 0x4cf0, 0x4cf0, 0 }, + { 0x4e13, 0x4e13, 0x4e13, 0 }, + { 0x4f39, 0x4f39, 0x4f39, 0 }, + { 0x5061, 0x5061, 0x5061, 0 }, + { 0x518b, 0x518b, 0x518b, 0 }, + { 0x52b9, 0x52b9, 0x52b9, 0 }, + { 0x53e8, 0x53e8, 0x53e8, 0 }, + { 0x551b, 0x551b, 0x551b, 0 }, + { 0x5650, 0x5650, 0x5650, 0 }, + { 0x5787, 0x5787, 0x5787, 0 }, + { 0x58c1, 0x58c1, 0x58c1, 0 }, + { 0x59fd, 0x59fd, 0x59fd, 0 }, + { 0x5b3c, 0x5b3c, 0x5b3c, 0 }, + { 0x5c7e, 0x5c7e, 0x5c7e, 0 }, + { 0x5dc2, 0x5dc2, 0x5dc2, 0 }, + { 0x5f09, 0x5f09, 0x5f09, 0 }, + { 0x6052, 0x6052, 0x6052, 0 }, + { 0x619e, 0x619e, 0x619e, 0 }, + { 0x62ec, 0x62ec, 0x62ec, 0 }, + { 0x643d, 0x643d, 0x643d, 0 }, + { 0x6591, 0x6591, 0x6591, 0 }, + { 0x66e7, 0x66e7, 0x66e7, 0 }, + { 0x6840, 0x6840, 0x6840, 0 }, + { 0x699b, 0x699b, 0x699b, 0 }, + { 0x6afa, 0x6afa, 0x6afa, 0 }, + { 0x6c5a, 0x6c5a, 0x6c5a, 0 }, + { 0x6dbe, 0x6dbe, 0x6dbe, 0 }, + { 0x6f24, 0x6f24, 0x6f24, 0 }, + { 0x708c, 0x708c, 0x708c, 0 }, + { 0x71f8, 0x71f8, 0x71f8, 0 }, + { 0x7366, 0x7366, 0x7366, 0 }, + { 0x74d6, 0x74d6, 0x74d6, 0 }, + { 0x764a, 0x764a, 0x764a, 0 }, + { 0x77c0, 0x77c0, 0x77c0, 0 }, + { 0x7938, 0x7938, 0x7938, 0 }, + { 0x7ab4, 0x7ab4, 0x7ab4, 0 }, + { 0x7c32, 0x7c32, 0x7c32, 0 }, + { 0x7db3, 0x7db3, 0x7db3, 0 }, + { 0x7f36, 0x7f36, 0x7f36, 0 }, + { 0x80bc, 0x80bc, 0x80bc, 0 }, + { 0x8245, 0x8245, 0x8245, 0 }, + { 0x83d1, 0x83d1, 0x83d1, 0 }, + { 0x855f, 0x855f, 0x855f, 0 }, + { 0x86f0, 0x86f0, 0x86f0, 0 }, + { 0x8884, 0x8884, 0x8884, 0 }, + { 0x8a1a, 0x8a1a, 0x8a1a, 0 }, + { 0x8bb4, 0x8bb4, 0x8bb4, 0 }, + { 0x8d50, 0x8d50, 0x8d50, 0 }, + { 0x8eee, 0x8eee, 0x8eee, 0 }, + { 0x9090, 0x9090, 0x9090, 0 }, + { 0x9234, 0x9234, 0x9234, 0 }, + { 0x93db, 0x93db, 0x93db, 0 }, + { 0x9585, 0x9585, 0x9585, 0 }, + { 0x9732, 0x9732, 0x9732, 0 }, + { 0x98e1, 0x98e1, 0x98e1, 0 }, + { 0x9a93, 0x9a93, 0x9a93, 0 }, + { 0x9c48, 0x9c48, 0x9c48, 0 }, + { 0x9e00, 0x9e00, 0x9e00, 0 }, + { 0x9fbb, 0x9fbb, 0x9fbb, 0 }, + { 0xa178, 0xa178, 0xa178, 0 }, + { 0xa338, 0xa338, 0xa338, 0 }, + { 0xa4fb, 0xa4fb, 0xa4fb, 0 }, + { 0xa6c1, 0xa6c1, 0xa6c1, 0 }, + { 0xa88a, 0xa88a, 0xa88a, 0 }, + { 0xaa56, 0xaa56, 0xaa56, 0 }, + { 0xac24, 0xac24, 0xac24, 0 }, + { 0xadf5, 0xadf5, 0xadf5, 0 }, + { 0xafc9, 0xafc9, 0xafc9, 0 }, + { 0xb1a0, 0xb1a0, 0xb1a0, 0 }, + { 0xb37a, 0xb37a, 0xb37a, 0 }, + { 0xb557, 0xb557, 0xb557, 0 }, + { 0xb736, 0xb736, 0xb736, 0 }, + { 0xb919, 0xb919, 0xb919, 0 }, + { 0xbafe, 0xbafe, 0xbafe, 0 }, + { 0xbce6, 0xbce6, 0xbce6, 0 }, + { 0xbed2, 0xbed2, 0xbed2, 0 }, + { 0xc0c0, 0xc0c0, 0xc0c0, 0 }, + { 0xc2b0, 0xc2b0, 0xc2b0, 0 }, + { 0xc4a4, 0xc4a4, 0xc4a4, 0 }, + { 0xc69b, 0xc69b, 0xc69b, 0 }, + { 0xc895, 0xc895, 0xc895, 0 }, + { 0xca91, 0xca91, 0xca91, 0 }, + { 0xcc91, 0xcc91, 0xcc91, 0 }, + { 0xce93, 0xce93, 0xce93, 0 }, + { 0xd098, 0xd098, 0xd098, 0 }, + { 0xd2a1, 0xd2a1, 0xd2a1, 0 }, + { 0xd4ac, 0xd4ac, 0xd4ac, 0 }, + { 0xd6ba, 0xd6ba, 0xd6ba, 0 }, + { 0xd8cb, 0xd8cb, 0xd8cb, 0 }, + { 0xdadf, 0xdadf, 0xdadf, 0 }, + { 0xdcf7, 0xdcf7, 0xdcf7, 0 }, + { 0xdf11, 0xdf11, 0xdf11, 0 }, + { 0xe12e, 0xe12e, 0xe12e, 0 }, + { 0xe34e, 0xe34e, 0xe34e, 0 }, + { 0xe571, 0xe571, 0xe571, 0 }, + { 0xe796, 0xe796, 0xe796, 0 }, + { 0xe9bf, 0xe9bf, 0xe9bf, 0 }, + { 0xebeb, 0xebeb, 0xebeb, 0 }, + { 0xee1a, 0xee1a, 0xee1a, 0 }, + { 0xf04c, 0xf04c, 0xf04c, 0 }, + { 0xf281, 0xf281, 0xf281, 0 }, + { 0xf4b9, 0xf4b9, 0xf4b9, 0 }, + { 0xf6f4, 0xf6f4, 0xf6f4, 0 }, + { 0xf932, 0xf932, 0xf932, 0 }, + { 0xfb73, 0xfb73, 0xfb73, 0 }, + { 0xfdb7, 0xfdb7, 0xfdb7, 0 }, + { 0xffff, 0xffff, 0xffff, 0 }, +}; + +const struct vkms_color_lut srgb_eotf = { + .base = srgb_array, + .lut_length = LUT_SIZE, + .channel_value2index_ratio = 0xff00ffll +}; + +static struct drm_color_lut srgb_inv_array[LUT_SIZE] = { + { 0x0, 0x0, 0x0, 0 }, + { 0xcc2, 0xcc2, 0xcc2, 0 }, + { 0x15be, 0x15be, 0x15be, 0 }, + { 0x1c56, 0x1c56, 0x1c56, 0 }, + { 0x21bd, 0x21bd, 0x21bd, 0 }, + { 0x2666, 0x2666, 0x2666, 0 }, + { 0x2a8a, 0x2a8a, 0x2a8a, 0 }, + { 0x2e4c, 0x2e4c, 0x2e4c, 0 }, + { 0x31c0, 0x31c0, 0x31c0, 0 }, + { 0x34f6, 0x34f6, 0x34f6, 0 }, + { 0x37f9, 0x37f9, 0x37f9, 0 }, + { 0x3acf, 0x3acf, 0x3acf, 0 }, + { 0x3d80, 0x3d80, 0x3d80, 0 }, + { 0x4010, 0x4010, 0x4010, 0 }, + { 0x4284, 0x4284, 0x4284, 0 }, + { 0x44dd, 0x44dd, 0x44dd, 0 }, + { 0x4720, 0x4720, 0x4720, 0 }, + { 0x494e, 0x494e, 0x494e, 0 }, + { 0x4b69, 0x4b69, 0x4b69, 0 }, + { 0x4d73, 0x4d73, 0x4d73, 0 }, + { 0x4f6e, 0x4f6e, 0x4f6e, 0 }, + { 0x5159, 0x5159, 0x5159, 0 }, + { 0x5337, 0x5337, 0x5337, 0 }, + { 0x5509, 0x5509, 0x5509, 0 }, + { 0x56cf, 0x56cf, 0x56cf, 0 }, + { 0x588a, 0x588a, 0x588a, 0 }, + { 0x5a3b, 0x5a3b, 0x5a3b, 0 }, + { 0x5be2, 0x5be2, 0x5be2, 0 }, + { 0x5d80, 0x5d80, 0x5d80, 0 }, + { 0x5f16, 0x5f16, 0x5f16, 0 }, + { 0x60a4, 0x60a4, 0x60a4, 0 }, + { 0x6229, 0x6229, 0x6229, 0 }, + { 0x63a8, 0x63a8, 0x63a8, 0 }, + { 0x6520, 0x6520, 0x6520, 0 }, + { 0x6691, 0x6691, 0x6691, 0 }, + { 0x67fc, 0x67fc, 0x67fc, 0 }, + { 0x6961, 0x6961, 0x6961, 0 }, + { 0x6ac0, 0x6ac0, 0x6ac0, 0 }, + { 0x6c19, 0x6c19, 0x6c19, 0 }, + { 0x6d6e, 0x6d6e, 0x6d6e, 0 }, + { 0x6ebd, 0x6ebd, 0x6ebd, 0 }, + { 0x7008, 0x7008, 0x7008, 0 }, + { 0x714d, 0x714d, 0x714d, 0 }, + { 0x728f, 0x728f, 0x728f, 0 }, + { 0x73cc, 0x73cc, 0x73cc, 0 }, + { 0x7504, 0x7504, 0x7504, 0 }, + { 0x7639, 0x7639, 0x7639, 0 }, + { 0x776a, 0x776a, 0x776a, 0 }, + { 0x7897, 0x7897, 0x7897, 0 }, + { 0x79c1, 0x79c1, 0x79c1, 0 }, + { 0x7ae7, 0x7ae7, 0x7ae7, 0 }, + { 0x7c09, 0x7c09, 0x7c09, 0 }, + { 0x7d28, 0x7d28, 0x7d28, 0 }, + { 0x7e44, 0x7e44, 0x7e44, 0 }, + { 0x7f5d, 0x7f5d, 0x7f5d, 0 }, + { 0x8073, 0x8073, 0x8073, 0 }, + { 0x8186, 0x8186, 0x8186, 0 }, + { 0x8296, 0x8296, 0x8296, 0 }, + { 0x83a4, 0x83a4, 0x83a4, 0 }, + { 0x84ae, 0x84ae, 0x84ae, 0 }, + { 0x85b6, 0x85b6, 0x85b6, 0 }, + { 0x86bc, 0x86bc, 0x86bc, 0 }, + { 0x87bf, 0x87bf, 0x87bf, 0 }, + { 0x88bf, 0x88bf, 0x88bf, 0 }, + { 0x89be, 0x89be, 0x89be, 0 }, + { 0x8ab9, 0x8ab9, 0x8ab9, 0 }, + { 0x8bb3, 0x8bb3, 0x8bb3, 0 }, + { 0x8cab, 0x8cab, 0x8cab, 0 }, + { 0x8da0, 0x8da0, 0x8da0, 0 }, + { 0x8e93, 0x8e93, 0x8e93, 0 }, + { 0x8f84, 0x8f84, 0x8f84, 0 }, + { 0x9073, 0x9073, 0x9073, 0 }, + { 0x9161, 0x9161, 0x9161, 0 }, + { 0x924c, 0x924c, 0x924c, 0 }, + { 0x9335, 0x9335, 0x9335, 0 }, + { 0x941d, 0x941d, 0x941d, 0 }, + { 0x9503, 0x9503, 0x9503, 0 }, + { 0x95e7, 0x95e7, 0x95e7, 0 }, + { 0x96c9, 0x96c9, 0x96c9, 0 }, + { 0x97aa, 0x97aa, 0x97aa, 0 }, + { 0x9889, 0x9889, 0x9889, 0 }, + { 0x9966, 0x9966, 0x9966, 0 }, + { 0x9a42, 0x9a42, 0x9a42, 0 }, + { 0x9b1c, 0x9b1c, 0x9b1c, 0 }, + { 0x9bf5, 0x9bf5, 0x9bf5, 0 }, + { 0x9ccc, 0x9ccc, 0x9ccc, 0 }, + { 0x9da1, 0x9da1, 0x9da1, 0 }, + { 0x9e76, 0x9e76, 0x9e76, 0 }, + { 0x9f49, 0x9f49, 0x9f49, 0 }, + { 0xa01a, 0xa01a, 0xa01a, 0 }, + { 0xa0ea, 0xa0ea, 0xa0ea, 0 }, + { 0xa1b9, 0xa1b9, 0xa1b9, 0 }, + { 0xa286, 0xa286, 0xa286, 0 }, + { 0xa352, 0xa352, 0xa352, 0 }, + { 0xa41d, 0xa41d, 0xa41d, 0 }, + { 0xa4e7, 0xa4e7, 0xa4e7, 0 }, + { 0xa5af, 0xa5af, 0xa5af, 0 }, + { 0xa676, 0xa676, 0xa676, 0 }, + { 0xa73c, 0xa73c, 0xa73c, 0 }, + { 0xa801, 0xa801, 0xa801, 0 }, + { 0xa8c5, 0xa8c5, 0xa8c5, 0 }, + { 0xa987, 0xa987, 0xa987, 0 }, + { 0xaa48, 0xaa48, 0xaa48, 0 }, + { 0xab09, 0xab09, 0xab09, 0 }, + { 0xabc8, 0xabc8, 0xabc8, 0 }, + { 0xac86, 0xac86, 0xac86, 0 }, + { 0xad43, 0xad43, 0xad43, 0 }, + { 0xadff, 0xadff, 0xadff, 0 }, + { 0xaeba, 0xaeba, 0xaeba, 0 }, + { 0xaf74, 0xaf74, 0xaf74, 0 }, + { 0xb02d, 0xb02d, 0xb02d, 0 }, + { 0xb0e5, 0xb0e5, 0xb0e5, 0 }, + { 0xb19c, 0xb19c, 0xb19c, 0 }, + { 0xb252, 0xb252, 0xb252, 0 }, + { 0xb307, 0xb307, 0xb307, 0 }, + { 0xb3bb, 0xb3bb, 0xb3bb, 0 }, + { 0xb46f, 0xb46f, 0xb46f, 0 }, + { 0xb521, 0xb521, 0xb521, 0 }, + { 0xb5d3, 0xb5d3, 0xb5d3, 0 }, + { 0xb683, 0xb683, 0xb683, 0 }, + { 0xb733, 0xb733, 0xb733, 0 }, + { 0xb7e2, 0xb7e2, 0xb7e2, 0 }, + { 0xb890, 0xb890, 0xb890, 0 }, + { 0xb93d, 0xb93d, 0xb93d, 0 }, + { 0xb9ea, 0xb9ea, 0xb9ea, 0 }, + { 0xba96, 0xba96, 0xba96, 0 }, + { 0xbb40, 0xbb40, 0xbb40, 0 }, + { 0xbbea, 0xbbea, 0xbbea, 0 }, + { 0xbc94, 0xbc94, 0xbc94, 0 }, + { 0xbd3c, 0xbd3c, 0xbd3c, 0 }, + { 0xbde4, 0xbde4, 0xbde4, 0 }, + { 0xbe8b, 0xbe8b, 0xbe8b, 0 }, + { 0xbf31, 0xbf31, 0xbf31, 0 }, + { 0xbfd7, 0xbfd7, 0xbfd7, 0 }, + { 0xc07b, 0xc07b, 0xc07b, 0 }, + { 0xc120, 0xc120, 0xc120, 0 }, + { 0xc1c3, 0xc1c3, 0xc1c3, 0 }, + { 0xc266, 0xc266, 0xc266, 0 }, + { 0xc308, 0xc308, 0xc308, 0 }, + { 0xc3a9, 0xc3a9, 0xc3a9, 0 }, + { 0xc449, 0xc449, 0xc449, 0 }, + { 0xc4e9, 0xc4e9, 0xc4e9, 0 }, + { 0xc589, 0xc589, 0xc589, 0 }, + { 0xc627, 0xc627, 0xc627, 0 }, + { 0xc6c5, 0xc6c5, 0xc6c5, 0 }, + { 0xc763, 0xc763, 0xc763, 0 }, + { 0xc7ff, 0xc7ff, 0xc7ff, 0 }, + { 0xc89b, 0xc89b, 0xc89b, 0 }, + { 0xc937, 0xc937, 0xc937, 0 }, + { 0xc9d2, 0xc9d2, 0xc9d2, 0 }, + { 0xca6c, 0xca6c, 0xca6c, 0 }, + { 0xcb06, 0xcb06, 0xcb06, 0 }, + { 0xcb9f, 0xcb9f, 0xcb9f, 0 }, + { 0xcc37, 0xcc37, 0xcc37, 0 }, + { 0xcccf, 0xcccf, 0xcccf, 0 }, + { 0xcd66, 0xcd66, 0xcd66, 0 }, + { 0xcdfd, 0xcdfd, 0xcdfd, 0 }, + { 0xce93, 0xce93, 0xce93, 0 }, + { 0xcf29, 0xcf29, 0xcf29, 0 }, + { 0xcfbe, 0xcfbe, 0xcfbe, 0 }, + { 0xd053, 0xd053, 0xd053, 0 }, + { 0xd0e7, 0xd0e7, 0xd0e7, 0 }, + { 0xd17a, 0xd17a, 0xd17a, 0 }, + { 0xd20d, 0xd20d, 0xd20d, 0 }, + { 0xd2a0, 0xd2a0, 0xd2a0, 0 }, + { 0xd331, 0xd331, 0xd331, 0 }, + { 0xd3c3, 0xd3c3, 0xd3c3, 0 }, + { 0xd454, 0xd454, 0xd454, 0 }, + { 0xd4e4, 0xd4e4, 0xd4e4, 0 }, + { 0xd574, 0xd574, 0xd574, 0 }, + { 0xd603, 0xd603, 0xd603, 0 }, + { 0xd692, 0xd692, 0xd692, 0 }, + { 0xd720, 0xd720, 0xd720, 0 }, + { 0xd7ae, 0xd7ae, 0xd7ae, 0 }, + { 0xd83c, 0xd83c, 0xd83c, 0 }, + { 0xd8c9, 0xd8c9, 0xd8c9, 0 }, + { 0xd955, 0xd955, 0xd955, 0 }, + { 0xd9e1, 0xd9e1, 0xd9e1, 0 }, + { 0xda6d, 0xda6d, 0xda6d, 0 }, + { 0xdaf8, 0xdaf8, 0xdaf8, 0 }, + { 0xdb83, 0xdb83, 0xdb83, 0 }, + { 0xdc0d, 0xdc0d, 0xdc0d, 0 }, + { 0xdc97, 0xdc97, 0xdc97, 0 }, + { 0xdd20, 0xdd20, 0xdd20, 0 }, + { 0xdda9, 0xdda9, 0xdda9, 0 }, + { 0xde31, 0xde31, 0xde31, 0 }, + { 0xdeb9, 0xdeb9, 0xdeb9, 0 }, + { 0xdf41, 0xdf41, 0xdf41, 0 }, + { 0xdfc8, 0xdfc8, 0xdfc8, 0 }, + { 0xe04f, 0xe04f, 0xe04f, 0 }, + { 0xe0d5, 0xe0d5, 0xe0d5, 0 }, + { 0xe15b, 0xe15b, 0xe15b, 0 }, + { 0xe1e0, 0xe1e0, 0xe1e0, 0 }, + { 0xe266, 0xe266, 0xe266, 0 }, + { 0xe2ea, 0xe2ea, 0xe2ea, 0 }, + { 0xe36f, 0xe36f, 0xe36f, 0 }, + { 0xe3f3, 0xe3f3, 0xe3f3, 0 }, + { 0xe476, 0xe476, 0xe476, 0 }, + { 0xe4f9, 0xe4f9, 0xe4f9, 0 }, + { 0xe57c, 0xe57c, 0xe57c, 0 }, + { 0xe5fe, 0xe5fe, 0xe5fe, 0 }, + { 0xe680, 0xe680, 0xe680, 0 }, + { 0xe702, 0xe702, 0xe702, 0 }, + { 0xe783, 0xe783, 0xe783, 0 }, + { 0xe804, 0xe804, 0xe804, 0 }, + { 0xe884, 0xe884, 0xe884, 0 }, + { 0xe905, 0xe905, 0xe905, 0 }, + { 0xe984, 0xe984, 0xe984, 0 }, + { 0xea04, 0xea04, 0xea04, 0 }, + { 0xea83, 0xea83, 0xea83, 0 }, + { 0xeb02, 0xeb02, 0xeb02, 0 }, + { 0xeb80, 0xeb80, 0xeb80, 0 }, + { 0xebfe, 0xebfe, 0xebfe, 0 }, + { 0xec7b, 0xec7b, 0xec7b, 0 }, + { 0xecf9, 0xecf9, 0xecf9, 0 }, + { 0xed76, 0xed76, 0xed76, 0 }, + { 0xedf2, 0xedf2, 0xedf2, 0 }, + { 0xee6f, 0xee6f, 0xee6f, 0 }, + { 0xeeeb, 0xeeeb, 0xeeeb, 0 }, + { 0xef66, 0xef66, 0xef66, 0 }, + { 0xefe2, 0xefe2, 0xefe2, 0 }, + { 0xf05d, 0xf05d, 0xf05d, 0 }, + { 0xf0d7, 0xf0d7, 0xf0d7, 0 }, + { 0xf152, 0xf152, 0xf152, 0 }, + { 0xf1cc, 0xf1cc, 0xf1cc, 0 }, + { 0xf245, 0xf245, 0xf245, 0 }, + { 0xf2bf, 0xf2bf, 0xf2bf, 0 }, + { 0xf338, 0xf338, 0xf338, 0 }, + { 0xf3b0, 0xf3b0, 0xf3b0, 0 }, + { 0xf429, 0xf429, 0xf429, 0 }, + { 0xf4a1, 0xf4a1, 0xf4a1, 0 }, + { 0xf519, 0xf519, 0xf519, 0 }, + { 0xf590, 0xf590, 0xf590, 0 }, + { 0xf608, 0xf608, 0xf608, 0 }, + { 0xf67e, 0xf67e, 0xf67e, 0 }, + { 0xf6f5, 0xf6f5, 0xf6f5, 0 }, + { 0xf76b, 0xf76b, 0xf76b, 0 }, + { 0xf7e1, 0xf7e1, 0xf7e1, 0 }, + { 0xf857, 0xf857, 0xf857, 0 }, + { 0xf8cd, 0xf8cd, 0xf8cd, 0 }, + { 0xf942, 0xf942, 0xf942, 0 }, + { 0xf9b7, 0xf9b7, 0xf9b7, 0 }, + { 0xfa2b, 0xfa2b, 0xfa2b, 0 }, + { 0xfaa0, 0xfaa0, 0xfaa0, 0 }, + { 0xfb14, 0xfb14, 0xfb14, 0 }, + { 0xfb88, 0xfb88, 0xfb88, 0 }, + { 0xfbfb, 0xfbfb, 0xfbfb, 0 }, + { 0xfc6e, 0xfc6e, 0xfc6e, 0 }, + { 0xfce1, 0xfce1, 0xfce1, 0 }, + { 0xfd54, 0xfd54, 0xfd54, 0 }, + { 0xfdc6, 0xfdc6, 0xfdc6, 0 }, + { 0xfe39, 0xfe39, 0xfe39, 0 }, + { 0xfeaa, 0xfeaa, 0xfeaa, 0 }, + { 0xff1c, 0xff1c, 0xff1c, 0 }, + { 0xff8d, 0xff8d, 0xff8d, 0 }, + { 0xffff, 0xffff, 0xffff, 0 }, +}; + +const struct vkms_color_lut srgb_inv_eotf = { + .base = srgb_inv_array, + .lut_length = LUT_SIZE, + .channel_value2index_ratio = 0xff00ffll +}; diff --git a/drivers/gpu/drm/vkms/vkms_luts.h b/drivers/gpu/drm/vkms/vkms_luts.h new file mode 100644 index 000000000000..053512a643f7 --- /dev/null +++ b/drivers/gpu/drm/vkms/vkms_luts.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef _VKMS_LUTS_H_ +#define _VKMS_LUTS_H_ + +#define LUT_SIZE 256 + +extern const struct vkms_color_lut linear_eotf; +extern const struct vkms_color_lut srgb_eotf; +extern const struct vkms_color_lut srgb_inv_eotf; + +#endif /* _VKMS_LUTS_H_ */ \ No newline at end of file diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index e5c625ab8e3e..8520ee0534d1 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -215,5 +215,7 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, drm_plane_create_rotation_property(&plane->base, DRM_MODE_ROTATE_0, DRM_MODE_ROTATE_MASK | DRM_MODE_REFLECT_MASK); + vkms_initialize_colorops(&plane->base); + return plane; } From patchwork Thu Oct 19 21:21:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13429865 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 DE4A7C00A98 for ; Thu, 19 Oct 2023 21:23:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DBD8C10E56B; Thu, 19 Oct 2023 21:23:24 +0000 (UTC) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2056.outbound.protection.outlook.com [40.107.94.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id F1E6E10E567; Thu, 19 Oct 2023 21:23:20 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FG1eO1Nn2Ts7g1bP9xjYfthHTQJJZsnwrDO5SeTQSkZt3imuNZnzxFLWhBPFRAmyFSLY7UKGMYC36PGVJiHuaVTiag2rRCPinJRoezNusqGbkuLPOFGLQ3qREtmqtUloU0PQEdz3Pxr/rDp92EgWezcYUsOQSvfgvTtW2WUkyeNDPWINK/x1NnDqwi3WoSVfDejtGPhzq2QsGvgOd37qWXeb9KXYkGVZPyCPoDhRSa2Xpp+8QEJt4LXAPbmZ79sbPL6cEt2B9s1vkcIt5da6+bu7b2zftI46az6lGbAqPh7kIaBlWwSrrLYjxHxbbAnlvcXhNiMCD1Fogh6hJBf8vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NzCY4tEWaePunveco7AAoWtk5Dto5jVqKqQPoKjb/kM=; b=JO0lfxET2NXvVqhWP5uoZFzOVhuAqoc7MbktlJ3cRLfrbWohqIjW3PWyVrLOf7D3xvDOAHQrYvLO007snNkJEsrAzOMJgA/NWsTRvxvGlLuT4+oudKson9hhFPb/7felzfoKvR8Uw0Id+Kg5Vq/1w0/IRBtDnX5N87bB1ekw8WO/raWevo/0UTMOtn371TULzm0nEC2ZmUBODlmssIACUdohXR5GWePme5pF08on73aMfBkqS7dP3Vc1YTI7SkqIj7x5fluKSKdUut1GNIUXMwv/FCwkGJ59XK0KxV26yaf7Ymr6LS9sgkn9SGvF/vXZ0PEKTeAmSuEv3UlnpKJ2Gg== 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 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=NzCY4tEWaePunveco7AAoWtk5Dto5jVqKqQPoKjb/kM=; b=ux6aIqFyRvWTymoIFUjcB9nNL0WUythfqHHjjq6EFSoHYM78l8bNx6ft15HLi/gBXIwLWuidg68tNI+TK6EKC5PsvBJvOXcWDaCQSGOqq2qrVBipNEkvkq6tb/on/C9c830MK2sBZ6vk5tuRNk4yLTwRVeDkyC4sq3cMHNW+BTk= Received: from MN2PR16CA0064.namprd16.prod.outlook.com (2603:10b6:208:234::33) by BN9PR12MB5034.namprd12.prod.outlook.com (2603:10b6:408:104::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.24; Thu, 19 Oct 2023 21:23:18 +0000 Received: from BL02EPF0001A108.namprd05.prod.outlook.com (2603:10b6:208:234:cafe::23) by MN2PR16CA0064.outlook.office365.com (2603:10b6:208:234::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.23 via Frontend Transport; Thu, 19 Oct 2023 21:23: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 BL02EPF0001A108.mail.protection.outlook.com (10.167.241.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6907.20 via Frontend Transport; Thu, 19 Oct 2023 21:23:18 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 19 Oct 2023 16:22:49 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 19 Oct 2023 16:22:49 -0500 Received: from hwentlanrmb.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Thu, 19 Oct 2023 16:22:48 -0500 From: Harry Wentland To: Subject: [RFC PATCH v2 17/17] drm/vkms: Add kunit tests for linear and sRGB LUTs Date: Thu, 19 Oct 2023 17:21:33 -0400 Message-ID: <20231019212133.245155-18-harry.wentland@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231019212133.245155-1-harry.wentland@amd.com> References: <20231019212133.245155-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A108:EE_|BN9PR12MB5034:EE_ X-MS-Office365-Filtering-Correlation-Id: 92ae086f-cd31-425a-7467-08dbd0e99d4a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nvI5tXxQSgEAf/Y7IiRVTsE9+AsaYIPdb+K9V3kN9V6iQ6a99bCPnUvvSx+v9R2+LOLwJNDtewzlXA1M8yN12aLCUEFeSlzg8TfwaizDOUupEPEcOnW8EjKhSbFiLk1RbuUqm3yOetfFP0tGnw68qrX6lEDfhQRzRGIpdYO+Ax+zz5FTbRpbS/sQ6XXnxNMC8NzXcJloBMCshRVl91joVq9+mSaJHplaRf6O2O0M22RQJkVeUqh/uSrAQuJ1oPb7Jycn+2J5OFamO4Mm6Kja7G8NIFjmRp5GTHTEExviYT54L5E2hc8nBHz48apZxZ+E976VMQah55bA3gYZkJMOmGZFqa3QRDTNgm125hQRM3fM8pJVAgdho7lu4my/j1QiL0UWq0qWOZnRam6+po4rtpobeesnEfbQq4Mhxrc3vpMcaoyfIbOCEj0NF2TvBmedA23zypn8LsO4bIeOyWlj/JnBaXaqMY1xnuQMJWd/SDvPywv4TizdjLJukhTlbu+tsoR9UgxdcB50OBCftbgg5rJ8S4gj+WB0G5hgaS0uQ8AhLh/ux5opHjUpEVRzBfqV/EJRh5zMLccT6ZuTQyuKxAVoY4i62XB7MUq1DEpm493nwVrHp50ldzvsVTzVwXMXR+spLgImET7i/M4jGIyBc0EvpH0s0/QyJGuN44bAoBcHIW8xd01oxA0txYzlcCoRNYg9FsLH7tGgI2Et0EqDlsN702fDbY5HtYLMBhiqlsq4tvx4Vz8FZvyuTam4d3/rI3Sp5NatScDAN7gfNoQheA== 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:(13230031)(4636009)(39860400002)(396003)(376002)(346002)(136003)(230922051799003)(82310400011)(64100799003)(186009)(1800799009)(451199024)(40470700004)(46966006)(36840700001)(40480700001)(86362001)(82740400003)(356005)(40460700003)(26005)(336012)(426003)(66574015)(2616005)(1076003)(81166007)(41300700001)(478600001)(8676002)(44832011)(5660300002)(8936002)(4326008)(2906002)(7416002)(70206006)(316002)(6916009)(36756003)(54906003)(70586007)(6666004)(7696005)(36860700001)(47076005)(83380400001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2023 21:23:18.7291 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 92ae086f-cd31-425a-7467-08dbd0e99d4a 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: BL02EPF0001A108.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5034 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: , Cc: Sasha McIntosh , Liviu Dudau , Victoria Brekenfeld , =?utf-8?q?Michel_D=C3=A4nzer?= , Arthur Grillo , Sebastian Wick , Shashank Sharma , wayland-devel@lists.freedesktop.org, =?utf-8?q?Jonas_=C3=85dahl?= , Uma Shankar , Abhinav Kumar , Naseer Ahmed , Melissa Wen , Aleix Pol , Christopher Braga , Pekka Paalanen , Hector Martin , Xaver Hugl , Joshua Ashton Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Signed-off-by: Harry Wentland Cc: Ville Syrjala Cc: Pekka Paalanen Cc: Simon Ser Cc: Harry Wentland Cc: Melissa Wen Cc: Jonas Ådahl Cc: Sebastian Wick Cc: Shashank Sharma Cc: Alexander Goins Cc: Joshua Ashton Cc: Michel Dänzer Cc: Aleix Pol Cc: Xaver Hugl Cc: Victoria Brekenfeld Cc: Sima Cc: Uma Shankar Cc: Naseer Ahmed Cc: Christopher Braga Cc: Abhinav Kumar Cc: Arthur Grillo Cc: Hector Martin Cc: Liviu Dudau Cc: Sasha McIntosh --- drivers/gpu/drm/vkms/tests/vkms_color_tests.c | 38 ++++++++++++++++++- drivers/gpu/drm/vkms/vkms_composer.c | 13 +------ drivers/gpu/drm/vkms/vkms_composer.h | 14 +++++++ 3 files changed, 52 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/vkms/tests/vkms_color_tests.c b/drivers/gpu/drm/vkms/tests/vkms_color_tests.c index 843b2e1d607e..14decb5d1b64 100644 --- a/drivers/gpu/drm/vkms/tests/vkms_color_tests.c +++ b/drivers/gpu/drm/vkms/tests/vkms_color_tests.c @@ -5,6 +5,7 @@ #include #include "../vkms_composer.h" +#include "../vkms_luts.h" #define TEST_LUT_SIZE 16 @@ -33,7 +34,6 @@ const struct vkms_color_lut test_linear_lut = { .channel_value2index_ratio = 0xf000fll }; - static void vkms_color_test_get_lut_index(struct kunit *test) { int i; @@ -42,6 +42,19 @@ static void vkms_color_test_get_lut_index(struct kunit *test) for (i = 0; i < TEST_LUT_SIZE; i++) KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&test_linear_lut, test_linear_array[i].red)), i); + + KUNIT_EXPECT_EQ(test, drm_fixp2int(get_lut_index(&srgb_eotf, 0x0)), 0x0); + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_eotf, 0x0)), 0x0); + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_eotf, 0x101)), 0x1); + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_eotf, 0x202)), 0x2); + + KUNIT_EXPECT_EQ(test, drm_fixp2int(get_lut_index(&srgb_inv_eotf, 0x0)), 0x0); + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_inv_eotf, 0x0)), 0x0); + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_inv_eotf, 0x101)), 0x1); + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_inv_eotf, 0x202)), 0x2); + + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_eotf, 0xfefe)), 0xfe); + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_eotf, 0xffff)), 0xff); } static void vkms_color_test_lerp(struct kunit *test) @@ -49,9 +62,32 @@ static void vkms_color_test_lerp(struct kunit *test) KUNIT_EXPECT_EQ(test, lerp_u16(0x0, 0x10, 0x80000000), 0x8); } +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 73b7d5e94021..24c984f2876f 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -110,18 +110,7 @@ s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel_value) return drm_fixp_mul(color_channel_fp, lut->channel_value2index_ratio); } -/* - * 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, +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); diff --git a/drivers/gpu/drm/vkms/vkms_composer.h b/drivers/gpu/drm/vkms/vkms_composer.h index 11c5de9cc961..d92497c555eb 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.h +++ b/drivers/gpu/drm/vkms/vkms_composer.h @@ -8,4 +8,18 @@ s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel_value); u16 lerp_u16(u16 a, u16 b, s64 t); +/* + * 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 +}; + +u16 apply_lut_to_channel_value(const struct vkms_color_lut *lut, u16 channel_value, + enum lut_channel channel); + #endif /* _VKMS_COMPOSER_H_ */ \ No newline at end of file