aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/2056-drm-amd-display-Add-connector-debugfs-for-output_bpc.patch
blob: 1584f4620bbe62503f712827870f5d767c16c0ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
From 6eda942846a688fad1518c1782fb439b965c70b7 Mon Sep 17 00:00:00 2001
From: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Date: Mon, 3 Jun 2019 13:44:37 -0400
Subject: [PATCH 2056/2940] drm/amd/display: Add connector debugfs for
 "output_bpc"

[Why]
This will be useful for verifying whether we enter the correct output
color depth from IGT.

[How]
Locks the connector and associated CRTC if available and outputs
the current and maximum output bpc values.

Example:

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

v2: Drop unneeded connector status check

Change-Id: I198e19a7838e0d90c2a2d551de029784d73020d3
Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Reviewed-by: David Francis <David.Francis@amd.com>
Signed-off-by: Chaudhary Amit Kumar <Chaudharyamit.Kumar@amd.com>
---
 .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 72 ++++++++++++++++++-
 1 file changed, 70 insertions(+), 2 deletions(-)

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 1d5fc5ad3bee..e6a2b87703f5 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
@@ -672,6 +672,72 @@ static ssize_t dp_phy_test_pattern_debugfs_write(struct file *f, const char __us
 	return bytes_from_user;
 }
 
+/*
+ * Returns the current and 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 = NULL;
+        struct dm_crtc_state *dm_crtc_state = NULL;
+        int res = -ENODEV;
+        unsigned int bpc;
+
+        mutex_lock(&dev->mode_config.mutex);
+        drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
+
+        if (connector->state == NULL)
+                goto unlock;
+
+        crtc = connector->state->crtc;
+        if (crtc == NULL)
+                goto unlock;
+
+        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->timing.display_color_depth) {
+        case COLOR_DEPTH_666:
+                bpc = 6;
+                break;
+        case COLOR_DEPTH_888:
+                bpc = 8;
+                break;
+        case COLOR_DEPTH_101010:
+                bpc = 10;
+                break;
+        case COLOR_DEPTH_121212:
+                bpc = 12;
+                break;
+        case COLOR_DEPTH_161616:
+                bpc = 16;
+                break;
+        default:
+                goto unlock;
+        }
+
+        seq_printf(m, "Current: %u\n", bpc);
+        seq_printf(m, "Maximum: %u\n", connector->display_info.bpc);
+        res = 0;
+
+unlock:
+        if (crtc)
+                drm_modeset_unlock(&crtc->mutex);
+
+        drm_modeset_unlock(&dev->mode_config.connection_mutex);
+        mutex_unlock(&dev->mode_config.mutex);
+
+        return res;
+}
+
+
 /*
  * Returns the min and max vrr vfreq through the connector's debugfs file.
  * Example usage: cat /sys/kernel/debug/dri/0/DP-1/vrr_range
@@ -730,8 +796,6 @@ static ssize_t dp_sdp_message_debugfs_write(struct file *f, const char __user *b
 	return write_size;
 }
 
-DEFINE_SHOW_ATTRIBUTE(vrr_range);
-
 static ssize_t dp_dpcd_address_write(struct file *f, const char __user *buf,
 				 size_t size, loff_t *pos)
 {
@@ -814,6 +878,9 @@ static ssize_t dp_dpcd_data_read(struct file *f, char __user *buf,
 	return read_size - r;
 }
 
+DEFINE_SHOW_ATTRIBUTE(output_bpc);
+DEFINE_SHOW_ATTRIBUTE(vrr_range);
+
 static const struct file_operations dp_link_settings_debugfs_fops = {
 	.owner = THIS_MODULE,
 	.read = dp_link_settings_read,
@@ -866,6 +933,7 @@ static const struct {
 		{"link_settings", &dp_link_settings_debugfs_fops},
 		{"phy_settings", &dp_phy_settings_debugfs_fop},
 		{"test_pattern", &dp_phy_test_pattern_fops},
+		{"output_bpc", &output_bpc_fops},
 		{"vrr_range", &vrr_range_fops},
 		{"sdp_message", &sdp_message_fops},
 		{"aux_dpcd_address", &dp_dpcd_address_debugfs_fops},
-- 
2.17.1