intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [Intel-gfx] [PATCH] drm/i915/display/debugfs: Add connector debugfs for "output_bpc"
@ 2022-03-28  7:50 Bhanuprakash Modem
  2022-03-28  8:07 ` [Intel-gfx] ✗ Fi.CI.DOCS: warning for " Patchwork
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: Bhanuprakash Modem @ 2022-03-28  7:50 UTC (permalink / raw)
  To: intel-gfx

This new debugfs will expose the connector's max supported bpc
and the bpc currently using. It is very useful for verifying
whether we enter the correct output color depth from IGT.

Example:
cat /sys/kernel/debug/dri/0/DP-1/output_bpc
Current: 8
Maximum: 10

Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Uma Shankar <uma.shankar@intel.com>
Cc: Swati Sharma <swati2.sharma@intel.com>
Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
---
 .../drm/i915/display/intel_display_debugfs.c  | 44 +++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/drivers/gpu/drm/i915/display/intel_display_debugfs.c b/drivers/gpu/drm/i915/display/intel_display_debugfs.c
index c1e74a13a0828..3792952a7c219 100644
--- a/drivers/gpu/drm/i915/display/intel_display_debugfs.c
+++ b/drivers/gpu/drm/i915/display/intel_display_debugfs.c
@@ -2275,6 +2275,47 @@ static const struct file_operations i915_dsc_bpp_fops = {
 	.write = i915_dsc_bpp_write
 };
 
+/*
+ * Returns the maximum output bpc for the connector.
+ * Example usage: cat /sys/kernel/debug/dri/0/DP-1/output_bpc
+ */
+static int output_bpc_show(struct seq_file *m, void *data)
+{
+	struct drm_connector *connector = m->private;
+	struct drm_device *dev = connector->dev;
+	struct drm_crtc *crtc;
+	struct intel_crtc_state *crtc_state;
+	struct intel_encoder *encoder = intel_attached_encoder(to_intel_connector(connector));
+	int res;
+
+	if (!encoder)
+		return -ENODEV;
+
+	res = drm_modeset_lock_single_interruptible(&dev->mode_config.connection_mutex);
+	if (res)
+		return res;
+
+	crtc = connector->state->crtc;
+	if (connector->status != connector_status_connected || !crtc) {
+		res = -ENODEV;
+		goto unlock;
+	}
+
+	crtc_state = to_intel_crtc_state(crtc->state);
+	if (!crtc_state->hw.active)
+		goto unlock;
+
+	seq_printf(m, "Current: %u\n", crtc_state->pipe_bpp / 3);
+	seq_printf(m, "Maximum: %u\n", connector->display_info.bpc);
+	res = 0;
+
+unlock:
+	drm_modeset_unlock(&dev->mode_config.connection_mutex);
+
+	return res;
+}
+DEFINE_SHOW_ATTRIBUTE(output_bpc);
+
 /**
  * intel_connector_debugfs_add - add i915 specific connector debugfs files
  * @connector: pointer to a registered drm_connector
@@ -2330,6 +2371,9 @@ void intel_connector_debugfs_add(struct intel_connector *intel_connector)
 	    connector->connector_type == DRM_MODE_CONNECTOR_HDMIB)
 		debugfs_create_file("i915_lpsp_capability", 0444, root,
 				    connector, &i915_lpsp_capability_fops);
+
+	debugfs_create_file("output_bpc", 0444, root,
+			    connector, &output_bpc_fops);
 }
 
 /**
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-04-08 10:36 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-28  7:50 [Intel-gfx] [PATCH] drm/i915/display/debugfs: Add connector debugfs for "output_bpc" Bhanuprakash Modem
2022-03-28  8:07 ` [Intel-gfx] ✗ Fi.CI.DOCS: warning for " Patchwork
2022-03-28  8:22 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-03-28  9:14 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2022-03-29  6:07 ` [Intel-gfx] [PATCH] " Bhanuprakash Modem
2022-04-01 12:40   ` Jani Nikula
2022-04-04  8:57     ` Modem, Bhanuprakash
2022-04-04 10:46       ` Jani Nikula
2022-04-04 12:06         ` Modem, Bhanuprakash
2022-04-04 15:41         ` Daniel Vetter
2022-04-08 10:36           ` Modem, Bhanuprakash
2022-03-29  6:48 ` [Intel-gfx] ✗ Fi.CI.DOCS: warning for drm/i915/display/debugfs: Add connector debugfs for "output_bpc" (rev2) Patchwork
2022-03-29  7:10 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-03-29  8:25 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).