AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Harry Wentland <harry.wentland@amd.com>
To: <amd-gfx@lists.freedesktop.org>, <dri-devel@lists.freedesktop.org>
Cc: Pekka Paalanen <ppaalanen@gmail.com>,
	Harry Wentland <harry.wentland@amd.com>,
	Sebastian Wick <sebastian.wick@redhat.com>,
	Joshua Ashton <joshua@froggi.es>,
	Vitaly.Prosyak@amd.com
Subject: [PATCH v3 14/17] drm/amd/display: Add debugfs for testing output colorspace
Date: Tue, 7 Mar 2023 10:11:04 -0500	[thread overview]
Message-ID: <20230307151107.49649-15-harry.wentland@amd.com> (raw)
In-Reply-To: <20230307151107.49649-1-harry.wentland@amd.com>

In order to IGT test colorspace we'll want to print
the currently enabled colorspace on a stream. We add
a new debugfs to do so, using the same scheme as
current bpc reporting.

This might also come in handy when debugging display
issues.

Signed-off-by: Harry Wentland <harry.wentland@amd.com>
Cc: Pekka Paalanen <ppaalanen@gmail.com>
Cc: Sebastian Wick <sebastian.wick@redhat.com>
Cc: Vitaly.Prosyak@amd.com
Cc: Joshua Ashton <joshua@froggi.es>
Cc: dri-devel@lists.freedesktop.org
Cc: amd-gfx@lists.freedesktop.org
Reviewed-By: Joshua Ashton <joshua@froggi.es>
---
 .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 57 +++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
index 4a5dae578d97..f0022c16b708 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
@@ -906,6 +906,61 @@ static int amdgpu_current_bpc_show(struct seq_file *m, void *data)
 }
 DEFINE_SHOW_ATTRIBUTE(amdgpu_current_bpc);
 
+/*
+ * Returns the current bpc for the crtc.
+ * Example usage: cat /sys/kernel/debug/dri/0/crtc-0/amdgpu_current_colorspace
+ */
+static int amdgpu_current_colorspace_show(struct seq_file *m, void *data)
+{
+	struct drm_crtc *crtc = m->private;
+	struct drm_device *dev = crtc->dev;
+	struct dm_crtc_state *dm_crtc_state = NULL;
+	int res = -ENODEV;
+
+	mutex_lock(&dev->mode_config.mutex);
+	drm_modeset_lock(&crtc->mutex, NULL);
+	if (crtc->state == NULL)
+		goto unlock;
+
+	dm_crtc_state = to_dm_crtc_state(crtc->state);
+	if (dm_crtc_state->stream == NULL)
+		goto unlock;
+
+	switch (dm_crtc_state->stream->output_color_space) {
+	case COLOR_SPACE_SRGB:
+		seq_printf(m, "RGB");
+		break;
+	case COLOR_SPACE_YCBCR601:
+	case COLOR_SPACE_YCBCR601_LIMITED:
+		seq_printf(m, "BT601_YCC");
+		break;
+	case COLOR_SPACE_YCBCR709:
+	case COLOR_SPACE_YCBCR709_LIMITED:
+		seq_printf(m, "BT709_YCC");
+		break;
+	case COLOR_SPACE_ADOBERGB:
+		seq_printf(m, "opRGB");
+		break;
+	case COLOR_SPACE_2020_RGB_FULLRANGE:
+		seq_printf(m, "BT2020_RGB");
+		break;
+	case COLOR_SPACE_2020_YCBCR:
+		seq_printf(m, "BT2020_YCC");
+		break;
+	default:
+		goto unlock;
+	}
+	res = 0;
+
+unlock:
+	drm_modeset_unlock(&crtc->mutex);
+	mutex_unlock(&dev->mode_config.mutex);
+
+	return res;
+}
+DEFINE_SHOW_ATTRIBUTE(amdgpu_current_colorspace);
+
+
 /*
  * Example usage:
  * Disable dsc passthrough, i.e.,: have dsc decoding at converver, not external RX
@@ -3235,6 +3290,8 @@ void crtc_debugfs_init(struct drm_crtc *crtc)
 #endif
 	debugfs_create_file("amdgpu_current_bpc", 0644, crtc->debugfs_entry,
 			    crtc, &amdgpu_current_bpc_fops);
+	debugfs_create_file("amdgpu_current_colorspace", 0644, crtc->debugfs_entry,
+			    crtc, &amdgpu_current_colorspace_fops);
 }
 
 /*
-- 
2.39.2


  parent reply	other threads:[~2023-03-07 15:12 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-07 15:10 [PATCH v3 00/17] Enable Colorspace connector property in amdgpu Harry Wentland
2023-03-07 15:10 ` [PATCH v3 01/17] drm/connector: Convert DRM_MODE_COLORIMETRY to enum Harry Wentland
2023-03-07 15:13   ` Simon Ser
2023-03-07 15:29     ` [PATCH v4 " Harry Wentland
2023-03-08  8:21       ` Pekka Paalanen
2023-03-07 15:10 ` [PATCH v3 02/17] drm/connector: Add enum documentation to drm_colorspace Harry Wentland
2023-03-08  8:59   ` Pekka Paalanen
2023-03-09  0:56     ` Sebastian Wick
2023-03-09 10:03       ` Pekka Paalanen
2023-03-09 20:23         ` Sebastian Wick
2023-05-24 17:00     ` Harry Wentland
2023-03-07 15:10 ` [PATCH v3 03/17] drm/connector: Deprecate split for BT.2020 in drm_colorspace enum Harry Wentland
2023-03-08  9:09   ` Pekka Paalanen
2023-03-09  1:05     ` Sebastian Wick
2023-03-09  1:10       ` Ville Syrjälä
2023-05-24 17:01     ` Harry Wentland
2023-03-07 15:10 ` [PATCH v3 04/17] drm/connector: Pull out common create_colorspace_property code Harry Wentland
2023-03-07 15:10 ` [PATCH v3 05/17] drm/connector: Use common colorspace_names array Harry Wentland
2023-03-08  9:15   ` Pekka Paalanen
2023-03-09  1:39   ` Sebastian Wick
2023-03-07 15:10 ` [PATCH v3 06/17] drm/connector: Print connector colorspace in state debugfs Harry Wentland
2023-03-08  9:19   ` Pekka Paalanen
2023-03-07 15:10 ` [PATCH v3 07/17] drm/connector: Allow drivers to pass list of supported colorspaces Harry Wentland
2023-03-07 15:10 ` [PATCH v3 08/17] drm/amd/display: Always pass connector_state to stream validation Harry Wentland
2023-03-07 15:10 ` [PATCH v3 09/17] drm/amd/display: Register Colorspace property for DP and HDMI Harry Wentland
2023-03-08  9:24   ` Pekka Paalanen
2023-05-24 18:16     ` Harry Wentland
2023-03-16  0:37   ` Sebastian Wick
2023-03-16  9:50     ` Ville Syrjälä
2023-03-16 10:07       ` Pekka Paalanen
2023-03-16 10:47         ` Ville Syrjälä
2023-03-16 11:34           ` Pekka Paalanen
2023-03-16 12:35             ` Ville Syrjälä
2023-03-16 21:13               ` Sebastian Wick
2023-03-16 23:01                 ` Ville Syrjälä
2023-03-17  8:53                   ` Pekka Paalanen
2023-03-17 12:50                     ` Ville Syrjälä
2023-03-17 13:35                       ` Pekka Paalanen
2023-03-17 13:53                         ` Joshua Ashton
2023-05-24 19:51                           ` Harry Wentland
2023-03-17 14:14                         ` Ville Syrjälä
2023-03-17 15:37                           ` Pekka Paalanen
2023-03-17 16:33                             ` Ville Syrjälä
2023-03-17 17:40                               ` Sebastian Wick
2023-03-17 18:38                                 ` Ville Syrjälä
2023-03-17 18:47                                   ` Sebastian Wick
2023-03-17 19:13                                     ` Ville Syrjälä
2023-03-07 15:11 ` [PATCH v3 10/17] drm/amd/display: Signal mode_changed if colorspace changed Harry Wentland
2023-03-07 15:11 ` [PATCH v3 11/17] drm/amd/display: Send correct DP colorspace infopacket Harry Wentland
2023-03-09  1:58   ` Sebastian Wick
2023-03-07 15:11 ` [PATCH v3 12/17] drm/amd/display: Always set crtcinfo from create_stream_for_sink Harry Wentland
2023-03-07 15:11 ` [PATCH v3 13/17] drm/amd/display: Add support for explicit BT601_YCC Harry Wentland
2023-03-07 15:11 ` Harry Wentland [this message]
2023-03-08  9:30   ` [PATCH v3 14/17] drm/amd/display: Add debugfs for testing output colorspace Pekka Paalanen
2023-03-09  2:05   ` Sebastian Wick
2023-03-07 15:11 ` [PATCH v3 15/17] drm/amd/display: Add default case for output_color_space switch Harry Wentland
2023-03-08  9:35   ` Pekka Paalanen
2023-03-07 15:11 ` [PATCH v3 16/17] drm/amd/display: Fallback to 2020_YCBCR if the pixel encoding is not RGB Harry Wentland
2023-03-07 15:11 ` [PATCH v3 17/17] drm/amd/display: Refactor avi_info_frame colorimetry determination Harry Wentland
2023-03-08  9:38 ` [PATCH v3 00/17] Enable Colorspace connector property in amdgpu 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=20230307151107.49649-15-harry.wentland@amd.com \
    --to=harry.wentland@amd.com \
    --cc=Vitaly.Prosyak@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=joshua@froggi.es \
    --cc=ppaalanen@gmail.com \
    --cc=sebastian.wick@redhat.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