mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Melissa Wen <mwen@igalia.com>
To: maarten.lankhorst@linux.intel.com, mripard@kernel.org,
	tzimmermann@suse.de, airlied@gmail.com, daniel@ffwll.ch
Cc: Joshua Ashton <joshua@froggi.es>,
	alex.hung@amd.com, nicholas.kazlauskas@amd.com,
	sungjoon.kim@amd.com, seanpaul@chromium.org,
	bhawanpreet.lakha@amd.com,
	Shashank Sharma <shashank.sharma@amd.com>,
	ville.syrjala@linux.intel.com, kernel-dev@igalia.com,
	laurent.pinchart+renesas@ideasonboard.com,
	Melissa Wen <mwen@igalia.com>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: [RFC PATCH v2 04/18] drm/drm_color_mgmt: add function to create 3D LUT modes supported
Date: Mon,  9 Jan 2023 13:38:32 -0100	[thread overview]
Message-ID: <20230109143846.1966301-5-mwen@igalia.com> (raw)
In-Reply-To: <20230109143846.1966301-1-mwen@igalia.com>

DRM color function to create modes for lut3d mode property from an array
of drm_color_lut3d_mode modes supported by the HW and advertise to
userspace. Userspace can get the description of a specific mode in the
enum list from its blob data.

Signed-off-by: Melissa Wen <mwen@igalia.com>
---
 drivers/gpu/drm/drm_color_mgmt.c | 43 +++++++++++++++++++++++++++++++-
 include/drm/drm_color_mgmt.h     |  4 +++
 2 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c
index f92633b3b67e..6ce48007cdd4 100644
--- a/drivers/gpu/drm/drm_color_mgmt.c
+++ b/drivers/gpu/drm/drm_color_mgmt.c
@@ -104,7 +104,7 @@
  *	LUT3D property. A mode specifies size, stride, bit depth and color
  *	format and depends on the underlying hardware). If drivers support
  *	multiple 3D LUT modes, they should be declared in a array of
- *	drm_color_lut3d_mode and they will be advertised as an enum.
+ *	drm_mode_lut3d_mode and they will be advertised as an enum.
  *
  * “GAMMA_LUT”:
  *	Blob property to set the gamma lookup table (LUT) mapping pixel data
@@ -228,6 +228,47 @@ void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc,
 }
 EXPORT_SYMBOL(drm_crtc_enable_color_mgmt);
 
+int drm_crtc_create_lut3d_mode_property(struct drm_crtc *crtc,
+					const struct drm_mode_lut3d_mode modes[],
+					unsigned int num_modes)
+{
+	struct drm_device *dev = crtc->dev;
+	struct drm_property_blob *blob;
+	struct drm_property *prop;
+	char *name;
+	int ret;
+
+	if (dev->mode_config.lut3d_mode_property)
+		return 0;
+
+	prop = drm_property_create(dev, DRM_MODE_PROP_ENUM, "LUT3D_MODE", num_modes);
+	if (!prop)
+		return -EINVAL;
+
+	for (int i = 0; i < num_modes; i++) {
+		blob = drm_property_create_blob(dev, sizeof(modes[i]), &modes[i]);
+		if (IS_ERR(blob))
+			return PTR_ERR(blob);
+
+		name = kasprintf(GFP_KERNEL, "lut3d_%d_%dbit",
+				 modes[i].lut_size, modes[i].bit_depth);
+		if (!name)
+			return -ENOMEM;
+
+		ret = drm_property_add_enum(prop, blob->base.id, name);
+		if (ret) {
+			drm_property_blob_put(blob);
+			kfree(name);
+			return ret;
+		}
+		kfree(name);
+	}
+	dev->mode_config.lut3d_mode_property = prop;
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_crtc_create_lut3d_mode_property);
+
 /**
  * drm_mode_crtc_set_gamma_size - set the gamma table size
  * @crtc: CRTC to set the gamma table size for
diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h
index 81c298488b0c..af9305925572 100644
--- a/include/drm/drm_color_mgmt.h
+++ b/include/drm/drm_color_mgmt.h
@@ -59,6 +59,10 @@ void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc,
 				bool has_ctm,
 				uint gamma_lut_size);
 
+int drm_crtc_create_lut3d_mode_property(struct drm_crtc *crtc,
+					const struct drm_mode_lut3d_mode modes[],
+					unsigned int num_modes);
+
 int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
 				 int gamma_size);
 
-- 
2.35.1


  parent reply	other threads:[~2023-01-09 14:44 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-09 14:38 [RFC PATCH v2 00/18] Add DRM CRTC 3D LUT interface Melissa Wen
2023-01-09 14:38 ` [RFC PATCH v2 01/18] drm: Add 3D LUT mode and its attributes Melissa Wen
2023-01-09 14:38 ` [RFC PATCH v2 02/18] drm/drm_color_mgmt: add shaper LUT to color mgmt properties Melissa Wen
2023-01-09 14:38 ` [RFC PATCH v2 03/18] drm/drm_color_mgmt: add 3D LUT props to DRM color mgmt Melissa Wen
2023-01-09 14:38 ` Melissa Wen [this message]
2023-01-09 14:38 ` [RFC PATCH v2 05/18] drm/drm_color_mgmt: add function to attach 3D LUT props Melissa Wen
2023-01-09 14:38 ` [RFC PATCH v2 06/18] drm/drm_color_mgmt: set first lut3d mode as default Melissa Wen
2023-01-09 14:38 ` [RFC PATCH v2 07/18] drm/amd/display: remove unused regamma condition Melissa Wen
2023-01-09 14:38 ` [RFC PATCH v2 08/18] drm/amd/display: add comments to describe DM crtc color mgmt behavior Melissa Wen
2023-01-09 14:38 ` [RFC PATCH v2 09/18] drm/amd/display: encapsulate atomic regamma operation Melissa Wen
2023-01-09 14:38 ` [RFC PATCH v2 10/18] drm/amd/display: update lut3d and shaper lut to stream Melissa Wen
2023-01-09 14:38 ` [RFC PATCH v2 11/18] drm/amd/display: handle MPC 3D LUT resources for a given context Melissa Wen
2023-01-09 14:38 ` [RFC PATCH v2 12/18] drm/amd/display: acquire/release 3D LUT resources for ctx on DCN301 Melissa Wen
2023-01-09 14:38 ` [RFC PATCH v2 13/18] drm/amd/display: Define 3D LUT struct for HDR planes Melissa Wen
2023-01-09 14:38 ` [RFC PATCH v2 14/18] drm/amd/display: expand array of supported 3D LUT modes Melissa Wen
2023-01-09 14:38 ` [RFC PATCH v2 15/18] drm/amd/display: enable 3D-LUT DRM properties if supported Melissa Wen
2023-01-09 14:38 ` [RFC PATCH v2 16/18] drm/amd/display: add user 3D LUT support to the amdgpu_dm color pipeline Melissa Wen
2023-01-09 14:38 ` [RFC PATCH v2 17/18] drm/amd/display: decouple steps to reuse in shaper LUT support Melissa Wen
2023-01-09 14:38 ` [RFC PATCH v2 18/18] drm/amd/display: add user shaper LUT support to amdgpu_dm color pipeline Melissa Wen
2023-06-13 15:43 ` [RFC PATCH v2 00/18] Add DRM CRTC 3D LUT interface Jacopo Mondi
2023-06-15  7:14   ` Pekka Paalanen
2023-06-15  8:07     ` Jacopo Mondi
2023-06-15 10:29       ` Pekka Paalanen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230109143846.1966301-5-mwen@igalia.com \
    --to=mwen@igalia.com \
    --cc=airlied@gmail.com \
    --cc=alex.hung@amd.com \
    --cc=bhawanpreet.lakha@amd.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=joshua@froggi.es \
    --cc=kernel-dev@igalia.com \
    --cc=laurent.pinchart+renesas@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=nicholas.kazlauskas@amd.com \
    --cc=seanpaul@chromium.org \
    --cc=shashank.sharma@amd.com \
    --cc=sungjoon.kim@amd.com \
    --cc=tzimmermann@suse.de \
    --cc=ville.syrjala@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®