From patchwork Fri Sep 8 15:02: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: 13377581 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 73F04EE8011 for ; Fri, 8 Sep 2023 15:03:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E808A10E8F2; Fri, 8 Sep 2023 15:02:50 +0000 (UTC) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2061a.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eaa::61a]) by gabe.freedesktop.org (Postfix) with ESMTPS id EE1DF10E8E5; Fri, 8 Sep 2023 15:02:46 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AxbcnorI3gjbZNCLZK8AWFWzXmxRbd3zrQoOzV1VzKYknBkHF7DgLywQxDW00nJ6p7h8xmfiHo63H8VdNzpA68LJXXJz/Fclu+oU8k0wROdeRZMfoe+SYvspU9P0EddkYorL4BEBPIPVoTlUmmFUfV//NmhsJL0NV9fkhG0csgxXLxu+wgqh1QE4Ba0zOtu1LmppwOZ2B7GGI2FaB3gK0dD0QeFa6xO1CL2xufPRWF65PRN/K7BA3ByFHNDzitmafPxPP8IuNp4Lx7n0yUyzvRWCAaN+AXHRa1tCN941bv87q/QLfGVlYOSdvCk9hoywSQiXz6RY+h/H7de9mowMbg== 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=pusTVJwF2JKmpaD4olMjutog9lQxXXm+VWjgzq2ima0=; b=APFTUm66DiAZJErliIUmSFmLtlCnfHeRmbJNVEV2Vzz8+FuiyO7aG5rT8bsYoi5lidC45wRzG+I05INgZIou6qqMUoDa3HQ38Q+8NzCvpyEuaV+YveraRDBZQ4aTCcj02cFoZOzqGZgcyqYWtHiu+TyEop4VvPuhaAjC1rXlM7UGCcpVLUwcM5JvBtZL7q7Qai7wSFpF1KhFupQzQc/2P7c1Ax+m6/hCF1JdO4eweCfGxX0tBhxMKEarqieMftm2hCLKr5Q8rwvklOTMViE8RtSE+gTVUlLibOObWT8rcXJ2jjV1V5YcVBDuCtPYtasdSJPrOcPDPdMNWaKpDDW5XA== 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=pusTVJwF2JKmpaD4olMjutog9lQxXXm+VWjgzq2ima0=; b=GVrrPTK74tgfqAyOMYNoj5KFoEILH2gRad5umd450z+qMD5EDd57HTnHPmZm8hc/JnLXKLbFBMFgPm3BLQZ+0zpM1lU4cn8C2a/kk4HIpIvaXqbI+G3Q8WABJDR5RL+P8DN3KfnDHcjqHx82EnfeXtX3OVLZzbV1BXvftymj4EM= Received: from CH0PR13CA0047.namprd13.prod.outlook.com (2603:10b6:610:b2::22) by CH3PR12MB8911.namprd12.prod.outlook.com (2603:10b6:610:169::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.23; Fri, 8 Sep 2023 15:02:44 +0000 Received: from DS3PEPF000099DA.namprd04.prod.outlook.com (2603:10b6:610:b2:cafe::ed) by CH0PR13CA0047.outlook.office365.com (2603:10b6:610:b2::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.10 via Frontend Transport; Fri, 8 Sep 2023 15:02:44 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by DS3PEPF000099DA.mail.protection.outlook.com (10.167.17.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6792.11 via Frontend Transport; Fri, 8 Sep 2023 15:02:44 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Fri, 8 Sep 2023 10:02:43 -0500 Received: from hwentlanrmb.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Fri, 8 Sep 2023 10:02:42 -0500 From: Harry Wentland To: Subject: [RFC PATCH 01/10] drm/doc/rfc: Describe why prescriptive color pipeline is needed Date: Fri, 8 Sep 2023 11:02:26 -0400 Message-ID: <20230908150235.75918-2-harry.wentland@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230908150235.75918-1-harry.wentland@amd.com> References: <20230908150235.75918-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DA:EE_|CH3PR12MB8911:EE_ X-MS-Office365-Filtering-Correlation-Id: 5734c205-1246-4a70-9973-08dbb07ca7d3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: K7T4EDSo+Ev1Bxt2pznmjBhnCTvt8iAVoRyb7fybWrlbKInqiusVnpQ5SvpwliRvZ6VF4Pq3xhsjMhD0NyY3z2DmhK+qohu9USnBsA6VQQFkG/vLNQLqBHS+jvcAe1I9jHk4MHKan5GkgL8kU1ANTviPfEsgnODHqg3VP8AS+Gw58vWUMlZV1y1Cs9Mc2lU5BkHN+D+GoMEq3h31uVjCW830rBiYutXTRHyGhUaeWXINIUUaoTb7n7kok7SkSUprbW2YdhEryJaFxwRbNwru5jPh5Rsub3DO+o/vWRg9+f4M5dgdnJQIRWaxGu7AqBp63AFr9GTVVGZPkdlMLdKWUfUQ/kV/X0JtncT9X9CdBhV9Dk/frtf1PQdQrzgwGnyHoV4Fwl/9SGZweFBopJV8b8Nvrw6dq/45uLW1Ya400nxqspxYGuj++pf/gKk4U/UZCvRyQHsd+Z3mIF2ldYJl5/SwMyzEyyFTulcZ9s/Wnhxjxd7XoQcpMx6iPMbFbs99pFlAKS3bh0e3VJ2CGCZ8Jn8XUhClfyZUfTdWrquodY48ilomdAZyAzqrlT5B46KbWC5cZSFuH4MZxxrj6dhDq2vpqT3ZdmgFfih06SclmUQGF+hYOAzw+cnY+pg1BHr21cjymGYNf7j4NMsUJfsu5tiOagn21ynwQbRmwX0ud0cTmxFDSPxVDbUJwkgV5maJuOVZeN0RnsNFhPui4OGgUnUiTGzMS127Ek10wSCqjoYa3BdAVgGdNsrN5FQojYh8PoWVwIXhHTlSrwcmGwpnNQ== 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)(376002)(396003)(39860400002)(346002)(136003)(451199024)(82310400011)(186009)(1800799009)(36840700001)(46966006)(40470700004)(82740400003)(356005)(66899024)(6666004)(7696005)(81166007)(40480700001)(40460700003)(36756003)(86362001)(36860700001)(1076003)(47076005)(26005)(70206006)(83380400001)(66574015)(2906002)(478600001)(70586007)(426003)(4326008)(2616005)(966005)(7416002)(30864003)(336012)(8936002)(41300700001)(8676002)(5660300002)(6916009)(44832011)(54906003)(316002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2023 15:02:44.0371 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5734c205-1246-4a70-9973-08dbb07ca7d3 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: DS3PEPF000099DA.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8911 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: Sebastian Wick , Pekka Paalanen , Shashank Sharma , Xaver Hugl , =?utf-8?q?Michel_D=C3=A4nzer?= , wayland-devel@lists.freedesktop.org, Melissa Wen , =?utf-8?q?Jonas_=C3=85dahl?= , Uma Shankar , Victoria Brekenfeld , Joshua Ashton , Aleix Pol , Naseer Ahmed , Christopher Braga 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: Daniel Vetter Cc: Uma Shankar Cc: Naseer Ahmed Cc: Christopher Braga --- Documentation/gpu/rfc/color_pipeline.rst | 278 +++++++++++++++++++++++ 1 file changed, 278 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..bfa4a8f12087 --- /dev/null +++ b/Documentation/gpu/rfc/color_pipeline.rst @@ -0,0 +1,278 @@ +======================== +Linux Color Pipeline API +======================== + +What problem are we solving? +============================ + +We would like to support pre-, and post-blending complex color transformations +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. + +While it is possible to support an HDR output on HW supporting the Colorspace +and HDR Metadata drm_connector properties 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. + + +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 will almost inevitably make it look very +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 order 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. + + +drm_colorop Object & IOCTLs +=========================== + +To support the definition of color pipelines we introduce a new DRM core +object, a 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. + +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. This allows DRM +clients to fallback to other methods of color management if an atomic +check for KMS color operations fails. + +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:: + + Color operation 42 + ├─ "type": enum {Bypass, 1D curve} = 1D curve + ├─ "1d_curve_type": enum {LUT, sRGB, PQ, BT.709, HLG, …} = LUT + ├─ "lut_size": immutable range = 4096 + ├─ "lut_data": blob + └─ "next": immutable color operation ID = 43 + + Color operation 42 + ├─ "type": enum {Bypass, 3D LUT} = 3D LUT + ├─ "lut_size": immutable range = 33 + ├─ "lut_data": blob + └─ "next": immutable color operation ID = 43 + + Color operation 42 + ├─ "type": enum {Bypass, Matrix} = Matrix + ├─ "matrix_data": blob + └─ "next": immutable color operation ID = 43 + + +COLOR_PIPELINE Plane Property +============================= + +Because we don't have existing KMS color properties in the pre-blending +portion of display pipelines (i.e. on drm_planes) we are introducing +color pipelines here first. Eventually we'll want to use the same +concept for the post-blending portion, i.e. drm_crtcs. + +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 +set 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 enum {Overlay, Primary, Cursor} = Primary + └─ "color_pipeline": enum {0, 42} = 0 + Color operation 42 (input CSC) + ├─ "type": enum {Bypass, Matrix} = Matrix + ├─ "matrix_data": blob + └─ "next": immutable color operation ID = 43 + Color operation 43 + ├─ "type": enum {Scaling} = Scaling + └─ "next": immutable color operation ID = 44 + Color operation 44 (DeGamma) + ├─ "type": enum {Bypass, 1D curve} = 1D curve + ├─ "1d_curve_type": enum {sRGB, PQ, …} = sRGB + └─ "next": immutable color operation ID = 45 + Color operation 45 (gamut remap) + ├─ "type": enum {Bypass, Matrix} = Matrix + ├─ "matrix_data": blob + └─ "next": immutable color operation ID = 46 + Color operation 46 (shaper LUT RAM) + ├─ "type": enum {Bypass, 1D curve} = 1D curve + ├─ "1d_curve_type": enum {LUT} = LUT + ├─ "lut_size": immutable range = 4096 + ├─ "lut_data": blob + └─ "next": immutable color operation ID = 47 + Color operation 47 (3D LUT RAM) + ├─ "type": enum {Bypass, 3D LUT} = 3D LUT + ├─ "lut_size": immutable range = 17 + ├─ "lut_data": blob + └─ "next": immutable color operation ID = 48 + Color operation 48 (blend gamma) + ├─ "type": enum {Bypass, 1D curve} = 1D curve + ├─ "1d_curve_type": enum {LUT, sRGB, PQ, …} = LUT + ├─ "lut_size": immutable range = 4096 + ├─ "lut_data": blob + └─ "next": immutable color operation ID = 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) + └─ "bypasse" = true + Color operation 46 (shaper LUT RAM) + └─ "bypass" = true + Color operation 47 (3D LUT RAM) + └─ "lut_data" = Gamut mapping + tone mapping + night mode + Color operation 48 (blend gamma) + └─ "1d_curve_type" = PQ inverse EOTF + + +References +========== + +1. https://lore.kernel.org/dri-devel/QMers3awXvNCQlyhWdTtsPwkp5ie9bze_hD5nAccFW7a_RXlWjYB7MoUW_8CKLT2bSQwIXVi5H6VULYIxCdgvryZoAoJnC5lZgyK1QWn488=@emersion.fr/ \ No newline at end of file From patchwork Fri Sep 8 15:02: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: 13377584 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 E1989EE8011 for ; Fri, 8 Sep 2023 15:03:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1F66410E8F9; Fri, 8 Sep 2023 15:02:53 +0000 (UTC) Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2062d.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eb2::62d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2CB2010E8E7; Fri, 8 Sep 2023 15:02:49 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AElzwp6yRaZU5IfbnfIPh/iycG6X2txHuHvrz70sqR4+Sjm7hytwGhDNSkO0EWvghY2T+1IyMkeVqKdefTr2IYv3jrkbwh4l7JOuw663TLRy5mNUBSTT4poeU+imQLGgET3nRHk87Q/hd2EGt6w+rT+rvU3jOIsj3yq/tLtjrg5TS0hgKerowAc84kGt6dvrabwbskI60mwUgSPyJp09g2GwaKSvMb2PK3bPyoUVcNUAEcF2dcejLuvVwFXBIe9bWcXJKTl3scCOkokWeSJikZNwg/L+3jq70SgQxbDbh8XhigmC1EPzL4gr3drc3g50WbcOlfDahAuAEzezH+t99w== 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=Z9dsublalnWUkVuYzmXxeTm+wmoXhkDgwcGKhEzXPp4=; b=LPzKgIOq/aom7AldEvgPf99S5CnJ6Hk9FMfdrKZNkABZhRXICmv5Ly0CbeIar9Iq/j5oG5KeUA473Asv0vdVC0icgYzHQ/ExyIa8Bw3+uRjJwU+nrgNA6CPzxZR1I0PrrbphBJqQO2+Mhmh8M1qWILTXaaT3HyLQVKZxdZC3Eb1Pe6w7GxuSGMwZ5a6fIX2VjSZMrp/ytHmv8VwRfW0+Eh/OqP2cD2jS4ClBdeeTLPPyvX7MXbBYrYNQWL3/kAsBQITfFmpHzHepPBplzMondmws245MrHFwPmmIm23Nj2RDBv4DgYvUpfQB8hRnT0YjV2D0auHcBSKYIP4shVwx7w== 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=Z9dsublalnWUkVuYzmXxeTm+wmoXhkDgwcGKhEzXPp4=; b=gmLpnOY1sit59kihNE0eQsbNcXpu0xpCGHHtgQWducBvoWG10VdkMILBOTXf1bOYT0GavaKII8sdrlofv/kHFW+AAuV1xxga1S4GoxfYNiKWgIIERWGrm9v66TZe0hlffg5QHovaLT2BhgTVnNuNp9zADDWf2seUTDlLPN691Hw= Received: from CH0PR13CA0041.namprd13.prod.outlook.com (2603:10b6:610:b2::16) by CH2PR12MB4165.namprd12.prod.outlook.com (2603:10b6:610:a4::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.30; Fri, 8 Sep 2023 15:02:46 +0000 Received: from DS3PEPF000099DA.namprd04.prod.outlook.com (2603:10b6:610:b2:cafe::ff) by CH0PR13CA0041.outlook.office365.com (2603:10b6:610:b2::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.10 via Frontend Transport; Fri, 8 Sep 2023 15:02: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 DS3PEPF000099DA.mail.protection.outlook.com (10.167.17.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6792.11 via Frontend Transport; Fri, 8 Sep 2023 15:02:45 +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; Fri, 8 Sep 2023 10:02:45 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Fri, 8 Sep 2023 08:02:44 -0700 Received: from hwentlanrmb.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Fri, 8 Sep 2023 10:02:43 -0500 From: Harry Wentland To: Subject: [RFC PATCH 02/10] drm/colorop: Introduce new drm_colorop mode object Date: Fri, 8 Sep 2023 11:02:27 -0400 Message-ID: <20230908150235.75918-3-harry.wentland@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230908150235.75918-1-harry.wentland@amd.com> References: <20230908150235.75918-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DA:EE_|CH2PR12MB4165:EE_ X-MS-Office365-Filtering-Correlation-Id: 708f4ff8-e37e-4d7d-6588-08dbb07ca8e3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: irIaTNpYZnZtmjRcLBVK0RapDdusJJjl9P2/mWPy7+iqfhxBVJm35TkGo4aNJnUHUlYfoLklF6m+5iBYNPq0s5PsNGY8ayZBusz86z5ZwJ8vRRAQ/KjkSacrvjphsLo75iScWf3EciTIG9iAmrvomCPdsOFEQUs4LofUcBTvcM+1U5xqb1HOBGgmRwyC+VPwOLZva2wEBtEoXgfyz5NpfiVdU8DAHI4Os+6BfzeAgPgbs+fwYjn48JerIRr6Shh2HVUQfmWJB0/xI7GgoO32M0ExNJWgJqqfxV7AGXR6DETF7IAn5dTVuiejf31vC7/L1AiS5doWLOgm/cQdg/XBvsQdzDrivDcQKkhZU1wrF8q9SRqhKmBmOmIJJgnAitOr0XpoNC3kh0OUixhwsEPNdoDug/0UvH90jO/F5I0guXFW2Vt2yYLWnoXwlNfyJnPe2gRI3q5G28VcuNPYEZdUb2hYARj71qIm9lwiiF+g+yTfb8++JB1bZYo4GaJ9PgbRb2hHh/XlgDWlR0AI5o2Q04QdZM7IXJ0nNxY7IRkGFRdKnYjqioeS8rlYSgScbyB6pnI2C7kuN+AgQNn/y0F8EFG0lUT4V+H+KL8crDdz7HbeHpvP1q6cHiGsM0579jE83wZhB4IAjuIVGEcl5AW9bHOq7TmB9OKb7f8qdGbrNd9oW7CP3NIWxruPR452Yhxb4ullmpUeCLoceBvgf4DPdisdECclBSFVxx64hVBsgl0NQz/Xi8gmST6TdZIsBh6pV7c015O1op0iavFM4s4jhg== 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)(376002)(39860400002)(396003)(346002)(82310400011)(1800799009)(186009)(451199024)(46966006)(36840700001)(40470700004)(7696005)(6666004)(478600001)(41300700001)(83380400001)(66574015)(336012)(30864003)(2616005)(1076003)(426003)(26005)(7416002)(2906002)(6916009)(44832011)(316002)(54906003)(4326008)(70206006)(5660300002)(70586007)(8936002)(40460700003)(8676002)(82740400003)(47076005)(86362001)(36860700001)(36756003)(40480700001)(81166007)(66899024)(356005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2023 15:02:45.8184 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 708f4ff8-e37e-4d7d-6588-08dbb07ca8e3 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: DS3PEPF000099DA.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4165 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: Sebastian Wick , Pekka Paalanen , Shashank Sharma , Xaver Hugl , =?utf-8?q?Michel_D=C3=A4nzer?= , wayland-devel@lists.freedesktop.org, Melissa Wen , =?utf-8?q?Jonas_=C3=85dahl?= , Uma Shankar , Victoria Brekenfeld , Joshua Ashton , Aleix Pol , Naseer Ahmed , Christopher Braga 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: Daniel Vetter Cc: Uma Shankar Cc: Naseer Ahmed Cc: Christopher Braga --- 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 1855863b4d7a..941de0269709 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 11f3a130f6f4..d734e9d5bfed 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; state->dev = dev; @@ -244,6 +250,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; @@ -562,6 +582,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 d579fd8f7cb8..0472f6182c0a 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -2921,6 +2921,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; @@ -2998,6 +3000,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 d867e7f9f2cd..b1aa752c1848 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -642,6 +643,26 @@ drm_atomic_plane_get_property(struct drm_plane *plane, return 0; } + +static int drm_atomic_colorop_set_property(struct drm_colorop *colorop, + struct drm_colorop_state *state, struct drm_file *file_priv, + struct drm_property *property, uint64_t val) +{ + drm_dbg_atomic(colorop->dev, + "[COLOROP:%d] unknown property [PROP:%d:%s]]\n", + colorop->base.id, + property->base.id, property->name); + return -EINVAL; +} + +static int +drm_atomic_colorop_get_property(struct drm_colorop *colorop, + const struct drm_colorop_state *state, + struct drm_property *property, uint64_t *val) +{ + return -EINVAL; +} + static int drm_atomic_set_writeback_fb_for_connector( struct drm_connector_state *conn_state, struct drm_framebuffer *fb) @@ -893,6 +914,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: ret = -EINVAL; break; @@ -1027,6 +1058,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 87eb591fe9b5..5bdcf71e1ae0 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" @@ -184,11 +185,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); @@ -415,6 +420,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); @@ -436,6 +442,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 c91e454eba09..69faa0eeb27f 100644 --- a/drivers/gpu/drm/drm_plane_helper.c +++ b/drivers/gpu/drm/drm_plane_helper.c @@ -318,4 +318,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 92586ab55ef5..dca8fc26ad71 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); @@ -623,6 +633,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 @@ -870,6 +929,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 e5b053001d22..f56d21d93cf0 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 51291983ea44..cfb8f46b94ab 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 642808520d92..dec498a44eae 100644 --- a/include/uapi/drm/drm.h +++ b/include/uapi/drm/drm.h @@ -1116,6 +1116,9 @@ extern "C" { */ #define DRM_IOCTL_MODE_GETFB2 DRM_IOWR(0xCE, struct drm_mode_fb_cmd2) +#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 46becedf5b2f..6dcf628def56 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -626,6 +626,7 @@ struct drm_mode_connector_set_property { #define DRM_MODE_OBJECT_FB 0xfbfbfbfb #define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb #define DRM_MODE_OBJECT_PLANE 0xeeeeeeee +#define DRM_MODE_OBJECT_COLOROP 0xfafafafa #define DRM_MODE_OBJECT_ANY 0 struct drm_mode_obj_get_properties { From patchwork Fri Sep 8 15:02: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: 13377582 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 5BDB8EE8012 for ; Fri, 8 Sep 2023 15:03:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B1FCD10E8F4; Fri, 8 Sep 2023 15:02:51 +0000 (UTC) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2079.outbound.protection.outlook.com [40.107.94.79]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7F22A10E8EE; Fri, 8 Sep 2023 15:02:49 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IjhBMGBMpbt+le9BscVSzcqkpJ0F0NBVH/KZ7rAMPsaHLAoVgE1rchi3egIKXUS5RpW6n2STthd2vDZpABbPilUN/8lAkOK4s22KWOnPZCVCjj2PO+XyvCcUR48jiNgTiEgIX9O81RUEfDllin/YleQ9CGWDm++MJLwHc/I8Hvy/ZEiz8NiPy/L/WR20SHvgeMCiDFN4/JF+2PmJl55bs33Wbhs37zPlt3f5blvrYs5ku7ioX1+ZEORLyGiCzm8mVBdBW/VlX2irpY606f54GCvi6M+je3k1RKXVxeJJaGpvYYB12F+9gwT4byC+b7DcuDgOqD5NUY+rRwzRIEUICw== 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=QmpUnDxE1/dF7nQ3VvJIbQhffQwnJJS0FXOlqkNV4P0=; b=OFUj+QUHNnNtd1JS7qDuTEcXLc2YnOlTW5aZGZUfYrhvEEIEhF2bj8f85WbNE32CUIkIrNa1xZxaV28eXDYi3paa1aQkm2wgXLwDBnIEWJRg26XHH0SFcuMPnQoqFHB0kKreVW2tISSVj5PCYI6bPul3czv2DRScv9+iI0iaSMUlr5WHD91CoiheSjg0i+RmDem8ME2Yg5cwyrhR8fSq5DqNo7w6CcApO3wEo6VTSdipaQZqfTR3CO/K6h1iUwX6/458pbwRU53UZVoX/a687mn8tI4Or2wwBm8U9GY9772C8nQmF3NyOx3pWWzQnfh5iD6viVN6chLBS0PXxhEW1w== 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=QmpUnDxE1/dF7nQ3VvJIbQhffQwnJJS0FXOlqkNV4P0=; b=laojvoxpbN/8DLJfAxff0UH3Tp0R89VTYjJ1fGymLGE8/StZPQoz5bRLbd7Ledz1VZKtk83pX+z0IuyxcUETHoUaS1nRHF+SoztbMPT4ebAfhus4CWD/ANWGz70oKHFTn0QFWJm7gJR3kfH18U4JxNTItFB7q30GzSsLoyo3HLU= Received: from MW4P221CA0011.NAMP221.PROD.OUTLOOK.COM (2603:10b6:303:8b::16) by SA1PR12MB8163.namprd12.prod.outlook.com (2603:10b6:806:332::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.30; Fri, 8 Sep 2023 15:02:47 +0000 Received: from MWH0EPF000989E8.namprd02.prod.outlook.com (2603:10b6:303:8b:cafe::fa) by MW4P221CA0011.outlook.office365.com (2603:10b6:303:8b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.31 via Frontend Transport; Fri, 8 Sep 2023 15:02:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989E8.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.6792.11 via Frontend Transport; Fri, 8 Sep 2023 15:02:46 +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; Fri, 8 Sep 2023 10:02:46 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Fri, 8 Sep 2023 08:02:45 -0700 Received: from hwentlanrmb.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Fri, 8 Sep 2023 10:02:45 -0500 From: Harry Wentland To: Subject: [RFC PATCH 03/10] drm/colorop: Add TYPE property Date: Fri, 8 Sep 2023 11:02:28 -0400 Message-ID: <20230908150235.75918-4-harry.wentland@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230908150235.75918-1-harry.wentland@amd.com> References: <20230908150235.75918-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989E8:EE_|SA1PR12MB8163:EE_ X-MS-Office365-Filtering-Correlation-Id: 4c389cf6-7bab-4b02-99b4-08dbb07ca992 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ydA/kIB9uw7Lj5a64jjZ47pYMcHMA202aDLmJVfTF+8Xm1bHCVbeq97LX6ACPQBb/CRcHoAvGzTvn9UrQjkbwnAoFs0vycxmO7jkfC2l/gG5j+PlWSmi2LWZfNyvCs2n6ngL+8aHDkQA1zjtpDNsBK7Er+XloJLcSBT0jLLYMd2pGWN1reWhn/eEbrsC6c/sG8RnBFFM+HsWorocD0mmwMC0koRtq/7zAGrqt1VKvLENJQCF8C+C5SbJ54ISxK1gZdx2HcLFDjud3oasP2CpsErwk/n/RxHijBBFxbtcwYCD+qDXE8Weee6KcVy8pdlGel1RMLocsqZ0tpVIDi9+TU686J51A0QMaWqHaFx1xc9W5ddKnZp/32EabbIqGWEA6wrAiZk/vtuyszSa2Uu0bE0kkH74MGXrilDnMvuh9bRkGTwyzfu5oSobzTN7APDDOYv06MbSui+zWFGkZux52DQazWQtWBZIuWTlpIGdYYcuAahOXsvTKyi28tYuHqDtGs068wV2TopfKzWc6e2xYQc3NMs052oKXPX6JIEjTNIy4ncP2CqYBySCDBp34fTaBO1QJQW1Q3wQZHK078WiTHn9vDYqwQ5+/BiKq9Z6/stzHeF+qKbgrZ1+4XB2r3zaR52SAnO7xhtk8y73eCmTQ+6UhUB+PfR1zAE9DrOM8Y8NWgIFuseFOg75OwJB3lZ0BF5qcWnKp0BzZYud5U+0/NIgZIQnzeY4URPqSb0Cpi0oj7Of9LWJPbj5XHajGYZ0H85gVmnbmemCZyY5iOPHfA== 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)(136003)(346002)(396003)(451199024)(1800799009)(82310400011)(186009)(40470700004)(46966006)(36840700001)(40480700001)(40460700003)(54906003)(70206006)(6916009)(316002)(70586007)(478600001)(356005)(81166007)(2906002)(7416002)(86362001)(36860700001)(8936002)(8676002)(4326008)(41300700001)(44832011)(5660300002)(83380400001)(7696005)(47076005)(6666004)(82740400003)(2616005)(426003)(336012)(1076003)(26005)(36756003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2023 15:02:46.8885 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4c389cf6-7bab-4b02-99b4-08dbb07ca992 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: MWH0EPF000989E8.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8163 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: Sebastian Wick , Pekka Paalanen , Shashank Sharma , Xaver Hugl , =?utf-8?q?Michel_D=C3=A4nzer?= , wayland-devel@lists.freedesktop.org, Melissa Wen , =?utf-8?q?Jonas_=C3=85dahl?= , Uma Shankar , Victoria Brekenfeld , Joshua Ashton , Aleix Pol , Naseer Ahmed , Christopher Braga 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: Daniel Vetter Cc: Uma Shankar Cc: Naseer Ahmed Cc: Christopher Braga --- drivers/gpu/drm/drm_atomic.c | 4 +-- drivers/gpu/drm/drm_atomic_uapi.c | 8 +++++- drivers/gpu/drm/drm_colorop.c | 44 ++++++++++++++++++++++++++++++- include/drm/drm_colorop.h | 21 ++++++++++++++- 4 files changed, 72 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index d734e9d5bfed..8a5f8cd22c8d 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -627,8 +627,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 b1aa752c1848..51072fe2b548 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -660,7 +660,13 @@ drm_atomic_colorop_get_property(struct drm_colorop *colorop, const struct drm_colorop_state *state, struct drm_property *property, uint64_t *val) { - return -EINVAL; + if (property == colorop->type_property) { + *val = colorop->type; + } else { + return -EINVAL; + } + + return 0; } static int drm_atomic_set_writeback_fb_for_connector( diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c index 78d6a0067f5b..c028d5426d42 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,24 @@ 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 Fri Sep 8 15:02: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: 13377583 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 D1875EE8012 for ; Fri, 8 Sep 2023 15:03:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CB40E10E8EE; Fri, 8 Sep 2023 15:02:52 +0000 (UTC) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2062.outbound.protection.outlook.com [40.107.223.62]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1582410E8F3; Fri, 8 Sep 2023 15:02:51 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AmhMmiLuVEHgDsNjOuy8d1FvP+Z331uGL08aik5oHk2R1ImSqZzRrFdEAvg9gZgR2Qurq+PpjzM6wvQ32hWIkKNXy7Ey9hdPZ/27eYuRXzpoSeXJgZDamn4oLfpasKvCmhDDLwcGuxPD4ehs6qXNVYesddYw3owZYPTUZ/Grh7Jj/F4M8Esm+YPWfEe4pu5UUjlGuUCrBxyU0HeEjljJ4F0BX8K/K5GiAR5kHuzF5w8ole809skQtWNPLJWdcL/7eVbsuGgn3sOUP2hpYu+4VexJguSr1o+/S2CdLuey0itEJsF6uJCIq8Ux8HogcUg2jVBgvVzEVUyMgnlNp+/iow== 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=41QjC1S1t7lsapX3L9Nq80bSOzoRSt8WGAN7fsGmvCI=; b=PQRFO0AWcBDCWZN9cN/HdBUX18IPEysg1zernKsaOobBXec7ZYgsoszxzLlDraEkr4tz4n7s0lGIo8ErhkDpEusvI0t1JqUD3u8emu0iG7QqyjAGf14YEAKqL1EY8rwn+3gaCAG0UC4t56RAmEYnuWVuRYRbQO06OoGEdXtLuf63WYVcuLnJp7LH4mR1j0fHy+9tfHtIWvDPC1G5VwTejYYJQ4e79OzimLYJLf4JX3ceIv3QRSZ8fAC4QqQg3XiP7wf2oLaxmJGU259zBSRcQZgDXkQamYi0tAXyf91AdxDidghXSz87yybmDO2ZPJB4V4HO8zyvVEOr141iBIRpmA== 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=41QjC1S1t7lsapX3L9Nq80bSOzoRSt8WGAN7fsGmvCI=; b=0rx1Y4eYobu0zTktBo6CPgeRBXJ8LLnlOsZ+G2i0RupHtQlQ6kgzBbllf2/mZ9VVfO+/zZrIGPlYWKwhF838c2HBFj759FarqoGSCkFSB8V/lsdSIjE3LBjcpfifJFTAO+tA2EGB8NydPjlU/V+Mfw2MaHxFK0atuzfzhLppBmI= Received: from BY3PR04CA0006.namprd04.prod.outlook.com (2603:10b6:a03:217::11) 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.6768.30; Fri, 8 Sep 2023 15:02:48 +0000 Received: from MWH0EPF000989EC.namprd02.prod.outlook.com (2603:10b6:a03:217:cafe::d2) by BY3PR04CA0006.outlook.office365.com (2603:10b6:a03:217::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.31 via Frontend Transport; Fri, 8 Sep 2023 15:02:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989EC.mail.protection.outlook.com (10.167.241.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6792.11 via Frontend Transport; Fri, 8 Sep 2023 15:02:48 +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; Fri, 8 Sep 2023 10:02:47 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Fri, 8 Sep 2023 10:02:47 -0500 Received: from hwentlanrmb.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Fri, 8 Sep 2023 10:02:46 -0500 From: Harry Wentland To: Subject: [RFC PATCH 04/10] drm/color: Add 1D Curve subtype Date: Fri, 8 Sep 2023 11:02:29 -0400 Message-ID: <20230908150235.75918-5-harry.wentland@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230908150235.75918-1-harry.wentland@amd.com> References: <20230908150235.75918-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989EC:EE_|DM4PR12MB7719:EE_ X-MS-Office365-Filtering-Correlation-Id: 31b899bb-0333-4937-15de-08dbb07caa4c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DtMSl3AwRVWxYGgXCd+sygRp6a/4pn5WwTAwyipJ9BTNCROoixAbudjwxWg8O7HVyeB4YQGWoaffH0ntDRiunYQQ/XV3hwG+jE/V1yVcrg6PtIvFBlcFFc+7b+GLCMqDr9/N1rrxZ62PRge7Jm2wtc9AE2E/b2tZ7lFqp2DmufZaZCQyuFEQB3mNT8z6RQL5QghZvYwWnd0lIILmsNcNgbyybejD/28nrApVTmY0e7UIQUUG9qm4aeDN8eiZYNYiiIYg/EMYVA9ZU8X9Hii7DcIAJH/KoJrBFFwOia2RX+T+KhzLeCX9LH4dbHAtjObaHJQ+Bqt97K3THCIugCBC4xn2yJ/MfzZbPstUky9s7bXS713KZxXU5ABecpKij3pULuqF4vy9vAz9RPgfH8oKCYws/TuY+ucDzixPJHpxWdmuIrsflnuxJJMOiVBvepkK5Qr2UCACaBhkgWfCYimaVXq8HRp/9XvPNF+qvHo71+NsVg/pH065T6BZx4VqJd7+0QWMwNv39xU8iYBKjhbDOCAWEkFjTx2YepGqdxODKyCSp6/4HXFUKrNE2TOTyXpVaOugyCPiX6E8iNvHtxiTKPX8sujEDCFv2OPplX+pNjucR6IzgIBksxiVFC2vbXmn7FI/umc+Voyvf5WprQuALHg4Pu2hvg7xGCar0vgQ+scSaL9xIn8PXU1CeF4KQ+ZQLvdczG6XJQ1a9EZEpx3nbGVXz0GPZ+FbUNiTJ2nrZLAnCeJbQBC1QeV1FPRiQQozrRhHf/k7XkXkRCQB/kbj+w== 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)(82310400011)(186009)(1800799009)(451199024)(46966006)(40470700004)(36840700001)(356005)(6666004)(7696005)(83380400001)(478600001)(2616005)(426003)(41300700001)(336012)(2906002)(7416002)(54906003)(44832011)(6916009)(316002)(70206006)(70586007)(5660300002)(8936002)(4326008)(8676002)(40460700003)(1076003)(26005)(47076005)(40480700001)(36756003)(86362001)(36860700001)(82740400003)(81166007)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2023 15:02:48.1197 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 31b899bb-0333-4937-15de-08dbb07caa4c 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: MWH0EPF000989EC.namprd02.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: Sebastian Wick , Pekka Paalanen , Shashank Sharma , Xaver Hugl , =?utf-8?q?Michel_D=C3=A4nzer?= , wayland-devel@lists.freedesktop.org, Melissa Wen , =?utf-8?q?Jonas_=C3=85dahl?= , Uma Shankar , Victoria Brekenfeld , Joshua Ashton , Aleix Pol , Naseer Ahmed , Christopher Braga 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: Daniel Vetter Cc: Uma Shankar Cc: Naseer Ahmed Cc: Christopher Braga --- 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 51072fe2b548..9b01f234b04e 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -648,11 +648,17 @@ static int drm_atomic_colorop_set_property(struct drm_colorop *colorop, struct drm_colorop_state *state, struct drm_file *file_priv, struct drm_property *property, uint64_t val) { - drm_dbg_atomic(colorop->dev, - "[COLOROP:%d] unknown property [PROP:%d:%s]]\n", - colorop->base.id, - property->base.id, property->name); - return -EINVAL; + if (property == colorop->curve_1d_type_property) { + state->curve_1d_type = val; + } else { + drm_dbg_atomic(colorop->dev, + "[COLOROP:%d:%d] unknown property [PROP:%d:%s]]\n", + colorop->base.id, colorop->type, + property->base.id, property->name); + return -EINVAL; + } + + return 0; } static int @@ -662,6 +668,8 @@ drm_atomic_colorop_get_property(struct drm_colorop *colorop, { if (property == colorop->type_property) { *val = colorop->type; + } else if (property == colorop->curve_1d_type_property) { + *val = state->curve_1d_type; } else { return -EINVAL; } diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c index c028d5426d42..f665a12a214e 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 @@ -209,3 +233,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 Fri Sep 8 15:02: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: 13377587 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 11F21EE8017 for ; Fri, 8 Sep 2023 15:03:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F260210E8F8; Fri, 8 Sep 2023 15:03:01 +0000 (UTC) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on20605.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5a::605]) by gabe.freedesktop.org (Postfix) with ESMTPS id 78CB110E8F9; Fri, 8 Sep 2023 15:02:52 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jHsl4aWsG7LbxBhgRNxhH1qhpb+RixA2gxNEGaqe3no1S8SixoB/0wZUS0WBsFXjITN4EsonVPLFuR1g+DzxGwaiEwR57Aso8N+pimUkzCOjYGXCvle32PB+8cZFZ7vHOVpgQod2hNkdN2B8XMWqge7x36LJb9y3ySTf6uaiw3qYkeGKKOcDAtrkGGGuovQ6iCwDmGPMt7sOj4tCRc8MAXtLdrRdcU0I8YvBQZvWXoakZH8AGXILSYq0wkBEX4+Tkf2SEjj1LuHj0yVE7iXNl6YfwxaGbXMZs6EX1BH4FhZkmJ8PzgvoB9SmEEBGW1nRF9ZcGxbv5OFNlHIduiD3Mg== 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=66lS1MEI2rYlJj9vK3IEjboXjMxGBH8hwv9DGYahzDo=; b=EP3gWwZcimdWxisHbDHQcp+tYPSM3g8rq4/zyX/iBHJUjt6xrb+tBSjnYI6DstLKR+6xGsRryvKy7E1WGoC5/TBjzcN9Yj22Nn0+ZDGHmekkh3Bh1BOqZWX9HKj+qOLnMBelXkBtNG7UlhS00InDQtfH4cJOBC1+ixkp0RdahAbiYQkVmQDJ0+HRWZro/EW+v/MZBDu8SkA+1kcSNKBediBeIM/bbRfLkgO0g7SF9pT2SYutMn0htqW7vy37g9TcKvDcrpCrVi3Cg2CPldWhszvX3hOttaUNptDDHcDybK32dqDyHKiA//mO7M7406poZyyQAwOVzm/s/vQziFF1fg== 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=66lS1MEI2rYlJj9vK3IEjboXjMxGBH8hwv9DGYahzDo=; b=EjAqIByPMwC0HLvNaulfGGRsGIkmugBqEniyeUQ/mJZ6bR6nhE5Om+PTApPaUaHUXfyuB0K8QuMq3fRauUJAt9kR6Fqwwz1CK+PwVFCApun2i4SByz1AEX3ompzbqBAXhEHYPw0TtxPKSHKXhhL4Q6nFIW7AxgTBivsFLoYVp2k= Received: from DM6PR11CA0050.namprd11.prod.outlook.com (2603:10b6:5:14c::27) by SA1PR12MB7410.namprd12.prod.outlook.com (2603:10b6:806:2b4::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.30; Fri, 8 Sep 2023 15:02:49 +0000 Received: from DS3PEPF000099D5.namprd04.prod.outlook.com (2603:10b6:5:14c:cafe::48) by DM6PR11CA0050.outlook.office365.com (2603:10b6:5:14c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.31 via Frontend Transport; Fri, 8 Sep 2023 15:02:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by DS3PEPF000099D5.mail.protection.outlook.com (10.167.17.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6792.11 via Frontend Transport; Fri, 8 Sep 2023 15:02:49 +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; Fri, 8 Sep 2023 10:02:48 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Fri, 8 Sep 2023 10:02:48 -0500 Received: from hwentlanrmb.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Fri, 8 Sep 2023 10:02:47 -0500 From: Harry Wentland To: Subject: [RFC PATCH 05/10] drm/colorop: Add BYPASS property Date: Fri, 8 Sep 2023 11:02:30 -0400 Message-ID: <20230908150235.75918-6-harry.wentland@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230908150235.75918-1-harry.wentland@amd.com> References: <20230908150235.75918-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099D5:EE_|SA1PR12MB7410:EE_ X-MS-Office365-Filtering-Correlation-Id: de1e2a08-5660-498c-dab6-08dbb07caad9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XjYu3lFtp6rl9/LsuVPHBU/qIYLG684TwVSOxtaDWoZSVTRGryA2HaN3ao/Y8VimjmUxTSydHgS4nY7MEgWThyBdOJU03izzYoQFYcLKwzmIMkMJCRa3Ryv/ya8rjFoGQtzuVpferVCUP4h2rxPJnX63xtyx3W+3j+QKeBIc2LQQ7OUGXxUCvfZzDZlJs/j4ZWjnlZxJ/o07vYR9JOox1e6W+JRFOgkODLrLvm85k1EBCznk06WNfK7Si0kfB7OxiPbQXRJACew0Pli05LDwyp9zpI630Twg7oz+VL50yi6Xy/vC+sy7nOl86z1/8RxqUK+dWhNxqdKzUy/SEwU8aOcUi9Ru5OTSyqRa2jQVCnoGTabS56mz6NbR+avvracDxiTI8xx4IKa82bNo1+x9tshMIqbwS8I7p2J40k5qwRIaoDNmwVwXHdR9CNuz7f9G7cMXux7QF6V6lxl9y5vWsir1ISXupYF3WHi5Z2Vs4NluA9g7jWQTNZthi49K/qZRblfTWvdE081/7kJTIOGhbv1OlxucDLDD41vvXgSKS9Y5g2LreMNH6uNVmjnfKlrtVlMbG/en1Bp9YPPqxESGbeuZqfy/+pBrHy5FSABmKunXcVjU6XUGIOqBJJpQ7qlTd5Ld2P7NGuKy5UkWVCVz4zjDeRQFhKR8I4DwGHoXatasqyH6FrHgvNfaMbtc+XC/LTMYvryRbCwdr4UKDLBI7KPuhhxge2Mi9ErEN9f+JtcAe1ANiFC4xUUJgZd9C17qmL/CJxALix3mkboNDII0Og== 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)(39860400002)(346002)(376002)(396003)(136003)(186009)(1800799009)(451199024)(82310400011)(40470700004)(36840700001)(46966006)(36860700001)(40480700001)(83380400001)(81166007)(356005)(5660300002)(86362001)(7416002)(36756003)(44832011)(26005)(40460700003)(66574015)(47076005)(41300700001)(82740400003)(70206006)(6666004)(426003)(1076003)(70586007)(2616005)(478600001)(8936002)(4326008)(8676002)(54906003)(316002)(7696005)(6916009)(336012)(2906002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2023 15:02:49.1113 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: de1e2a08-5660-498c-dab6-08dbb07caad9 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: DS3PEPF000099D5.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7410 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: Sebastian Wick , Pekka Paalanen , Shashank Sharma , Xaver Hugl , =?utf-8?q?Michel_D=C3=A4nzer?= , wayland-devel@lists.freedesktop.org, Melissa Wen , =?utf-8?q?Jonas_=C3=85dahl?= , Uma Shankar , Victoria Brekenfeld , Joshua Ashton , Aleix Pol , Naseer Ahmed , Christopher Braga 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: Daniel Vetter Cc: Uma Shankar Cc: Naseer Ahmed Cc: Christopher Braga --- 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 9b01f234b04e..ca3512038d4c 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -648,7 +648,9 @@ static int drm_atomic_colorop_set_property(struct drm_colorop *colorop, struct drm_colorop_state *state, struct drm_file *file_priv, struct drm_property *property, uint64_t val) { - if (property == colorop->curve_1d_type_property) { + if (property == colorop->bypass_property) { + state->bypass = val; + } else if (property == colorop->curve_1d_type_property) { state->curve_1d_type = val; } else { drm_dbg_atomic(colorop->dev, @@ -668,6 +670,8 @@ drm_atomic_colorop_get_property(struct drm_colorop *colorop, { if (property == colorop->type_property) { *val = colorop->type; + } else if (property == colorop->bypass_property) { + *val = state->bypass; } else if (property == colorop->curve_1d_type_property) { *val = state->curve_1d_type; } else { diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c index f665a12a214e..409df022b256 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 Fri Sep 8 15:02: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: 13377585 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 731CEEE8012 for ; Fri, 8 Sep 2023 15:03:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 32B7310E904; Fri, 8 Sep 2023 15:03:00 +0000 (UTC) Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2086.outbound.protection.outlook.com [40.107.102.86]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5C16C10E8EB; Fri, 8 Sep 2023 15:02:54 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZwobJqS0Pex360jeb/vkXyhmtIZawM8YFzC8pFHA1Q3wWPSz0j+GAbzmYkS8nbp9dwswHW51mjCI/7PrVxBlRe3W8e/oryx1l+EkPYyje99KKi+LnFl4IGPd8IBl+VK2qgFpvDlt2jIwVSIipcNpk1o/YYaQBcE4qVer2QxFkPMi25C/CuPpz1OwJm6yXHJk40jz+cfWzImWeldnsdAJ+Du1yXyRhNT4x+quPN4nOKU4AlrP3y4XNX0ITt3Q66D8jcZqW5ZWNwgU7JEWgOGNlL7IapwKETng3iWrwpLDnRSTcuOBEqloSf1qr70MF4ZSHEr0/+pTC5PHHTUOwOe6bw== 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=+AyHWE16a+ZcbZwTDyfYyqBwyEeb91a2io25NiAzqmI=; b=LCVriEwS/idl0TXst7al5rCqk2YzOU5SJ2jWoQuk71tCU0KJ8hZbc+8UjmERKyhi4pWKDzofK1EbSm6mUhbhngA41ugCMFTy25XIudkvhzaiodW7tkdN6FM4dKhvod+lqoUvfnObEG/opAuxuehhqPZHCcwkJv5jCysTWjnasO+7qxPOyz+ErF/BunPSFssArFoW2vXeasjB3tmvBIJvDdi9UZCEWHNE0kp105Ju/3aZz0gqKpDfs4oq9TnTuYVYuUZIvQdXa6bM3aztpVYACApW9NJaTM1QgO4Q59qY4BpDizbmN+8vkzXtC+PvmbNYPGBfId1WMY9MfXuQcfAS8A== 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=+AyHWE16a+ZcbZwTDyfYyqBwyEeb91a2io25NiAzqmI=; b=FAXbADWT1dUMBfY4urhVVRAGr/UBvmb9iFGezbo/fQWA7rvLm1VT5DUkHFns3tvcRQoavtKNybVTM9ZuoQEnXtudRIvvsY5lVcq3vyPLaujsyEpW3Tkgbwr92kIuSlobA/tW/sqH5LkshszwzoqVjpAp0PxHuE7bQ/Iq6sxsCy4= Received: from MWH0EPF00056D0A.namprd21.prod.outlook.com (2603:10b6:30f:fff2:0:1:0:a) by PH7PR12MB5783.namprd12.prod.outlook.com (2603:10b6:510:1d2::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.30; Fri, 8 Sep 2023 15:02:50 +0000 Received: from MWH0EPF000989E7.namprd02.prod.outlook.com (2a01:111:f403:f805::) by MWH0EPF00056D0A.outlook.office365.com (2603:1036:d20::b) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.9 via Frontend Transport; Fri, 8 Sep 2023 15:02:50 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989E7.mail.protection.outlook.com (10.167.241.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6792.11 via Frontend Transport; Fri, 8 Sep 2023 15:02:50 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Fri, 8 Sep 2023 10:02:49 -0500 Received: from hwentlanrmb.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Fri, 8 Sep 2023 10:02:48 -0500 From: Harry Wentland To: Subject: [RFC PATCH 06/10] drm/colorop: Add NEXT property Date: Fri, 8 Sep 2023 11:02:31 -0400 Message-ID: <20230908150235.75918-7-harry.wentland@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230908150235.75918-1-harry.wentland@amd.com> References: <20230908150235.75918-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989E7:EE_|PH7PR12MB5783:EE_ X-MS-Office365-Filtering-Correlation-Id: e3a05d02-abb3-439a-1836-08dbb07cab9f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gdOexHxuQc/fo8+cQ3X6eZSYnuOGmzubk9oNJAONiuZZDOup9PEhCIhjIWCUyZ+89nr4OQa1/ojydJ36JdM6vPzL8DXOjFex8NkEBjcJU2nvmRBBwG8cgAJYDskqCyO8PU7TdAL+OO+5DUWWBJGxVF3oOZfHBuV37q0cvN6pvNFRsiCrhh/tD3eONiWfAJTdRcfN9UECX86TQLjOuNMDgRjXqokn+Q9WijIIYVI7HSLHoY/WIVz6FTCM6MjvhjT8RUkQT9LsQeZ14M+4udzaxw2fuhfZ7M0mKjR/N6ZW5sLiTfY5yqLSRerCpLA2W8zI1ZHDOhYsjaJ0DGJCZpor7IEFXRMRS4XyvggLu+7edLs9ag5SNNT09nIFgaYTdae0mNYvtXFDSRnA6eUnyAkdb2Ydhr4dmpdzMxsqQrDTMViDAbWNhAqioNf6rUUCasRKntfVWU5npf6roUSVIkefwAE38gunrt9rwfPvbv+Mo9unkbT4niGSxuRcJkMvnhFyIPogSDpCjroVYdYAcXI8Frq6wYk1gxpgbIJusTJIRT40IJOwOsycwujgSGBpt1aDZZshW4hrialvMuV4UxByh6DHLv2HKZ9x+wguzy217XcyHAJXEQVQmxXKXcKmq8Ax34uRXPo1Ex0x3hys0BmT/M+o36tekixma+8YHhfILW9V1YjgiBojM9FRhxtmXXxL/eT9a6ESrrtYtt91kFGjlugv2B+4Mx+1Nh0FM5mDGAItLaCWIyEsRvoGkY+5dL0NJJe05Kj1iEa7kWyDL73jGw== 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)(396003)(39860400002)(376002)(346002)(451199024)(1800799009)(186009)(82310400011)(40470700004)(36840700001)(46966006)(5660300002)(44832011)(4326008)(8936002)(8676002)(7696005)(54906003)(6916009)(70206006)(316002)(70586007)(41300700001)(478600001)(2906002)(6666004)(1076003)(2616005)(426003)(26005)(336012)(47076005)(7416002)(36860700001)(81166007)(356005)(82740400003)(40460700003)(86362001)(36756003)(40480700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2023 15:02:50.3258 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e3a05d02-abb3-439a-1836-08dbb07cab9f 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: MWH0EPF000989E7.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5783 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: Sebastian Wick , Pekka Paalanen , Shashank Sharma , Xaver Hugl , =?utf-8?q?Michel_D=C3=A4nzer?= , wayland-devel@lists.freedesktop.org, Melissa Wen , =?utf-8?q?Jonas_=C3=85dahl?= , Uma Shankar , Victoria Brekenfeld , Joshua Ashton , Aleix Pol , Naseer Ahmed , Christopher Braga 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: Daniel Vetter Cc: Uma Shankar Cc: Naseer Ahmed Cc: Christopher Braga --- 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 409df022b256..a92e170aed87 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); @@ -263,3 +272,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 Fri Sep 8 15:02: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: 13377586 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 94711EE8015 for ; Fri, 8 Sep 2023 15:03:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D497910E8F7; Fri, 8 Sep 2023 15:03:01 +0000 (UTC) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2075.outbound.protection.outlook.com [40.107.220.75]) by gabe.freedesktop.org (Postfix) with ESMTPS id E5CB610E8FE; Fri, 8 Sep 2023 15:02:55 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A8IM+92HzmCsfVNdrR3CRlNWnp3hDH5vUq5SmDN6QpyRW/7Uo15qxKXAYAibQnrr08q5fgzc7i66FCTEBMrLZkaAnDPl1vVxCWFd1FOjN8tQ/RdVzV/GUvfxFAbN+5tUd9KRs5dYZBj5cyxZqU+30LVNruOZLYBGA6cSQTrEv93ng0altGfHxWDGqHdzMvSZnwER5E35ifJfUutnVYmV+0b/70wcK7jO2rlR+pNuQY7YHTq4pPfCXhNPu9I6husikSNG4QpJbm8AvRssBujzx++3SYQUYXzsl/fTzt9M6GY70mEucYtULTCanoRHr78hSrWDN3Mp9TJClxuVpUuupA== 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=WcBeEZR24iop6aSPJ/uUkzZLABNZg8y7n2sE524BbH4=; b=bqShl9okSD+e+qx25qfFLalLCUR7Z9Y8lRvXh7qevJq0eDAhscghU1EaOSSdo21767bA3yVRy2BgVUT39cgRLuE3HJGwn5MJccHCT+ewe8B3d+dopIyw6sMrDt7s5SvWgRWWRmgVwEidaApQ/6ZrKWrcWJ0d4cKpbtHFCyKqW2Gk+MTXgDj2lz+VFKNalxeLDLx+3HUifKzH7aAZ4rRSUJudo8rbs5EOw908TZaKOXYOPrQQ5b9P2L9AbthuMxW5T58AQZXp5Xz80KEMvPGVB/8MRyVtJHfVRsqLrL3zU6NJkioEyIYRRU++5iEkmFRBADBJAuiUABr+435HBrcOFg== 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=WcBeEZR24iop6aSPJ/uUkzZLABNZg8y7n2sE524BbH4=; b=NzD46QfFytRY2lCWxn3MmDww9UHEmP+YVVKUt3JLx/Am1XpfosaUv0qVzt6WG+pM4bxvBSPsH2We/uBTv1+aaf16ob9T96P1HGu4ZW17xwg9kcvWCGTV2zyDbyDdNKFxanU6NdCveOQeJyblTOMP+a0mXIfHC1e399aFUgyNG4s= Received: from MW4PR04CA0381.namprd04.prod.outlook.com (2603:10b6:303:81::26) by SJ0PR12MB6878.namprd12.prod.outlook.com (2603:10b6:a03:483::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.30; Fri, 8 Sep 2023 15:02:52 +0000 Received: from MWH0EPF000989E9.namprd02.prod.outlook.com (2603:10b6:303:81:cafe::c8) by MW4PR04CA0381.outlook.office365.com (2603:10b6:303:81::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.31 via Frontend Transport; Fri, 8 Sep 2023 15:02:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989E9.mail.protection.outlook.com (10.167.241.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6792.11 via Frontend Transport; Fri, 8 Sep 2023 15:02:51 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Fri, 8 Sep 2023 10:02:50 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Fri, 8 Sep 2023 10:02:50 -0500 Received: from hwentlanrmb.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Fri, 8 Sep 2023 10:02:49 -0500 From: Harry Wentland To: Subject: [RFC PATCH 07/10] drm/colorop: Add atomic state print for drm_colorop Date: Fri, 8 Sep 2023 11:02:32 -0400 Message-ID: <20230908150235.75918-8-harry.wentland@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230908150235.75918-1-harry.wentland@amd.com> References: <20230908150235.75918-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989E9:EE_|SJ0PR12MB6878:EE_ X-MS-Office365-Filtering-Correlation-Id: ef1bf953-3e93-403c-133e-08dbb07cac74 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HgZTisgQU43NgA60IIlunKJeDZrjC/sqc+PbjC7SeGJsucaFX5ujZkf68O53I6hY1GC8yKTklSGlmTfRXsJJW+IlZ4BwQdOS1aJCa8rOvcC+fYiAEgSnGuBM+xcegbsHlmgNKd4kwZdZR+NYclqQcB1HUhT2YVmRCNpEn4Gm5nrab+v8VdV067X3ofXbCUxMzp07kvSuj7KPLrujDhLJ3+lIychPuza80vln66ztFOqiR1c0LF5FSuGJgczyvBcGY6ji8oc+OyfDd2pX6/GPx8SkWPcpB4lxLpea75giidpJfm7CB38jFK5sXzOVIZROMeE5KE45329Pwy/Y1MYOAwY5SGzhPqtEmYF0EWkGvtEsIOTs7aizfJQu8sVqRjgrxVGwMBohXHAxMzjnr7Tavt7/cLPHBiYzXdUxj/4JnEXNvssP6iIOMH5YXCWou/8uUQijR/8+9pkFJN60z/2jGQcMzXeg5yEUPB/6LecwBiM4UBXx8K8re5OdfmFHMiFXRlK7037P9O0E5ND4JEUQNTa9jRdB0HdqU47awf1Tk32Hds9E0orZinwTRJFzrpoi+PHFfem/LvSC+pmlOHewqVdpsMcjbaA4fh/fDz/NGGt2vlYPNlgWGAQtrNFM6Otwus/3ENKrOPKTsLVTMkBlUVIsm4XgTK0GsyTonLgDPAnaIe2hmm9vY8iG9PIh7owUVMp3S1Q3pnF/CkYncHLUlYH9GvBTzuGs4oXFAr0ec0dXSwtNZkc58QbBmtNyw87JZ9F/kWR1v4P/Dt2chyaEEg== 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)(346002)(376002)(39860400002)(396003)(186009)(1800799009)(451199024)(82310400011)(40470700004)(46966006)(36840700001)(81166007)(356005)(7696005)(6666004)(40460700003)(86362001)(40480700001)(36756003)(36860700001)(82740400003)(47076005)(2616005)(66574015)(26005)(2906002)(336012)(426003)(478600001)(83380400001)(1076003)(8676002)(70206006)(4326008)(8936002)(5660300002)(70586007)(7416002)(44832011)(316002)(54906003)(6916009)(41300700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2023 15:02:51.7059 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ef1bf953-3e93-403c-133e-08dbb07cac74 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: MWH0EPF000989E9.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6878 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: Sebastian Wick , Pekka Paalanen , Shashank Sharma , Xaver Hugl , =?utf-8?q?Michel_D=C3=A4nzer?= , wayland-devel@lists.freedesktop.org, Melissa Wen , =?utf-8?q?Jonas_=C3=85dahl?= , Uma Shankar , Victoria Brekenfeld , Joshua Ashton , Aleix Pol , Naseer Ahmed , Christopher Braga 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: Daniel Vetter Cc: Uma Shankar Cc: Naseer Ahmed Cc: Christopher Braga --- 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 8a5f8cd22c8d..30308b8dec53 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -783,6 +783,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) { @@ -803,6 +816,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); @@ -1779,6 +1799,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; @@ -1787,6 +1808,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 Fri Sep 8 15:02: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: 13377588 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 4CEB2EE8014 for ; Fri, 8 Sep 2023 15:03:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0474410E905; Fri, 8 Sep 2023 15:03:02 +0000 (UTC) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on20628.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5b::628]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6ACC710E8F1; Fri, 8 Sep 2023 15:02:56 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JRqN9OaLbcRSyKn5lfYLulvIaZRuODg8KZfyLBKwSWhpLtP/rWbpSd8YFmS+mi1TVy24D6EfZQJE431HbK5+NIFjQjDyy5uTuazhXYQrT++/XEEfNhlj39yy3trFNAfvBj83zz+xoco8Nzm+bP1vfas9rCid8PnTFFXUy5GuZvQ36+7zMEpYFh7oEftyoRfRLmQ8uQ521rYrkBQwxlYhYikBE7xD9ResR/hsp5uuK/yb/VHWGb6kFJSzka1C8H96ibqQrzmdKrrif3TobgkrbYKyCUqMok7W7gpdr578LyeqWFQIbPpvYtayi4mDfbRIRsQ5A92wckCb4rl0h6TRdw== 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=3D5Jt1c7JI9CLrV45yQgYx38Kjq6kDB1Ufl55t1Txr8=; b=NuORVZTjCJnbLuGKSOXUJspAdxjZtMYoh2PpG8SGkJ6eCHAigvKJIOiIipdmYyLNHeDdqntIS6sE+PB6KIWWTFsGP9fQg1boda9lcLZ89DGq5TOL4dviD+AkG3wdLZ2JC1+CULQbjWPOANm15081MHdR0Cx3Y+MN0f0ImeeIuutBIxrc6iYeT8Eg8juDXUtM2c6NuxaZmjIJ0i+0ZYpzSNAD5iuaWImq4wy45Cp4JmOa5UwXMqyXe+MGIGgL0dEy/F2K9rpj5tluLME/P5QtI1dC8hp3LrRvYCdp5N3hiPx2gGbXb6Ta1wStbMX0+t8rKNzLY8mhMiD0Z0BdSsLt9A== 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=3D5Jt1c7JI9CLrV45yQgYx38Kjq6kDB1Ufl55t1Txr8=; b=udKnbXmB0Ki5vd/KnWrVztdWNzDVqUUzhek7t4FFZeWOycZj/4z9RKGKrSyn/WN/qEJ4DLQ5b6syL+c7hL/swViVl+2W5tXWlPkUBiAnmpIjmpMMwVX6neoo7CKof7MlRnUMcqLWWcf39oFtU2duDrFJWZm9/UpR7XiczV/dYJ4= Received: from CH0PR03CA0444.namprd03.prod.outlook.com (2603:10b6:610:10e::12) by BL3PR12MB6642.namprd12.prod.outlook.com (2603:10b6:208:38e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.36; Fri, 8 Sep 2023 15:02:53 +0000 Received: from DS3PEPF000099D3.namprd04.prod.outlook.com (2603:10b6:610:10e:cafe::39) by CH0PR03CA0444.outlook.office365.com (2603:10b6:610:10e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.36 via Frontend Transport; Fri, 8 Sep 2023 15:02:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by DS3PEPF000099D3.mail.protection.outlook.com (10.167.17.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6792.11 via Frontend Transport; Fri, 8 Sep 2023 15:02:52 +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; Fri, 8 Sep 2023 10:02:52 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Fri, 8 Sep 2023 10:02:52 -0500 Received: from hwentlanrmb.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Fri, 8 Sep 2023 10:02:50 -0500 From: Harry Wentland To: Subject: [RFC PATCH 08/10] drm/colorop: Add new IOCTLs to retrieve drm_colorop objects Date: Fri, 8 Sep 2023 11:02:33 -0400 Message-ID: <20230908150235.75918-9-harry.wentland@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230908150235.75918-1-harry.wentland@amd.com> References: <20230908150235.75918-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099D3:EE_|BL3PR12MB6642:EE_ X-MS-Office365-Filtering-Correlation-Id: 845e55ab-afc9-4cb3-ccb8-08dbb07cacfb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MJcCo+uTkDVgY0YPBSeXKEUGP0jjhwV0RrY5hmgnSb+GZz6ARSduEM+Nh2WDNmnTeTlWerDMoM5ckMPaPezbQaULxQg3nNVN8OEY/J3QIAI4jd2tMGI6B0FEirgQlhNtmczkd2mMo/j9+c+om2p/H1kWXL5RI99q3ljjOnrXxsGU8Q/aFg53ppicYPBVmeHHIKXtSPbEcyNpHU6l16JTQiyXE7Pa7oENzUIO/ZN6PQkhJbgKE9Lwj2CYpdwFE8dinTynPMw9HPVPgAcsGRvGpaOVXUkvRusyAGCrCzzKl244MpF3thy3pJeH/MUnuiSfBkd2vfY3mdqb3KL7QDjFAYQRyLJ1Km5qz+hM48xCLjQjaMiSbwArovX4KiwWQYsqvnWXTOVTnWYPr+QTH1MLlQmC3zgTErHE1Xd5BaeXUHmzCYKM9BwKoHttsSHM9BC4h9XwsqD2MomwpZcLElbNmgzthvgAw8QXEb8lfNUV8v6lyVWeAUaVZHA73wzngfepQ5WUgPMLi/9i7j6TRoR4uEDolY8pBB2/Icgvg5yJbfo56+66blkqag6VWaHv8ilZWRSVt4OOHocXgohFFWO67m7avGWGbfgYLlzsTopo32aha6KZkTMLXFpLpJKZ7RB5xndNGlGoncG9JuYp4PYiRc4tWj4elwD1W/qk587ig+7+OqNE2G0r8hJRbjKbOJTSnwuofDWcAON2KsDdl2eeMgWdp7njbfIld80eiRK3bz4seWgi0g6MTtujznZLgdHLdyXaAOEptNZ3+U3HhVhUXA== 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)(376002)(396003)(39860400002)(136003)(346002)(82310400011)(186009)(451199024)(1800799009)(36840700001)(46966006)(40470700004)(356005)(6666004)(7696005)(2906002)(336012)(478600001)(1076003)(426003)(7416002)(6916009)(44832011)(316002)(41300700001)(70206006)(8936002)(26005)(70586007)(54906003)(4326008)(5660300002)(8676002)(82740400003)(40460700003)(40480700001)(2616005)(47076005)(36756003)(36860700001)(86362001)(81166007)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2023 15:02:52.6892 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 845e55ab-afc9-4cb3-ccb8-08dbb07cacfb 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: DS3PEPF000099D3.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR12MB6642 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: Sebastian Wick , Pekka Paalanen , Shashank Sharma , Xaver Hugl , =?utf-8?q?Michel_D=C3=A4nzer?= , wayland-devel@lists.freedesktop.org, Melissa Wen , =?utf-8?q?Jonas_=C3=85dahl?= , Uma Shankar , Victoria Brekenfeld , Joshua Ashton , Aleix Pol , Naseer Ahmed , Christopher Braga 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: Daniel Vetter Cc: Uma Shankar Cc: Naseer Ahmed Cc: Christopher Braga --- 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 a92e170aed87..fb85b5c41cc4 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 501a10edd0e1..b68e05c2cf57 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 7c9d66ee917d..a3c137ac88c6 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -716,6 +716,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 6dcf628def56..9e37eec55291 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 Fri Sep 8 15:02:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13377590 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 3A699EE8012 for ; Fri, 8 Sep 2023 15:03:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F17F810E8FE; Fri, 8 Sep 2023 15:03:10 +0000 (UTC) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on20626.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5b::626]) by gabe.freedesktop.org (Postfix) with ESMTPS id AA04910E8EF; Fri, 8 Sep 2023 15:02:58 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XqwFqqo94ewJzLJAChDew/3/66wEgNTMQOUM9rUB/wvxO/ea+eQPFL4eZhQLqGi9D8ukR9+Q5gTDIMdEmM3JI0YUsgTCQbQR0kDDT9DFYk5XZW2uQe9k0ydyh7hdVaNpOWeBwsLQVOxsvGstTVBSKOJgp0y/j94Al0D0W3KVNP2lBQJyMOPbJ64AFuPJc9btQri86xYQtOYO08DkAQE9MDzwSYp+7UOFHZtTkMYRc8TppvgcjxvH4MsJet5STaIfq8HoJg1UnRosKwl0pU4X4UwypP7vo2fjevdqZYse5OwgGBaFoYpOdBOGAmWbjbX3C8lWkfsC52Ip+nK5g7dRgg== 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=ZCXXubHKy2uOJ1uZFpDSgtKmtmpCztiSWo3FrpanB04=; b=mKfmdVZgSZCl0/eYNtLRhwp4BH8/3SXbnQXlBNySkm52S/RfZlWP437LaNnqt6BLROJuIpB21obaHwzg4Eh0QQLgbRwf9YSPcjBeNZrcJtqmBGOSvA7FjbY5KZMGoc5wffg2ILeewpQzZ0/Kai1aop6y/mTGibyG19uushGPVQpeliyVbqGBNsiKOuj6DIch9GjM9U/Jo7epXT+eCeRYHnoYtmCbw/SNAA+gH4oyFq0i2lh/apOcWaVFNP28T3/Z60tnwb1tu8L07wZQvZ6IDtiInEwpGsXi05ryyKwo6qKzw8902cZUVR36i42q2RNrbkkCa/N2W4C1mdbvcs9rYw== 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=ZCXXubHKy2uOJ1uZFpDSgtKmtmpCztiSWo3FrpanB04=; b=pGUljY2TQF9LrbPvtu07/b3QwO/mXXaVnm6qK6g+9rS7HPGemlSqFXG5h2/l75gWRvnsG5wjBM9EIjPpHHr87aWOANPQARFfMlIYKVXCMUYzdp8rvwu6OtSbT4ARkYK0igjFPN0cTAOQrkgjJGeeMU5PKPTFFT81MMaHu9OxyLA= Received: from BY3PR04CA0001.namprd04.prod.outlook.com (2603:10b6:a03:217::6) by PH0PR12MB8174.namprd12.prod.outlook.com (2603:10b6:510:298::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.36; Fri, 8 Sep 2023 15:02:54 +0000 Received: from MWH0EPF000989EC.namprd02.prod.outlook.com (2603:10b6:a03:217:cafe::44) by BY3PR04CA0001.outlook.office365.com (2603:10b6:a03:217::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.31 via Frontend Transport; Fri, 8 Sep 2023 15:02: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 MWH0EPF000989EC.mail.protection.outlook.com (10.167.241.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6792.11 via Frontend Transport; Fri, 8 Sep 2023 15:02:54 +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; Fri, 8 Sep 2023 10:02:53 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Fri, 8 Sep 2023 10:02:53 -0500 Received: from hwentlanrmb.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Fri, 8 Sep 2023 10:02:52 -0500 From: Harry Wentland To: Subject: [RFC PATCH 09/10] drm/plane: Add COLOR PIPELINE property Date: Fri, 8 Sep 2023 11:02:34 -0400 Message-ID: <20230908150235.75918-10-harry.wentland@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230908150235.75918-1-harry.wentland@amd.com> References: <20230908150235.75918-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989EC:EE_|PH0PR12MB8174:EE_ X-MS-Office365-Filtering-Correlation-Id: 941dd3ac-5530-4a4c-ecdc-08dbb07caded X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zmUgyZ0SSNhtm+++adXln1m3j+/cTuTN4INqb6qTngXnzaUWHcWw+kyNna1pxfssxVmXDZwawjKUxTmWKS2Tl/Jl5tHwdbFTzlErpAKWNmugjsUXrerueHet9r0Yt0inn/oFGDAp+51nFcbkTjxn60fupbAObEMx+vx485ZTDkIdDZqhlmHfRKzdn+NX1A4XpPwGVkIu0YOdkLSwzCFgaEx+EHb2mM9m5GNsBn6yU3uTBVLJ9ATmixoKPsVqoGv0Lf2KtIIpaQMBPtzHrOJDoSyB7GOxvXKi43x3zb9agMSQePPeHW+h/BKs2lr+5u5y1T7eOZLp5c2RE2Ofnecl8Q14HBQbiVFFDPqPvWjY9p/sDYVyTtZkRgqm8qulwHZQVOcCGHtEjOht5e3RUPMRvHGJP0ewa53mpMOyRNSVcIrfkFrjzAfnV6NLNuIsspyGGmSOxudEG+lB1V+HOInPO5mMD5EvS1DRFS/mngpXKckspSpElYBqEoygUh2EfoVNeMIIvN/3aFULdPiXpLglCf1K4ZbIAJJNn1be8FQRuQ8SkFlc7VsffpRcRx8hF0Hthb97Y0HVDpW7rFYk10OxmaX2eLNiiqC1/GX5Fvk3YqoCqD3ZJMqIDQrUnpn4yMC90nLBcIB+itIdIqRu+r4lmYnzBeEIY+04yYKMikaMy+THExqysY9l0Uz21/B5TN2f/GwzkpQ+XHQJyxG7JJOroOue68MEtF8iCBwTtDxUOP+t/w0Dicx48dMMdUxnRDL47C5aDgFNMbVx0TgsZD94VQ== 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)(1800799009)(82310400011)(186009)(451199024)(36840700001)(46966006)(40470700004)(356005)(7696005)(6666004)(83380400001)(478600001)(1076003)(2906002)(66574015)(2616005)(426003)(336012)(44832011)(41300700001)(316002)(54906003)(6916009)(70206006)(7416002)(8676002)(70586007)(26005)(4326008)(5660300002)(8936002)(82740400003)(40460700003)(81166007)(40480700001)(47076005)(36756003)(86362001)(36860700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2023 15:02:54.1822 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 941dd3ac-5530-4a4c-ecdc-08dbb07caded 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: MWH0EPF000989EC.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8174 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: Sebastian Wick , Pekka Paalanen , Shashank Sharma , Xaver Hugl , =?utf-8?q?Michel_D=C3=A4nzer?= , wayland-devel@lists.freedesktop.org, Melissa Wen , =?utf-8?q?Jonas_=C3=85dahl?= , Uma Shankar , Victoria Brekenfeld , Joshua Ashton , Aleix Pol , Naseer Ahmed , Christopher Braga 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: Daniel Vetter Cc: Uma Shankar Cc: Naseer Ahmed Cc: Christopher Braga --- 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 30308b8dec53..a8b978e8f3eb 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -1403,6 +1403,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 ca3512038d4c..44ceb10acb6f 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 @@ -563,6 +595,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, @@ -629,6 +671,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 cfb8f46b94ab..9c6961743a68 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 Fri Sep 8 15:02:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 13377589 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 8AEE6EE8012 for ; Fri, 8 Sep 2023 15:03:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 59BEE10E909; Fri, 8 Sep 2023 15:03:02 +0000 (UTC) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2069.outbound.protection.outlook.com [40.107.93.69]) by gabe.freedesktop.org (Postfix) with ESMTPS id B39E710E8F1; Fri, 8 Sep 2023 15:02:57 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Udjkr6ClaK7I9hNQaLf6tGrF/pIGBPHqlymIcyLAuPw5uKPtXins12JhDDd+YepzEkQ6fKRedOut0Iit1r6QIkMtUq3+qrdn4Wsy5OyxRK3eX9VE3DGblq2pMrzZlUm78eF1q0ylIqqpgzAF6RqywzFODbYXIIoAXlwceCIuSxQAkD+o1n1/RtgYNl89aXSWJF0Zexxm4Qx/UvHVTAhBgLn417qUclgkzkY3t5ihNKvUcVcygtzDkqyO9EPpjqMkAvqUxjnWnY3kjyn2GM/gtnWBlPhgyQEJPjmx5HL5kUJ9zC9hui3jlt4/Pw/Fq6qUqD/0BmJW3DYp1jcW4Atrlw== 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=Ln/kY2dEO+CZorZvAmeVw4PalDK5U1+UI8nmy/1w0GY=; b=OELcJdVmBOBgTvII2uAxCeUknz45Gru5O5/Jk3hd1hiSxi3e8ShfqDZUQk4410z0fMFIvm62NdEOXjrMwl5lYg/RtW3impRWV07J4KS4Edlwv2dooJ3fpwAmMeaaSHlIq+fGEx+fiJY0H6inHNk3G4G9XqVY9eZFj0p/cP+cOGIYXfUfOx3GZCuECYQjiipiZLev8UQpJgkKSvDU9x6zrAM5SoOtm4rMxsMcA6aymRnYQkuIjD5FSEA50WvkrT5aR68LwqYkdMZRbE7FxD+Z9fVGO6wBqbniW+2W8LFLtOL4mYGh/4q8vbcUtu5o/dzhwqo6fR/thQO9bhxUTOx7/w== 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=Ln/kY2dEO+CZorZvAmeVw4PalDK5U1+UI8nmy/1w0GY=; b=pkHURkWllGUkP41rdZciOA4zvRXZ2U7pd3ESdawAFx7elPESBp32iOZ43Gp6IHQongIcZxyUt29uhfj/sseYiXmEKqJ0vPIX+qFhRF4ziAE9EmWTAkQTFuGpfpgNMgrWkZ7tYStDfiPjbsDEJ3UixV/f+P997U6zRQ5hWHXMBwE= Received: from CYXPR02CA0054.namprd02.prod.outlook.com (2603:10b6:930:cd::16) by IA1PR12MB7758.namprd12.prod.outlook.com (2603:10b6:208:421::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.30; Fri, 8 Sep 2023 15:02:55 +0000 Received: from CY4PEPF0000EDD1.namprd03.prod.outlook.com (2603:10b6:930:cd:cafe::ba) by CYXPR02CA0054.outlook.office365.com (2603:10b6:930:cd::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.31 via Frontend Transport; Fri, 8 Sep 2023 15:02: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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by CY4PEPF0000EDD1.mail.protection.outlook.com (10.167.241.205) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6792.11 via Frontend Transport; Fri, 8 Sep 2023 15:02:55 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Fri, 8 Sep 2023 10:02:54 -0500 Received: from hwentlanrmb.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Fri, 8 Sep 2023 10:02:53 -0500 From: Harry Wentland To: Subject: [RFC PATCH 10/10] drm/vkms: Add enumerated 1D curve colorop Date: Fri, 8 Sep 2023 11:02:35 -0400 Message-ID: <20230908150235.75918-11-harry.wentland@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230908150235.75918-1-harry.wentland@amd.com> References: <20230908150235.75918-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD1:EE_|IA1PR12MB7758:EE_ X-MS-Office365-Filtering-Correlation-Id: 7562c719-7858-4ac8-2b9b-08dbb07cae63 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +Aq1MJskFNX/529SKQRgI6/QlSl+BvrPmIQfJOxEPu+/JuUnBNyDDHYi3RmXzEoXmK/8I8mWYWmTZxFweMf5GMpkqEwIsGbVZoYz5CTz3jUkJuG0gWyUk+xFeHPfxJfaUH8qbJqUipznhvdXgerSLWPenQgRblv0nBESP4bYEEIeAonQk0NhGuKZPNPaPKQqF323IenZj4JQU25OqezB+aZmTs6Oe28H5Q9AYCuX9X+nbGpCWjUo4bZgDnct+3Fj45euPFb8t5rtLywiZuNAOWUYmOUCDLQFjGVfSRlRaXTdLOOULQLk7TCfcP5+jImhxdbtWpLYQy9lezOWGijCgp+POafj6mphA7DjNbAr6/kqW1QmawGabudDmrhY9zrlObavQvJBEz4LNwVVEFITCwrQrYIDBN08kt8GCetvJ6VDDjortkVEIsC40Y3Mt5Lv88/7AWp9/iowc+lE7EwK35ThIkWX65KSwXNNJB6W/MU/majEcPlkVDwS8jomdPGlnIQYAxlYXtNLykWM/M180tb2/qzSF5nIXBMMO1rLfokUX6ydGIDUMOiI9NdcSD5xGiFDg6GRf+AR3+VxHTIhyIEQNG0z9ziu6eEa/ZrEIeU4GGGkMH4ecWY+z3sJqI0NYNhYq2+1BrpQOupDhfr4WJa9Dkr5jKKqnR/WFvjob8qIWi6bAEBw+Hc7zXjUbfNrPY+BqBd0DzkqPgRrxju2l8WSF/ptoUQGfxRYkmiMnofO7/MNo7QZdSUaiHwjElxwEuf+BecRBVUyJVMElbTnEg== 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)(136003)(396003)(39860400002)(1800799009)(82310400011)(186009)(451199024)(40470700004)(46966006)(36840700001)(6666004)(7696005)(426003)(478600001)(83380400001)(70206006)(66574015)(2616005)(26005)(30864003)(2906002)(4326008)(44832011)(7416002)(316002)(54906003)(41300700001)(5660300002)(70586007)(8936002)(8676002)(6916009)(1076003)(40460700003)(36860700001)(356005)(40480700001)(336012)(47076005)(81166007)(86362001)(36756003)(82740400003)(66899024)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2023 15:02:55.0131 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7562c719-7858-4ac8-2b9b-08dbb07cae63 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: CY4PEPF0000EDD1.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7758 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: Sebastian Wick , Pekka Paalanen , Shashank Sharma , Xaver Hugl , =?utf-8?q?Michel_D=C3=A4nzer?= , wayland-devel@lists.freedesktop.org, Melissa Wen , =?utf-8?q?Jonas_=C3=85dahl?= , Uma Shankar , Victoria Brekenfeld , Joshua Ashton , Aleix Pol , Naseer Ahmed , Christopher Braga 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: Daniel Vetter Cc: Uma Shankar Cc: Naseer Ahmed Cc: Christopher Braga --- drivers/gpu/drm/vkms/Makefile | 3 +- drivers/gpu/drm/vkms/vkms_colorop.c | 108 +++++++++ drivers/gpu/drm/vkms/vkms_composer.c | 316 +++++++++++++++++++++++++++ drivers/gpu/drm/vkms/vkms_drv.h | 4 + drivers/gpu/drm/vkms/vkms_plane.c | 2 + 5 files changed, 432 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/vkms/vkms_colorop.c diff --git a/drivers/gpu/drm/vkms/Makefile b/drivers/gpu/drm/vkms/Makefile index 1b28a6a32948..bcf508873622 100644 --- a/drivers/gpu/drm/vkms/Makefile +++ b/drivers/gpu/drm/vkms/Makefile @@ -6,6 +6,7 @@ vkms-y := \ vkms_formats.o \ vkms_crtc.o \ vkms_composer.o \ - vkms_writeback.o + vkms_writeback.o \ + vkms_colorop.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..b3da0705bca7 --- /dev/null +++ b/drivers/gpu/drm/vkms/vkms_colorop.c @@ -0,0 +1,108 @@ +/* + * 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 + +#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 f6c311e8a87c..92ab9c62a554 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -12,6 +12,284 @@ #include "vkms_drv.h" +#define LUT_SIZE 256 + +struct drm_color_lut srgb_array[LUT_SIZE] = { + { 0x13, 0x13, 0x13, 0 }, + { 0x27, 0x27, 0x27, 0 }, + { 0x3b, 0x3b, 0x3b, 0 }, + { 0x4f, 0x4f, 0x4f, 0 }, + { 0x63, 0x63, 0x63, 0 }, + { 0x76, 0x76, 0x76, 0 }, + { 0x8a, 0x8a, 0x8a, 0 }, + { 0x9e, 0x9e, 0x9e, 0 }, + { 0xb2, 0xb2, 0xb2, 0 }, + { 0xc6, 0xc6, 0xc6, 0 }, + { 0xda, 0xda, 0xda, 0 }, + { 0xef, 0xef, 0xef, 0 }, + { 0x106, 0x106, 0x106, 0 }, + { 0x11e, 0x11e, 0x11e, 0 }, + { 0x137, 0x137, 0x137, 0 }, + { 0x151, 0x151, 0x151, 0 }, + { 0x16d, 0x16d, 0x16d, 0 }, + { 0x18a, 0x18a, 0x18a, 0 }, + { 0x1a8, 0x1a8, 0x1a8, 0 }, + { 0x1c7, 0x1c7, 0x1c7, 0 }, + { 0x1e8, 0x1e8, 0x1e8, 0 }, + { 0x20a, 0x20a, 0x20a, 0 }, + { 0x22e, 0x22e, 0x22e, 0 }, + { 0x253, 0x253, 0x253, 0 }, + { 0x279, 0x279, 0x279, 0 }, + { 0x2a0, 0x2a0, 0x2a0, 0 }, + { 0x2c9, 0x2c9, 0x2c9, 0 }, + { 0x2f4, 0x2f4, 0x2f4, 0 }, + { 0x320, 0x320, 0x320, 0 }, + { 0x34d, 0x34d, 0x34d, 0 }, + { 0x37c, 0x37c, 0x37c, 0 }, + { 0x3ac, 0x3ac, 0x3ac, 0 }, + { 0x3de, 0x3de, 0x3de, 0 }, + { 0x411, 0x411, 0x411, 0 }, + { 0x446, 0x446, 0x446, 0 }, + { 0x47c, 0x47c, 0x47c, 0 }, + { 0x4b4, 0x4b4, 0x4b4, 0 }, + { 0x4ed, 0x4ed, 0x4ed, 0 }, + { 0x528, 0x528, 0x528, 0 }, + { 0x564, 0x564, 0x564, 0 }, + { 0x5a3, 0x5a3, 0x5a3, 0 }, + { 0x5e2, 0x5e2, 0x5e2, 0 }, + { 0x624, 0x624, 0x624, 0 }, + { 0x666, 0x666, 0x666, 0 }, + { 0x6ab, 0x6ab, 0x6ab, 0 }, + { 0x6f1, 0x6f1, 0x6f1, 0 }, + { 0x739, 0x739, 0x739, 0 }, + { 0x782, 0x782, 0x782, 0 }, + { 0x7ce, 0x7ce, 0x7ce, 0 }, + { 0x81b, 0x81b, 0x81b, 0 }, + { 0x869, 0x869, 0x869, 0 }, + { 0x8b9, 0x8b9, 0x8b9, 0 }, + { 0x90b, 0x90b, 0x90b, 0 }, + { 0x95f, 0x95f, 0x95f, 0 }, + { 0x9b5, 0x9b5, 0x9b5, 0 }, + { 0xa0c, 0xa0c, 0xa0c, 0 }, + { 0xa65, 0xa65, 0xa65, 0 }, + { 0xabf, 0xabf, 0xabf, 0 }, + { 0xb1c, 0xb1c, 0xb1c, 0 }, + { 0xb7a, 0xb7a, 0xb7a, 0 }, + { 0xbda, 0xbda, 0xbda, 0 }, + { 0xc3c, 0xc3c, 0xc3c, 0 }, + { 0xca0, 0xca0, 0xca0, 0 }, + { 0xd06, 0xd06, 0xd06, 0 }, + { 0xd6d, 0xd6d, 0xd6d, 0 }, + { 0xdd6, 0xdd6, 0xdd6, 0 }, + { 0xe41, 0xe41, 0xe41, 0 }, + { 0xeae, 0xeae, 0xeae, 0 }, + { 0xf1d, 0xf1d, 0xf1d, 0 }, + { 0xf8e, 0xf8e, 0xf8e, 0 }, + { 0x1001, 0x1001, 0x1001, 0 }, + { 0x1075, 0x1075, 0x1075, 0 }, + { 0x10ec, 0x10ec, 0x10ec, 0 }, + { 0x1164, 0x1164, 0x1164, 0 }, + { 0x11de, 0x11de, 0x11de, 0 }, + { 0x125a, 0x125a, 0x125a, 0 }, + { 0x12d9, 0x12d9, 0x12d9, 0 }, + { 0x1359, 0x1359, 0x1359, 0 }, + { 0x13db, 0x13db, 0x13db, 0 }, + { 0x145f, 0x145f, 0x145f, 0 }, + { 0x14e5, 0x14e5, 0x14e5, 0 }, + { 0x156d, 0x156d, 0x156d, 0 }, + { 0x15f7, 0x15f7, 0x15f7, 0 }, + { 0x1683, 0x1683, 0x1683, 0 }, + { 0x1711, 0x1711, 0x1711, 0 }, + { 0x17a1, 0x17a1, 0x17a1, 0 }, + { 0x1833, 0x1833, 0x1833, 0 }, + { 0x18c7, 0x18c7, 0x18c7, 0 }, + { 0x195d, 0x195d, 0x195d, 0 }, + { 0x19f6, 0x19f6, 0x19f6, 0 }, + { 0x1a90, 0x1a90, 0x1a90, 0 }, + { 0x1b2c, 0x1b2c, 0x1b2c, 0 }, + { 0x1bcb, 0x1bcb, 0x1bcb, 0 }, + { 0x1c6b, 0x1c6b, 0x1c6b, 0 }, + { 0x1d0e, 0x1d0e, 0x1d0e, 0 }, + { 0x1db3, 0x1db3, 0x1db3, 0 }, + { 0x1e59, 0x1e59, 0x1e59, 0 }, + { 0x1f02, 0x1f02, 0x1f02, 0 }, + { 0x1fad, 0x1fad, 0x1fad, 0 }, + { 0x205b, 0x205b, 0x205b, 0 }, + { 0x210a, 0x210a, 0x210a, 0 }, + { 0x21bb, 0x21bb, 0x21bb, 0 }, + { 0x226f, 0x226f, 0x226f, 0 }, + { 0x2325, 0x2325, 0x2325, 0 }, + { 0x23dd, 0x23dd, 0x23dd, 0 }, + { 0x2497, 0x2497, 0x2497, 0 }, + { 0x2553, 0x2553, 0x2553, 0 }, + { 0x2612, 0x2612, 0x2612, 0 }, + { 0x26d2, 0x26d2, 0x26d2, 0 }, + { 0x2795, 0x2795, 0x2795, 0 }, + { 0x285a, 0x285a, 0x285a, 0 }, + { 0x2922, 0x2922, 0x2922, 0 }, + { 0x29eb, 0x29eb, 0x29eb, 0 }, + { 0x2ab7, 0x2ab7, 0x2ab7, 0 }, + { 0x2b85, 0x2b85, 0x2b85, 0 }, + { 0x2c56, 0x2c56, 0x2c56, 0 }, + { 0x2d28, 0x2d28, 0x2d28, 0 }, + { 0x2dfd, 0x2dfd, 0x2dfd, 0 }, + { 0x2ed4, 0x2ed4, 0x2ed4, 0 }, + { 0x2fad, 0x2fad, 0x2fad, 0 }, + { 0x3089, 0x3089, 0x3089, 0 }, + { 0x3167, 0x3167, 0x3167, 0 }, + { 0x3247, 0x3247, 0x3247, 0 }, + { 0x332a, 0x332a, 0x332a, 0 }, + { 0x340e, 0x340e, 0x340e, 0 }, + { 0x34f5, 0x34f5, 0x34f5, 0 }, + { 0x35df, 0x35df, 0x35df, 0 }, + { 0x36cb, 0x36cb, 0x36cb, 0 }, + { 0x37b9, 0x37b9, 0x37b9, 0 }, + { 0x38a9, 0x38a9, 0x38a9, 0 }, + { 0x399c, 0x399c, 0x399c, 0 }, + { 0x3a91, 0x3a91, 0x3a91, 0 }, + { 0x3b89, 0x3b89, 0x3b89, 0 }, + { 0x3c83, 0x3c83, 0x3c83, 0 }, + { 0x3d7f, 0x3d7f, 0x3d7f, 0 }, + { 0x3e7e, 0x3e7e, 0x3e7e, 0 }, + { 0x3f7f, 0x3f7f, 0x3f7f, 0 }, + { 0x4082, 0x4082, 0x4082, 0 }, + { 0x4188, 0x4188, 0x4188, 0 }, + { 0x4290, 0x4290, 0x4290, 0 }, + { 0x439b, 0x439b, 0x439b, 0 }, + { 0x44a8, 0x44a8, 0x44a8, 0 }, + { 0x45b7, 0x45b7, 0x45b7, 0 }, + { 0x46c9, 0x46c9, 0x46c9, 0 }, + { 0x47dd, 0x47dd, 0x47dd, 0 }, + { 0x48f4, 0x48f4, 0x48f4, 0 }, + { 0x4a0d, 0x4a0d, 0x4a0d, 0 }, + { 0x4b29, 0x4b29, 0x4b29, 0 }, + { 0x4c47, 0x4c47, 0x4c47, 0 }, + { 0x4d68, 0x4d68, 0x4d68, 0 }, + { 0x4e8b, 0x4e8b, 0x4e8b, 0 }, + { 0x4fb1, 0x4fb1, 0x4fb1, 0 }, + { 0x50d9, 0x50d9, 0x50d9, 0 }, + { 0x5203, 0x5203, 0x5203, 0 }, + { 0x5330, 0x5330, 0x5330, 0 }, + { 0x5460, 0x5460, 0x5460, 0 }, + { 0x5592, 0x5592, 0x5592, 0 }, + { 0x56c6, 0x56c6, 0x56c6, 0 }, + { 0x57fd, 0x57fd, 0x57fd, 0 }, + { 0x5937, 0x5937, 0x5937, 0 }, + { 0x5a73, 0x5a73, 0x5a73, 0 }, + { 0x5bb2, 0x5bb2, 0x5bb2, 0 }, + { 0x5cf3, 0x5cf3, 0x5cf3, 0 }, + { 0x5e37, 0x5e37, 0x5e37, 0 }, + { 0x5f7d, 0x5f7d, 0x5f7d, 0 }, + { 0x60c6, 0x60c6, 0x60c6, 0 }, + { 0x6212, 0x6212, 0x6212, 0 }, + { 0x6360, 0x6360, 0x6360, 0 }, + { 0x64b0, 0x64b0, 0x64b0, 0 }, + { 0x6604, 0x6604, 0x6604, 0 }, + { 0x6759, 0x6759, 0x6759, 0 }, + { 0x68b2, 0x68b2, 0x68b2, 0 }, + { 0x6a0d, 0x6a0d, 0x6a0d, 0 }, + { 0x6b6a, 0x6b6a, 0x6b6a, 0 }, + { 0x6ccb, 0x6ccb, 0x6ccb, 0 }, + { 0x6e2d, 0x6e2d, 0x6e2d, 0 }, + { 0x6f93, 0x6f93, 0x6f93, 0 }, + { 0x70fb, 0x70fb, 0x70fb, 0 }, + { 0x7266, 0x7266, 0x7266, 0 }, + { 0x73d3, 0x73d3, 0x73d3, 0 }, + { 0x7543, 0x7543, 0x7543, 0 }, + { 0x76b6, 0x76b6, 0x76b6, 0 }, + { 0x782b, 0x782b, 0x782b, 0 }, + { 0x79a3, 0x79a3, 0x79a3, 0 }, + { 0x7b1d, 0x7b1d, 0x7b1d, 0 }, + { 0x7c9b, 0x7c9b, 0x7c9b, 0 }, + { 0x7e1b, 0x7e1b, 0x7e1b, 0 }, + { 0x7f9d, 0x7f9d, 0x7f9d, 0 }, + { 0x8123, 0x8123, 0x8123, 0 }, + { 0x82ab, 0x82ab, 0x82ab, 0 }, + { 0x8436, 0x8436, 0x8436, 0 }, + { 0x85c3, 0x85c3, 0x85c3, 0 }, + { 0x8753, 0x8753, 0x8753, 0 }, + { 0x88e6, 0x88e6, 0x88e6, 0 }, + { 0x8a7c, 0x8a7c, 0x8a7c, 0 }, + { 0x8c14, 0x8c14, 0x8c14, 0 }, + { 0x8daf, 0x8daf, 0x8daf, 0 }, + { 0x8f4d, 0x8f4d, 0x8f4d, 0 }, + { 0x90ed, 0x90ed, 0x90ed, 0 }, + { 0x9290, 0x9290, 0x9290, 0 }, + { 0x9436, 0x9436, 0x9436, 0 }, + { 0x95df, 0x95df, 0x95df, 0 }, + { 0x978b, 0x978b, 0x978b, 0 }, + { 0x9939, 0x9939, 0x9939, 0 }, + { 0x9aea, 0x9aea, 0x9aea, 0 }, + { 0x9c9e, 0x9c9e, 0x9c9e, 0 }, + { 0x9e55, 0x9e55, 0x9e55, 0 }, + { 0xa00e, 0xa00e, 0xa00e, 0 }, + { 0xa1ca, 0xa1ca, 0xa1ca, 0 }, + { 0xa389, 0xa389, 0xa389, 0 }, + { 0xa54b, 0xa54b, 0xa54b, 0 }, + { 0xa710, 0xa710, 0xa710, 0 }, + { 0xa8d7, 0xa8d7, 0xa8d7, 0 }, + { 0xaaa1, 0xaaa1, 0xaaa1, 0 }, + { 0xac6e, 0xac6e, 0xac6e, 0 }, + { 0xae3e, 0xae3e, 0xae3e, 0 }, + { 0xb011, 0xb011, 0xb011, 0 }, + { 0xb1e7, 0xb1e7, 0xb1e7, 0 }, + { 0xb3bf, 0xb3bf, 0xb3bf, 0 }, + { 0xb59a, 0xb59a, 0xb59a, 0 }, + { 0xb778, 0xb778, 0xb778, 0 }, + { 0xb959, 0xb959, 0xb959, 0 }, + { 0xbb3d, 0xbb3d, 0xbb3d, 0 }, + { 0xbd24, 0xbd24, 0xbd24, 0 }, + { 0xbf0d, 0xbf0d, 0xbf0d, 0 }, + { 0xc0fa, 0xc0fa, 0xc0fa, 0 }, + { 0xc2e9, 0xc2e9, 0xc2e9, 0 }, + { 0xc4db, 0xc4db, 0xc4db, 0 }, + { 0xc6d0, 0xc6d0, 0xc6d0, 0 }, + { 0xc8c8, 0xc8c8, 0xc8c8, 0 }, + { 0xcac3, 0xcac3, 0xcac3, 0 }, + { 0xccc1, 0xccc1, 0xccc1, 0 }, + { 0xcec1, 0xcec1, 0xcec1, 0 }, + { 0xd0c5, 0xd0c5, 0xd0c5, 0 }, + { 0xd2cc, 0xd2cc, 0xd2cc, 0 }, + { 0xd4d5, 0xd4d5, 0xd4d5, 0 }, + { 0xd6e1, 0xd6e1, 0xd6e1, 0 }, + { 0xd8f1, 0xd8f1, 0xd8f1, 0 }, + { 0xdb03, 0xdb03, 0xdb03, 0 }, + { 0xdd18, 0xdd18, 0xdd18, 0 }, + { 0xdf30, 0xdf30, 0xdf30, 0 }, + { 0xe14b, 0xe14b, 0xe14b, 0 }, + { 0xe369, 0xe369, 0xe369, 0 }, + { 0xe58a, 0xe58a, 0xe58a, 0 }, + { 0xe7ae, 0xe7ae, 0xe7ae, 0 }, + { 0xe9d5, 0xe9d5, 0xe9d5, 0 }, + { 0xebff, 0xebff, 0xebff, 0 }, + { 0xee2c, 0xee2c, 0xee2c, 0 }, + { 0xf05c, 0xf05c, 0xf05c, 0 }, + { 0xf28f, 0xf28f, 0xf28f, 0 }, + { 0xf4c4, 0xf4c4, 0xf4c4, 0 }, + { 0xf6fd, 0xf6fd, 0xf6fd, 0 }, + { 0xf939, 0xf939, 0xf939, 0 }, + { 0xfb78, 0xfb78, 0xfb78, 0 }, + { 0xfdba, 0xfdba, 0xfdba, 0 }, + { 0xffff, 0xffff, 0xffff, 0 } +}; + +#if 0 +struct vkms_color_lut srgb_eotf = { + .base = NULL, + . lut_length = LUT_SIZE, + .channel_value2index_ratio = drm_int2fixp(0xffff) + // .channel_value2index_ratio = 0 //drm_fixp_div(drm_int2fixp(0xffff), drm_int2fixp(LUT_SIZE)) +}; + +#else +const struct vkms_color_lut srgb_eotf = { + .base = srgb_array, + .lut_length = 256, + .channel_value2index_ratio = 16711935ll +}; + +#endif + static u16 pre_mul_blend_channel(u16 src, u16 dst, u16 alpha) { u32 new_color; @@ -136,6 +414,39 @@ 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 *pipeline = plane_state->base.base.color_pipeline; + /* TODO this is probably wrong */ + struct drm_colorop_state *colorop_state; + + if (!pipeline) + return; + + colorop_state = pipeline->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 (pipeline->type == DRM_COLOROP_1D_CURVE && + colorop_state->bypass == false) { + switch (colorop_state->curve_1d_type) { + case DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF: + 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; + } + } + } +} + /** * @wb_frame_info: The writeback frame buffer metadata * @crtc_state: The crtc state @@ -168,8 +479,13 @@ static void blend(struct vkms_writeback_job *wb, continue; plane[i]->plane_read(stage_buffer, plane[i]->frame_info, y); + + /* do per-plane color transformations here */ + // pre_blend_color_transform(plane[i], stage_buffer); + pre_mul_alpha_blend(plane[i]->frame_info, stage_buffer, output_buffer); + pre_blend_color_transform(plane[i], output_buffer); } apply_lut(crtc_state, output_buffer); diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 310b31f47928..c04f714cd486 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -168,4 +168,8 @@ void vkms_set_composer(struct vkms_output *out, bool enabled); /* 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_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index b3f8a115cc23..cbffbdd7cbf9 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -237,5 +237,7 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, drm_plane_helper_add(&plane->base, funcs); + vkms_initialize_colorops(&plane->base); + return plane; }