<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Looks straightforward</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Reviewed-by: David Francis <David.Francis@amd.com></p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Nicholas Kazlauskas <nicholas.kazlauskas@amd.com><br>
<b>Sent:</b> June 3, 2019 1:44:37 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org<br>
<b>Cc:</b> Li, Sun peng (Leo); Wentland, Harry; Kazlauskas, Nicholas<br>
<b>Subject:</b> [PATCH v2] drm/amd/display: Add connector debugfs for "output_bpc"</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">[Why]<br>
This will be useful for verifying whether we enter the correct output<br>
color depth from IGT.<br>
<br>
[How]<br>
Locks the connector and associated CRTC if available and outputs<br>
the current and maximum output bpc values.<br>
<br>
Example:<br>
<br>
cat /sys/kernel/debug/dri/0/DP-1/output_bpc<br>
Current: 8<br>
Maximum: 10<br>
<br>
v2: Drop unneeded connector status check<br>
<br>
Cc: Leo Li <sunpeng.li@amd.com><br>
Cc: Harry Wentland <harry.wentland@amd.com><br>
Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com><br>
---<br>
 .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 71 ++++++++++++++++++-<br>
 1 file changed, 69 insertions(+), 2 deletions(-)<br>
<br>
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<br>
index 1d5fc5ad3bee..a3e362fa6747 100644<br>
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c<br>
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c<br>
@@ -672,6 +672,71 @@ static ssize_t dp_phy_test_pattern_debugfs_write(struct file *f, const char __us<br>
         return bytes_from_user;<br>
 }<br>
 <br>
+/*<br>
+ * Returns the current and maximum output bpc for the connector.<br>
+ * Example usage: cat /sys/kernel/debug/dri/0/DP-1/output_bpc<br>
+ */<br>
+static int output_bpc_show(struct seq_file *m, void *data)<br>
+{<br>
+       struct drm_connector *connector = m->private;<br>
+       struct drm_device *dev = connector->dev;<br>
+       struct drm_crtc *crtc = NULL;<br>
+       struct dm_crtc_state *dm_crtc_state = NULL;<br>
+       int res = -ENODEV;<br>
+       unsigned int bpc;<br>
+<br>
+       mutex_lock(&dev->mode_config.mutex);<br>
+       drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);<br>
+<br>
+       if (connector->state == NULL)<br>
+               goto unlock;<br>
+<br>
+       crtc = connector->state->crtc;<br>
+       if (crtc == NULL)<br>
+               goto unlock;<br>
+<br>
+       drm_modeset_lock(&crtc->mutex, NULL);<br>
+       if (crtc->state == NULL)<br>
+               goto unlock;<br>
+<br>
+       dm_crtc_state = to_dm_crtc_state(crtc->state);<br>
+       if (dm_crtc_state->stream == NULL)<br>
+               goto unlock;<br>
+<br>
+       switch (dm_crtc_state->stream->timing.display_color_depth) {<br>
+       case COLOR_DEPTH_666:<br>
+               bpc = 6;<br>
+               break;<br>
+       case COLOR_DEPTH_888:<br>
+               bpc = 8;<br>
+               break;<br>
+       case COLOR_DEPTH_101010:<br>
+               bpc = 10;<br>
+               break;<br>
+       case COLOR_DEPTH_121212:<br>
+               bpc = 12;<br>
+               break;<br>
+       case COLOR_DEPTH_161616:<br>
+               bpc = 16;<br>
+               break;<br>
+       default:<br>
+               goto unlock;<br>
+       }<br>
+<br>
+       seq_printf(m, "Current: %u\n", bpc);<br>
+       seq_printf(m, "Maximum: %u\n", connector->display_info.bpc);<br>
+       res = 0;<br>
+<br>
+unlock:<br>
+       if (crtc)<br>
+               drm_modeset_unlock(&crtc->mutex);<br>
+<br>
+       drm_modeset_unlock(&dev->mode_config.connection_mutex);<br>
+       mutex_unlock(&dev->mode_config.mutex);<br>
+<br>
+       return res;<br>
+}<br>
+<br>
 /*<br>
  * Returns the min and max vrr vfreq through the connector's debugfs file.<br>
  * Example usage: cat /sys/kernel/debug/dri/0/DP-1/vrr_range<br>
@@ -730,8 +795,6 @@ static ssize_t dp_sdp_message_debugfs_write(struct file *f, const char __user *b<br>
         return write_size;<br>
 }<br>
 <br>
-DEFINE_SHOW_ATTRIBUTE(vrr_range);<br>
-<br>
 static ssize_t dp_dpcd_address_write(struct file *f, const char __user *buf,<br>
                                  size_t size, loff_t *pos)<br>
 {<br>
@@ -814,6 +877,9 @@ static ssize_t dp_dpcd_data_read(struct file *f, char __user *buf,<br>
         return read_size - r;<br>
 }<br>
 <br>
+DEFINE_SHOW_ATTRIBUTE(output_bpc);<br>
+DEFINE_SHOW_ATTRIBUTE(vrr_range);<br>
+<br>
 static const struct file_operations dp_link_settings_debugfs_fops = {<br>
         .owner = THIS_MODULE,<br>
         .read = dp_link_settings_read,<br>
@@ -866,6 +932,7 @@ static const struct {<br>
                 {"link_settings", &dp_link_settings_debugfs_fops},<br>
                 {"phy_settings", &dp_phy_settings_debugfs_fop},<br>
                 {"test_pattern", &dp_phy_test_pattern_fops},<br>
+               {"output_bpc", &output_bpc_fops},<br>
                 {"vrr_range", &vrr_range_fops},<br>
                 {"sdp_message", &sdp_message_fops},<br>
                 {"aux_dpcd_address", &dp_dpcd_address_debugfs_fops},<br>
-- <br>
2.17.1<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
amd-gfx@lists.freedesktop.org<br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a></div>
</span></font></div>
</body>
</html>