From patchwork Thu Feb 15 05:32:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniele Castagna X-Patchwork-Id: 10220557 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0701D6055C for ; Thu, 15 Feb 2018 08:36:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA11628047 for ; Thu, 15 Feb 2018 08:36:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DE96C290B5; Thu, 15 Feb 2018 08:36:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0F95A28047 for ; Thu, 15 Feb 2018 08:36:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 439016E09D; Thu, 15 Feb 2018 08:36:07 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt0-f193.google.com (mail-qt0-f193.google.com [209.85.216.193]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1DC8D6E083 for ; Thu, 15 Feb 2018 05:33:18 +0000 (UTC) Received: by mail-qt0-f193.google.com with SMTP id q18so10606894qtl.3 for ; Wed, 14 Feb 2018 21:33:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=qtVKp7AxUDZKdgD7labnK/ODtzD9XKzAwXItbnWZVMA=; b=Hu1u8ObCHiok3UYieMgaVR2B7T9Z8oIsRJkuPtvwFS2VbdM1SOQQoN5nKUAj0S40Dk wL1axTPq9SQi/emZ4eVXhyvsUzQAW8ApnlQ/ni2lSHz/jf2k9xHxHYROs2SR/QKIaMzg WEkznHTW1LlzhkkqUBTclMl3TW0rdKingTi8G8TXbCgTSGAg/QOfTWa5+Uy/9tOR6R5t EuRd4G/aeGHH2YrrNtb0yczbm/uIKk9yBiGk4hMkv8z/kwE4I5HEzq0uQrYxFEQqyavV QlH3wkkMKfM2/sZDuM8WioNwvusO3VmSRGL2LEg7ochyjEV82vnKQ+YrwTohyZmkSY3L Y8qA== X-Gm-Message-State: APf1xPBzq0G5uwyXI5jPEF/Ouyiw7qUyQqgW3C9t2/FPwl7CBY52+l9o T0dlX5D3M6IOS7GL2y+W5HgvgQtseX8= X-Google-Smtp-Source: AH8x225WJO6n/wQPutNNvIyr+0pwyJXKYl3iT6W6GO3lvEz/xohBqMj+XClQrOdxppFYx2FSBdBz3A== X-Received: by 10.237.44.99 with SMTP id f90mr2532560qtd.80.1518672796738; Wed, 14 Feb 2018 21:33:16 -0800 (PST) Received: from dcastagna1.nyc.corp.google.com ([2620:0:1003:101a:749d:49f2:f0b1:dd83]) by smtp.gmail.com with ESMTPSA id l62sm13808198qkl.23.2018.02.14.21.33.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Feb 2018 21:33:16 -0800 (PST) From: Daniele Castagna To: dri-devel@lists.freedesktop.org Subject: [PATCH 05/10] drm: Define helper function for plane color enabling Date: Thu, 15 Feb 2018 00:32:55 -0500 Message-Id: <20180215053300.70482-6-dcastagna@chromium.org> X-Mailer: git-send-email 2.16.1.291.g4437f3f132-goog In-Reply-To: <20180215053300.70482-1-dcastagna@chromium.org> References: <20180215053300.70482-1-dcastagna@chromium.org> X-Mailman-Approved-At: Thu, 15 Feb 2018 08:36:05 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: "uma.shankar at intel.com (Uma Shankar)" Define helper function to enable Plane color features to attach plane color properties to plane structure. (am from https://patchwork.kernel.org/patch/9971333/) Change-Id: I0a6647607fe482786e7cdb5f997faf196b2f59a2 Signed-off-by: Uma Shankar --- drivers/gpu/drm/drm_plane.c | 48 ++++++++++++++++++++++++++++++++++++ include/drm/drm_color_mgmt.h | 5 ++++ 2 files changed, 53 insertions(+) diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c index 2c90519576a3e..bc2fc5e6771ac 100644 --- a/drivers/gpu/drm/drm_plane.c +++ b/drivers/gpu/drm/drm_plane.c @@ -143,6 +143,54 @@ static int create_in_format_blob(struct drm_device *dev, struct drm_plane *plane return 0; } + /** + * drm_plane_enable_color_mgmt - enable color management properties + * @plane: DRM Plane + * @plane_degamma_lut_size: the size of the degamma lut (before CSC) + * @plane_has_ctm: whether to attach ctm_property for CSC matrix + * @plane_gamma_lut_size: the size of the gamma lut (after CSC) + * + * This function lets the driver enable the color correction + * properties on a plane. This includes 3 degamma, csc and gamma + * properties that userspace can set and 2 size properties to inform + * the userspace of the lut sizes. Each of the properties are + * optional. The gamma and degamma properties are only attached if + * their size is not 0 and ctm_property is only attached if has_ctm is + * true. + * + * Drivers should use drm_atomic_helper_legacy_gamma_set() to implement the + * legacy &drm_crtc_funcs.gamma_set callback. + */ +void drm_plane_enable_color_mgmt(struct drm_plane *plane, + uint plane_degamma_lut_size, + bool plane_has_ctm, + uint plane_gamma_lut_size) +{ + struct drm_device *dev = plane->dev; + struct drm_mode_config *config = &dev->mode_config; + + if (plane_degamma_lut_size) { + drm_object_attach_property(&plane->base, + config->plane_degamma_lut_property, 0); + drm_object_attach_property(&plane->base, + config->plane_degamma_lut_size_property, + plane_degamma_lut_size); + } + + if (plane_has_ctm) + drm_object_attach_property(&plane->base, + config->plane_ctm_property, 0); + + if (plane_gamma_lut_size) { + drm_object_attach_property(&plane->base, + config->plane_gamma_lut_property, 0); + drm_object_attach_property(&plane->base, + config->plane_gamma_lut_size_property, + plane_gamma_lut_size); + } +} +EXPORT_SYMBOL(drm_plane_enable_color_mgmt); + /** * drm_universal_plane_init - Initialize a new universal plane object * @dev: DRM device diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h index 03a59cbce6212..155a9ba38471c 100644 --- a/include/drm/drm_color_mgmt.h +++ b/include/drm/drm_color_mgmt.h @@ -37,4 +37,9 @@ void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc, int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, int gamma_size); +void drm_plane_enable_color_mgmt(struct drm_plane *plane, + uint plane_degamma_lut_size, + bool plane_has_ctm, + uint plane_gamma_lut_size); + #endif