2 * Copyright 2018 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
26 #include <linux/uaccess.h>
28 #include <drm/drm_debugfs.h>
32 #include "amdgpu_dm.h"
33 #include "amdgpu_dm_debugfs.h"
34 #include "dm_helpers.h"
35 #include "dmub/dmub_srv.h"
38 #include "dc_link_dp.h"
40 struct dmub_debugfs_trace_header {
45 struct dmub_debugfs_trace_entry {
53 /* parse_write_buffer_into_params - Helper function to parse debugfs write buffer into an array
55 * Function takes in attributes passed to debugfs write entry
56 * and writes into param array.
57 * The user passes max_param_num to identify maximum number of
58 * parameters that could be parsed.
61 static int parse_write_buffer_into_params(char *wr_buf, uint32_t wr_buf_size,
62 long *param, const char __user *buf,
66 char *wr_buf_ptr = NULL;
67 uint32_t wr_buf_count = 0;
70 const char delimiter[3] = {' ', '\n', '\0'};
71 uint8_t param_index = 0;
77 r = copy_from_user(wr_buf_ptr, buf, wr_buf_size);
79 /* r is bytes not be copied */
80 if (r >= wr_buf_size) {
81 DRM_DEBUG_DRIVER("user data not be read\n");
85 /* check number of parameters. isspace could not differ space and \n */
86 while ((*wr_buf_ptr != 0xa) && (wr_buf_count < wr_buf_size)) {
88 while (isspace(*wr_buf_ptr) && (wr_buf_count < wr_buf_size)) {
93 if (wr_buf_count == wr_buf_size)
97 while ((!isspace(*wr_buf_ptr)) && (wr_buf_count < wr_buf_size)) {
104 if (wr_buf_count == wr_buf_size)
108 if (*param_nums > max_param_num)
109 *param_nums = max_param_num;
112 wr_buf_ptr = wr_buf; /* reset buf pointer */
113 wr_buf_count = 0; /* number of char already checked */
115 while (isspace(*wr_buf_ptr) && (wr_buf_count < wr_buf_size)) {
120 while (param_index < *param_nums) {
121 /* after strsep, wr_buf_ptr will be moved to after space */
122 sub_str = strsep(&wr_buf_ptr, delimiter);
124 r = kstrtol(sub_str, 16, &(param[param_index]));
127 DRM_DEBUG_DRIVER("string to int convert error code: %d\n", r);
135 /* function description
136 * get/ set DP configuration: lane_count, link_rate, spread_spectrum
138 * valid lane count value: 1, 2, 4
139 * valid link rate value:
140 * 06h = 1.62Gbps per lane
141 * 0Ah = 2.7Gbps per lane
142 * 0Ch = 3.24Gbps per lane
143 * 14h = 5.4Gbps per lane
144 * 1Eh = 8.1Gbps per lane
146 * debugfs is located at /sys/kernel/debug/dri/0/DP-x/link_settings
148 * --- to get dp configuration
152 * It will list current, verified, reported, preferred dp configuration.
153 * current -- for current video mode
154 * verified --- maximum configuration which pass link training
155 * reported --- DP rx report caps (DPCD register offset 0, 1 2)
156 * preferred --- user force settings
158 * --- set (or force) dp configuration
160 * echo <lane_count> <link_rate> > link_settings
162 * for example, to force to 2 lane, 2.7GHz,
163 * echo 4 0xa > link_settings
165 * spread_spectrum could not be changed dynamically.
167 * in case invalid lane count, link rate are force, no hw programming will be
168 * done. please check link settings after force operation to see if HW get
173 * check current and preferred settings.
176 static ssize_t dp_link_settings_read(struct file *f, char __user *buf,
177 size_t size, loff_t *pos)
179 struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
180 struct dc_link *link = connector->dc_link;
182 char *rd_buf_ptr = NULL;
183 const uint32_t rd_buf_size = 100;
188 if (*pos & 3 || size & 3)
191 rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
197 str_len = strlen("Current: %d %d %d ");
198 snprintf(rd_buf_ptr, str_len, "Current: %d %d %d ",
199 link->cur_link_settings.lane_count,
200 link->cur_link_settings.link_rate,
201 link->cur_link_settings.link_spread);
202 rd_buf_ptr += str_len;
204 str_len = strlen("Verified: %d %d %d ");
205 snprintf(rd_buf_ptr, str_len, "Verified: %d %d %d ",
206 link->verified_link_cap.lane_count,
207 link->verified_link_cap.link_rate,
208 link->verified_link_cap.link_spread);
209 rd_buf_ptr += str_len;
211 str_len = strlen("Reported: %d %d %d ");
212 snprintf(rd_buf_ptr, str_len, "Reported: %d %d %d ",
213 link->reported_link_cap.lane_count,
214 link->reported_link_cap.link_rate,
215 link->reported_link_cap.link_spread);
216 rd_buf_ptr += str_len;
218 str_len = strlen("Preferred: %d %d %d ");
219 snprintf(rd_buf_ptr, str_len, "Preferred: %d %d %d\n",
220 link->preferred_link_setting.lane_count,
221 link->preferred_link_setting.link_rate,
222 link->preferred_link_setting.link_spread);
225 if (*pos >= rd_buf_size)
228 r = put_user(*(rd_buf + result), buf);
230 return r; /* r = -EFAULT */
242 static ssize_t dp_link_settings_write(struct file *f, const char __user *buf,
243 size_t size, loff_t *pos)
245 struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
246 struct dc_link *link = connector->dc_link;
247 struct dc *dc = (struct dc *)link->dc;
248 struct dc_link_settings prefer_link_settings;
250 const uint32_t wr_buf_size = 40;
251 /* 0: lane_count; 1: link_rate */
252 int max_param_num = 2;
253 uint8_t param_nums = 0;
255 bool valid_input = false;
260 wr_buf = kcalloc(wr_buf_size, sizeof(char), GFP_KERNEL);
264 if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
272 if (param_nums <= 0) {
274 DRM_DEBUG_DRIVER("user data not be read\n");
281 case LANE_COUNT_FOUR:
292 case LINK_RATE_HIGH2:
293 case LINK_RATE_HIGH3:
302 DRM_DEBUG_DRIVER("Invalid Input value No HW will be programmed\n");
306 /* save user force lane_count, link_rate to preferred settings
307 * spread spectrum will not be changed
309 prefer_link_settings.link_spread = link->cur_link_settings.link_spread;
310 prefer_link_settings.lane_count = param[0];
311 prefer_link_settings.link_rate = param[1];
313 dc_link_set_preferred_link_settings(dc, &prefer_link_settings, link);
319 /* function: get current DP PHY settings: voltage swing, pre-emphasis,
320 * post-cursor2 (defined by VESA DP specification)
323 * voltage swing: 0,1,2,3
324 * pre-emphasis : 0,1,2,3
325 * post cursor2 : 0,1,2,3
328 * how to use this debugfs
330 * debugfs is located at /sys/kernel/debug/dri/0/DP-x
332 * there will be directories, like DP-1, DP-2,DP-3, etc. for DP display
334 * To figure out which DP-x is the display for DP to be check,
337 * There should be debugfs file, like link_settings, phy_settings.
339 * from lane_count, link_rate to figure which DP-x is for display to be worked
342 * To get current DP PHY settings,
345 * To change DP PHY settings,
346 * echo <voltage_swing> <pre-emphasis> <post_cursor2> > phy_settings
347 * for examle, to change voltage swing to 2, pre-emphasis to 3, post_cursor2 to
349 * echo 2 3 0 > phy_settings
351 * To check if change be applied, get current phy settings by
354 * In case invalid values are set by user, like
355 * echo 1 4 0 > phy_settings
357 * HW will NOT be programmed by these settings.
358 * cat phy_settings will show the previous valid settings.
360 static ssize_t dp_phy_settings_read(struct file *f, char __user *buf,
361 size_t size, loff_t *pos)
363 struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
364 struct dc_link *link = connector->dc_link;
366 const uint32_t rd_buf_size = 20;
370 if (*pos & 3 || size & 3)
373 rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
377 snprintf(rd_buf, rd_buf_size, " %d %d %d ",
378 link->cur_lane_setting.VOLTAGE_SWING,
379 link->cur_lane_setting.PRE_EMPHASIS,
380 link->cur_lane_setting.POST_CURSOR2);
383 if (*pos >= rd_buf_size)
386 r = put_user((*(rd_buf + result)), buf);
388 return r; /* r = -EFAULT */
400 static ssize_t dp_phy_settings_write(struct file *f, const char __user *buf,
401 size_t size, loff_t *pos)
403 struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
404 struct dc_link *link = connector->dc_link;
405 struct dc *dc = (struct dc *)link->dc;
407 uint32_t wr_buf_size = 40;
409 bool use_prefer_link_setting;
410 struct link_training_settings link_lane_settings;
411 int max_param_num = 3;
412 uint8_t param_nums = 0;
419 wr_buf = kcalloc(wr_buf_size, sizeof(char), GFP_KERNEL);
423 if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
431 if (param_nums <= 0) {
433 DRM_DEBUG_DRIVER("user data not be read\n");
437 if ((param[0] > VOLTAGE_SWING_MAX_LEVEL) ||
438 (param[1] > PRE_EMPHASIS_MAX_LEVEL) ||
439 (param[2] > POST_CURSOR2_MAX_LEVEL)) {
441 DRM_DEBUG_DRIVER("Invalid Input No HW will be programmed\n");
445 /* get link settings: lane count, link rate */
446 use_prefer_link_setting =
447 ((link->preferred_link_setting.link_rate != LINK_RATE_UNKNOWN) &&
448 (link->test_pattern_enabled));
450 memset(&link_lane_settings, 0, sizeof(link_lane_settings));
452 if (use_prefer_link_setting) {
453 link_lane_settings.link_settings.lane_count =
454 link->preferred_link_setting.lane_count;
455 link_lane_settings.link_settings.link_rate =
456 link->preferred_link_setting.link_rate;
457 link_lane_settings.link_settings.link_spread =
458 link->preferred_link_setting.link_spread;
460 link_lane_settings.link_settings.lane_count =
461 link->cur_link_settings.lane_count;
462 link_lane_settings.link_settings.link_rate =
463 link->cur_link_settings.link_rate;
464 link_lane_settings.link_settings.link_spread =
465 link->cur_link_settings.link_spread;
468 /* apply phy settings from user */
469 for (r = 0; r < link_lane_settings.link_settings.lane_count; r++) {
470 link_lane_settings.lane_settings[r].VOLTAGE_SWING =
471 (enum dc_voltage_swing) (param[0]);
472 link_lane_settings.lane_settings[r].PRE_EMPHASIS =
473 (enum dc_pre_emphasis) (param[1]);
474 link_lane_settings.lane_settings[r].POST_CURSOR2 =
475 (enum dc_post_cursor2) (param[2]);
478 /* program ASIC registers and DPCD registers */
479 dc_link_set_drive_settings(dc, &link_lane_settings, link);
485 /* function description
487 * set PHY layer or Link layer test pattern
488 * PHY test pattern is used for PHY SI check.
489 * Link layer test will not affect PHY SI.
491 * Reset Test Pattern:
492 * 0 = DP_TEST_PATTERN_VIDEO_MODE
494 * PHY test pattern supported:
495 * 1 = DP_TEST_PATTERN_D102
496 * 2 = DP_TEST_PATTERN_SYMBOL_ERROR
497 * 3 = DP_TEST_PATTERN_PRBS7
498 * 4 = DP_TEST_PATTERN_80BIT_CUSTOM
499 * 5 = DP_TEST_PATTERN_CP2520_1
500 * 6 = DP_TEST_PATTERN_CP2520_2 = DP_TEST_PATTERN_HBR2_COMPLIANCE_EYE
501 * 7 = DP_TEST_PATTERN_CP2520_3
503 * DP PHY Link Training Patterns
504 * 8 = DP_TEST_PATTERN_TRAINING_PATTERN1
505 * 9 = DP_TEST_PATTERN_TRAINING_PATTERN2
506 * a = DP_TEST_PATTERN_TRAINING_PATTERN3
507 * b = DP_TEST_PATTERN_TRAINING_PATTERN4
509 * DP Link Layer Test pattern
510 * c = DP_TEST_PATTERN_COLOR_SQUARES
511 * d = DP_TEST_PATTERN_COLOR_SQUARES_CEA
512 * e = DP_TEST_PATTERN_VERTICAL_BARS
513 * f = DP_TEST_PATTERN_HORIZONTAL_BARS
514 * 10= DP_TEST_PATTERN_COLOR_RAMP
516 * debugfs phy_test_pattern is located at /syskernel/debug/dri/0/DP-x
518 * --- set test pattern
519 * echo <test pattern #> > test_pattern
521 * If test pattern # is not supported, NO HW programming will be done.
522 * for DP_TEST_PATTERN_80BIT_CUSTOM, it needs extra 10 bytes of data
523 * for the user pattern. input 10 bytes data are separated by space
525 * echo 0x4 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88 0x99 0xaa > test_pattern
527 * --- reset test pattern
528 * echo 0 > test_pattern
530 * --- HPD detection is disabled when set PHY test pattern
532 * when PHY test pattern (pattern # within [1,7]) is set, HPD pin of HW ASIC
533 * is disable. User could unplug DP display from DP connected and plug scope to
534 * check test pattern PHY SI.
535 * If there is need unplug scope and plug DP display back, do steps below:
536 * echo 0 > phy_test_pattern
540 * "echo 0 > phy_test_pattern" will re-enable HPD pin again so that video sw
541 * driver could detect "unplug scope" and "plug DP display"
543 static ssize_t dp_phy_test_pattern_debugfs_write(struct file *f, const char __user *buf,
544 size_t size, loff_t *pos)
546 struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
547 struct dc_link *link = connector->dc_link;
549 uint32_t wr_buf_size = 100;
550 long param[11] = {0x0};
551 int max_param_num = 11;
552 enum dp_test_pattern test_pattern = DP_TEST_PATTERN_UNSUPPORTED;
553 bool disable_hpd = false;
554 bool valid_test_pattern = false;
555 uint8_t param_nums = 0;
556 /* init with defalut 80bit custom pattern */
557 uint8_t custom_pattern[10] = {
558 0x1f, 0x7c, 0xf0, 0xc1, 0x07,
559 0x1f, 0x7c, 0xf0, 0xc1, 0x07
561 struct dc_link_settings prefer_link_settings = {LANE_COUNT_UNKNOWN,
562 LINK_RATE_UNKNOWN, LINK_SPREAD_DISABLED};
563 struct dc_link_settings cur_link_settings = {LANE_COUNT_UNKNOWN,
564 LINK_RATE_UNKNOWN, LINK_SPREAD_DISABLED};
565 struct link_training_settings link_training_settings;
571 wr_buf = kcalloc(wr_buf_size, sizeof(char), GFP_KERNEL);
575 if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
583 if (param_nums <= 0) {
585 DRM_DEBUG_DRIVER("user data not be read\n");
590 test_pattern = param[0];
592 switch (test_pattern) {
593 case DP_TEST_PATTERN_VIDEO_MODE:
594 case DP_TEST_PATTERN_COLOR_SQUARES:
595 case DP_TEST_PATTERN_COLOR_SQUARES_CEA:
596 case DP_TEST_PATTERN_VERTICAL_BARS:
597 case DP_TEST_PATTERN_HORIZONTAL_BARS:
598 case DP_TEST_PATTERN_COLOR_RAMP:
599 valid_test_pattern = true;
602 case DP_TEST_PATTERN_D102:
603 case DP_TEST_PATTERN_SYMBOL_ERROR:
604 case DP_TEST_PATTERN_PRBS7:
605 case DP_TEST_PATTERN_80BIT_CUSTOM:
606 case DP_TEST_PATTERN_HBR2_COMPLIANCE_EYE:
607 case DP_TEST_PATTERN_TRAINING_PATTERN4:
609 valid_test_pattern = true;
613 valid_test_pattern = false;
614 test_pattern = DP_TEST_PATTERN_UNSUPPORTED;
618 if (!valid_test_pattern) {
620 DRM_DEBUG_DRIVER("Invalid Test Pattern Parameters\n");
624 if (test_pattern == DP_TEST_PATTERN_80BIT_CUSTOM) {
625 for (i = 0; i < 10; i++) {
626 if ((uint8_t) param[i + 1] != 0x0)
631 /* not use default value */
632 for (i = 0; i < 10; i++)
633 custom_pattern[i] = (uint8_t) param[i + 1];
637 /* Usage: set DP physical test pattern using debugfs with normal DP
638 * panel. Then plug out DP panel and connect a scope to measure
639 * For normal video mode and test pattern generated from CRCT,
640 * they are visibile to user. So do not disable HPD.
641 * Video Mode is also set to clear the test pattern, so enable HPD
642 * because it might have been disabled after a test pattern was set.
643 * AUX depends on HPD * sequence dependent, do not move!
646 dc_link_enable_hpd(link);
648 prefer_link_settings.lane_count = link->verified_link_cap.lane_count;
649 prefer_link_settings.link_rate = link->verified_link_cap.link_rate;
650 prefer_link_settings.link_spread = link->verified_link_cap.link_spread;
652 cur_link_settings.lane_count = link->cur_link_settings.lane_count;
653 cur_link_settings.link_rate = link->cur_link_settings.link_rate;
654 cur_link_settings.link_spread = link->cur_link_settings.link_spread;
656 link_training_settings.link_settings = cur_link_settings;
659 if (test_pattern != DP_TEST_PATTERN_VIDEO_MODE) {
660 if (prefer_link_settings.lane_count != LANE_COUNT_UNKNOWN &&
661 prefer_link_settings.link_rate != LINK_RATE_UNKNOWN &&
662 (prefer_link_settings.lane_count != cur_link_settings.lane_count ||
663 prefer_link_settings.link_rate != cur_link_settings.link_rate))
664 link_training_settings.link_settings = prefer_link_settings;
667 for (i = 0; i < (unsigned int)(link_training_settings.link_settings.lane_count); i++)
668 link_training_settings.lane_settings[i] = link->cur_lane_setting;
670 dc_link_set_test_pattern(
673 DP_TEST_PATTERN_COLOR_SPACE_RGB,
674 &link_training_settings,
678 /* Usage: Set DP physical test pattern using AMDDP with normal DP panel
679 * Then plug out DP panel and connect a scope to measure DP PHY signal.
680 * Need disable interrupt to avoid SW driver disable DP output. This is
681 * done after the test pattern is set.
683 if (valid_test_pattern && disable_hpd)
684 dc_link_disable_hpd(link);
692 * Returns the DMCUB tracebuffer contents.
693 * Example usage: cat /sys/kernel/debug/dri/0/amdgpu_dm_dmub_tracebuffer
695 static int dmub_tracebuffer_show(struct seq_file *m, void *data)
697 struct amdgpu_device *adev = m->private;
698 struct dmub_srv_fb_info *fb_info = adev->dm.dmub_fb_info;
699 struct dmub_debugfs_trace_entry *entries;
701 uint32_t tbuf_size, max_entries, num_entries, i;
706 tbuf_base = (uint8_t *)fb_info->fb[DMUB_WINDOW_5_TRACEBUFF].cpu_addr;
710 tbuf_size = fb_info->fb[DMUB_WINDOW_5_TRACEBUFF].size;
711 max_entries = (tbuf_size - sizeof(struct dmub_debugfs_trace_header)) /
712 sizeof(struct dmub_debugfs_trace_entry);
715 ((struct dmub_debugfs_trace_header *)tbuf_base)->entry_count;
717 num_entries = min(num_entries, max_entries);
719 entries = (struct dmub_debugfs_trace_entry
721 sizeof(struct dmub_debugfs_trace_header));
723 for (i = 0; i < num_entries; ++i) {
724 struct dmub_debugfs_trace_entry *entry = &entries[i];
727 "trace_code=%u tick_count=%u param0=%u param1=%u\n",
728 entry->trace_code, entry->tick_count, entry->param0,
736 * Returns the DMCUB firmware state contents.
737 * Example usage: cat /sys/kernel/debug/dri/0/amdgpu_dm_dmub_fw_state
739 static int dmub_fw_state_show(struct seq_file *m, void *data)
741 struct amdgpu_device *adev = m->private;
742 struct dmub_srv_fb_info *fb_info = adev->dm.dmub_fb_info;
749 state_base = (uint8_t *)fb_info->fb[DMUB_WINDOW_6_FW_STATE].cpu_addr;
753 state_size = fb_info->fb[DMUB_WINDOW_6_FW_STATE].size;
755 return seq_write(m, state_base, state_size);
759 * Returns the current and maximum output bpc for the connector.
760 * Example usage: cat /sys/kernel/debug/dri/0/DP-1/output_bpc
762 static int output_bpc_show(struct seq_file *m, void *data)
764 struct drm_connector *connector = m->private;
765 struct drm_device *dev = connector->dev;
766 struct drm_crtc *crtc = NULL;
767 struct dm_crtc_state *dm_crtc_state = NULL;
771 mutex_lock(&dev->mode_config.mutex);
772 drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
774 if (connector->state == NULL)
777 crtc = connector->state->crtc;
781 drm_modeset_lock(&crtc->mutex, NULL);
782 if (crtc->state == NULL)
785 dm_crtc_state = to_dm_crtc_state(crtc->state);
786 if (dm_crtc_state->stream == NULL)
789 switch (dm_crtc_state->stream->timing.display_color_depth) {
790 case COLOR_DEPTH_666:
793 case COLOR_DEPTH_888:
796 case COLOR_DEPTH_101010:
799 case COLOR_DEPTH_121212:
802 case COLOR_DEPTH_161616:
809 seq_printf(m, "Current: %u\n", bpc);
810 seq_printf(m, "Maximum: %u\n", connector->display_info.bpc);
815 drm_modeset_unlock(&crtc->mutex);
817 drm_modeset_unlock(&dev->mode_config.connection_mutex);
818 mutex_unlock(&dev->mode_config.mutex);
823 #ifdef CONFIG_DRM_AMD_DC_HDCP
825 * Returns the HDCP capability of the Display (1.4 for now).
827 * NOTE* Not all HDMI displays report their HDCP caps even when they are capable.
828 * Since its rare for a display to not be HDCP 1.4 capable, we set HDMI as always capable.
830 * Example usage: cat /sys/kernel/debug/dri/0/DP-1/hdcp_sink_capability
831 * or cat /sys/kernel/debug/dri/0/HDMI-A-1/hdcp_sink_capability
833 static int hdcp_sink_capability_show(struct seq_file *m, void *data)
835 struct drm_connector *connector = m->private;
836 struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);
837 bool hdcp_cap, hdcp2_cap;
839 if (connector->status != connector_status_connected)
842 seq_printf(m, "%s:%d HDCP version: ", connector->name, connector->base.id);
844 hdcp_cap = dc_link_is_hdcp14(aconnector->dc_link, aconnector->dc_sink->sink_signal);
845 hdcp2_cap = dc_link_is_hdcp22(aconnector->dc_link, aconnector->dc_sink->sink_signal);
849 seq_printf(m, "%s ", "HDCP1.4");
851 seq_printf(m, "%s ", "HDCP2.2");
853 if (!hdcp_cap && !hdcp2_cap)
854 seq_printf(m, "%s ", "None");
861 /* function description
863 * generic SDP message access for testing
865 * debugfs sdp_message is located at /syskernel/debug/dri/0/DP-x
868 * Hb0 : Secondary-Data Packet ID
869 * Hb1 : Secondary-Data Packet type
870 * Hb2 : Secondary-Data-packet-specific header, Byte 0
871 * Hb3 : Secondary-Data-packet-specific header, Byte 1
873 * for using custom sdp message: input 4 bytes SDP header and 32 bytes raw data
875 static ssize_t dp_sdp_message_debugfs_write(struct file *f, const char __user *buf,
876 size_t size, loff_t *pos)
880 struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
881 struct dm_crtc_state *acrtc_state;
882 uint32_t write_size = 36;
884 if (connector->base.status != connector_status_connected)
890 acrtc_state = to_dm_crtc_state(connector->base.state->crtc->state);
892 r = copy_from_user(data, buf, write_size);
896 dc_stream_send_dp_sdp(acrtc_state->stream, data, write_size);
901 static ssize_t dp_dpcd_address_write(struct file *f, const char __user *buf,
902 size_t size, loff_t *pos)
905 struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
907 if (size < sizeof(connector->debugfs_dpcd_address))
910 r = copy_from_user(&connector->debugfs_dpcd_address,
911 buf, sizeof(connector->debugfs_dpcd_address));
916 static ssize_t dp_dpcd_size_write(struct file *f, const char __user *buf,
917 size_t size, loff_t *pos)
920 struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
922 if (size < sizeof(connector->debugfs_dpcd_size))
925 r = copy_from_user(&connector->debugfs_dpcd_size,
926 buf, sizeof(connector->debugfs_dpcd_size));
928 if (connector->debugfs_dpcd_size > 256)
929 connector->debugfs_dpcd_size = 0;
934 static ssize_t dp_dpcd_data_write(struct file *f, const char __user *buf,
935 size_t size, loff_t *pos)
939 struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
940 struct dc_link *link = connector->dc_link;
941 uint32_t write_size = connector->debugfs_dpcd_size;
943 if (size < write_size)
946 data = kzalloc(write_size, GFP_KERNEL);
950 r = copy_from_user(data, buf, write_size);
952 dm_helpers_dp_write_dpcd(link->ctx, link,
953 connector->debugfs_dpcd_address, data, write_size - r);
955 return write_size - r;
958 static ssize_t dp_dpcd_data_read(struct file *f, char __user *buf,
959 size_t size, loff_t *pos)
963 struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
964 struct dc_link *link = connector->dc_link;
965 uint32_t read_size = connector->debugfs_dpcd_size;
967 if (size < read_size)
970 data = kzalloc(read_size, GFP_KERNEL);
974 dm_helpers_dp_read_dpcd(link->ctx, link,
975 connector->debugfs_dpcd_address, data, read_size);
977 r = copy_to_user(buf, data, read_size);
980 return read_size - r;
983 static ssize_t dp_dsc_clock_en_read(struct file *f, char __user *buf,
984 size_t size, loff_t *pos)
987 char *rd_buf_ptr = NULL;
988 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
989 struct display_stream_compressor *dsc;
990 struct dcn_dsc_state dsc_state = {0};
991 const uint32_t rd_buf_size = 10;
992 struct pipe_ctx *pipe_ctx;
994 int i, r, str_len = 30;
996 rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
1001 rd_buf_ptr = rd_buf;
1003 for (i = 0; i < MAX_PIPES; i++) {
1004 pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
1005 if (pipe_ctx && pipe_ctx->stream &&
1006 pipe_ctx->stream->link == aconnector->dc_link)
1013 dsc = pipe_ctx->stream_res.dsc;
1015 dsc->funcs->dsc_read_state(dsc, &dsc_state);
1017 snprintf(rd_buf_ptr, str_len,
1019 dsc_state.dsc_clock_en);
1020 rd_buf_ptr += str_len;
1023 if (*pos >= rd_buf_size)
1026 r = put_user(*(rd_buf + result), buf);
1028 return r; /* r = -EFAULT */
1040 static ssize_t dp_dsc_slice_width_read(struct file *f, char __user *buf,
1041 size_t size, loff_t *pos)
1043 char *rd_buf = NULL;
1044 char *rd_buf_ptr = NULL;
1045 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
1046 struct display_stream_compressor *dsc;
1047 struct dcn_dsc_state dsc_state = {0};
1048 const uint32_t rd_buf_size = 100;
1049 struct pipe_ctx *pipe_ctx;
1051 int i, r, str_len = 30;
1053 rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
1058 rd_buf_ptr = rd_buf;
1060 for (i = 0; i < MAX_PIPES; i++) {
1061 pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
1062 if (pipe_ctx && pipe_ctx->stream &&
1063 pipe_ctx->stream->link == aconnector->dc_link)
1070 dsc = pipe_ctx->stream_res.dsc;
1072 dsc->funcs->dsc_read_state(dsc, &dsc_state);
1074 snprintf(rd_buf_ptr, str_len,
1076 dsc_state.dsc_slice_width);
1077 rd_buf_ptr += str_len;
1080 if (*pos >= rd_buf_size)
1083 r = put_user(*(rd_buf + result), buf);
1085 return r; /* r = -EFAULT */
1097 static ssize_t dp_dsc_slice_height_read(struct file *f, char __user *buf,
1098 size_t size, loff_t *pos)
1100 char *rd_buf = NULL;
1101 char *rd_buf_ptr = NULL;
1102 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
1103 struct display_stream_compressor *dsc;
1104 struct dcn_dsc_state dsc_state = {0};
1105 const uint32_t rd_buf_size = 100;
1106 struct pipe_ctx *pipe_ctx;
1108 int i, r, str_len = 30;
1110 rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
1115 rd_buf_ptr = rd_buf;
1117 for (i = 0; i < MAX_PIPES; i++) {
1118 pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
1119 if (pipe_ctx && pipe_ctx->stream &&
1120 pipe_ctx->stream->link == aconnector->dc_link)
1127 dsc = pipe_ctx->stream_res.dsc;
1129 dsc->funcs->dsc_read_state(dsc, &dsc_state);
1131 snprintf(rd_buf_ptr, str_len,
1133 dsc_state.dsc_slice_height);
1134 rd_buf_ptr += str_len;
1137 if (*pos >= rd_buf_size)
1140 r = put_user(*(rd_buf + result), buf);
1142 return r; /* r = -EFAULT */
1154 static ssize_t dp_dsc_bits_per_pixel_read(struct file *f, char __user *buf,
1155 size_t size, loff_t *pos)
1157 char *rd_buf = NULL;
1158 char *rd_buf_ptr = NULL;
1159 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
1160 struct display_stream_compressor *dsc;
1161 struct dcn_dsc_state dsc_state = {0};
1162 const uint32_t rd_buf_size = 100;
1163 struct pipe_ctx *pipe_ctx;
1165 int i, r, str_len = 30;
1167 rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
1172 rd_buf_ptr = rd_buf;
1174 for (i = 0; i < MAX_PIPES; i++) {
1175 pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
1176 if (pipe_ctx && pipe_ctx->stream &&
1177 pipe_ctx->stream->link == aconnector->dc_link)
1184 dsc = pipe_ctx->stream_res.dsc;
1186 dsc->funcs->dsc_read_state(dsc, &dsc_state);
1188 snprintf(rd_buf_ptr, str_len,
1190 dsc_state.dsc_bits_per_pixel);
1191 rd_buf_ptr += str_len;
1194 if (*pos >= rd_buf_size)
1197 r = put_user(*(rd_buf + result), buf);
1199 return r; /* r = -EFAULT */
1211 static ssize_t dp_dsc_pic_width_read(struct file *f, char __user *buf,
1212 size_t size, loff_t *pos)
1214 char *rd_buf = NULL;
1215 char *rd_buf_ptr = NULL;
1216 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
1217 struct display_stream_compressor *dsc;
1218 struct dcn_dsc_state dsc_state = {0};
1219 const uint32_t rd_buf_size = 100;
1220 struct pipe_ctx *pipe_ctx;
1222 int i, r, str_len = 30;
1224 rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
1229 rd_buf_ptr = rd_buf;
1231 for (i = 0; i < MAX_PIPES; i++) {
1232 pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
1233 if (pipe_ctx && pipe_ctx->stream &&
1234 pipe_ctx->stream->link == aconnector->dc_link)
1241 dsc = pipe_ctx->stream_res.dsc;
1243 dsc->funcs->dsc_read_state(dsc, &dsc_state);
1245 snprintf(rd_buf_ptr, str_len,
1247 dsc_state.dsc_pic_width);
1248 rd_buf_ptr += str_len;
1251 if (*pos >= rd_buf_size)
1254 r = put_user(*(rd_buf + result), buf);
1256 return r; /* r = -EFAULT */
1268 static ssize_t dp_dsc_pic_height_read(struct file *f, char __user *buf,
1269 size_t size, loff_t *pos)
1271 char *rd_buf = NULL;
1272 char *rd_buf_ptr = NULL;
1273 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
1274 struct display_stream_compressor *dsc;
1275 struct dcn_dsc_state dsc_state = {0};
1276 const uint32_t rd_buf_size = 100;
1277 struct pipe_ctx *pipe_ctx;
1279 int i, r, str_len = 30;
1281 rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
1286 rd_buf_ptr = rd_buf;
1288 for (i = 0; i < MAX_PIPES; i++) {
1289 pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
1290 if (pipe_ctx && pipe_ctx->stream &&
1291 pipe_ctx->stream->link == aconnector->dc_link)
1298 dsc = pipe_ctx->stream_res.dsc;
1300 dsc->funcs->dsc_read_state(dsc, &dsc_state);
1302 snprintf(rd_buf_ptr, str_len,
1304 dsc_state.dsc_pic_height);
1305 rd_buf_ptr += str_len;
1308 if (*pos >= rd_buf_size)
1311 r = put_user(*(rd_buf + result), buf);
1313 return r; /* r = -EFAULT */
1325 static ssize_t dp_dsc_chunk_size_read(struct file *f, char __user *buf,
1326 size_t size, loff_t *pos)
1328 char *rd_buf = NULL;
1329 char *rd_buf_ptr = NULL;
1330 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
1331 struct display_stream_compressor *dsc;
1332 struct dcn_dsc_state dsc_state = {0};
1333 const uint32_t rd_buf_size = 100;
1334 struct pipe_ctx *pipe_ctx;
1336 int i, r, str_len = 30;
1338 rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
1343 rd_buf_ptr = rd_buf;
1345 for (i = 0; i < MAX_PIPES; i++) {
1346 pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
1347 if (pipe_ctx && pipe_ctx->stream &&
1348 pipe_ctx->stream->link == aconnector->dc_link)
1355 dsc = pipe_ctx->stream_res.dsc;
1357 dsc->funcs->dsc_read_state(dsc, &dsc_state);
1359 snprintf(rd_buf_ptr, str_len,
1361 dsc_state.dsc_chunk_size);
1362 rd_buf_ptr += str_len;
1365 if (*pos >= rd_buf_size)
1368 r = put_user(*(rd_buf + result), buf);
1370 return r; /* r = -EFAULT */
1382 static ssize_t dp_dsc_slice_bpg_offset_read(struct file *f, char __user *buf,
1383 size_t size, loff_t *pos)
1385 char *rd_buf = NULL;
1386 char *rd_buf_ptr = NULL;
1387 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
1388 struct display_stream_compressor *dsc;
1389 struct dcn_dsc_state dsc_state = {0};
1390 const uint32_t rd_buf_size = 100;
1391 struct pipe_ctx *pipe_ctx;
1393 int i, r, str_len = 30;
1395 rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
1400 rd_buf_ptr = rd_buf;
1402 for (i = 0; i < MAX_PIPES; i++) {
1403 pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
1404 if (pipe_ctx && pipe_ctx->stream &&
1405 pipe_ctx->stream->link == aconnector->dc_link)
1412 dsc = pipe_ctx->stream_res.dsc;
1414 dsc->funcs->dsc_read_state(dsc, &dsc_state);
1416 snprintf(rd_buf_ptr, str_len,
1418 dsc_state.dsc_slice_bpg_offset);
1419 rd_buf_ptr += str_len;
1422 if (*pos >= rd_buf_size)
1425 r = put_user(*(rd_buf + result), buf);
1427 return r; /* r = -EFAULT */
1439 DEFINE_SHOW_ATTRIBUTE(dmub_fw_state);
1440 DEFINE_SHOW_ATTRIBUTE(dmub_tracebuffer);
1441 DEFINE_SHOW_ATTRIBUTE(output_bpc);
1442 #ifdef CONFIG_DRM_AMD_DC_HDCP
1443 DEFINE_SHOW_ATTRIBUTE(hdcp_sink_capability);
1446 static const struct file_operations dp_dsc_clock_en_debugfs_fops = {
1447 .owner = THIS_MODULE,
1448 .read = dp_dsc_clock_en_read,
1449 .llseek = default_llseek
1452 static const struct file_operations dp_dsc_slice_width_debugfs_fops = {
1453 .owner = THIS_MODULE,
1454 .read = dp_dsc_slice_width_read,
1455 .llseek = default_llseek
1458 static const struct file_operations dp_dsc_slice_height_debugfs_fops = {
1459 .owner = THIS_MODULE,
1460 .read = dp_dsc_slice_height_read,
1461 .llseek = default_llseek
1464 static const struct file_operations dp_dsc_bits_per_pixel_debugfs_fops = {
1465 .owner = THIS_MODULE,
1466 .read = dp_dsc_bits_per_pixel_read,
1467 .llseek = default_llseek
1470 static const struct file_operations dp_dsc_pic_width_debugfs_fops = {
1471 .owner = THIS_MODULE,
1472 .read = dp_dsc_pic_width_read,
1473 .llseek = default_llseek
1476 static const struct file_operations dp_dsc_pic_height_debugfs_fops = {
1477 .owner = THIS_MODULE,
1478 .read = dp_dsc_pic_height_read,
1479 .llseek = default_llseek
1482 static const struct file_operations dp_dsc_chunk_size_debugfs_fops = {
1483 .owner = THIS_MODULE,
1484 .read = dp_dsc_chunk_size_read,
1485 .llseek = default_llseek
1488 static const struct file_operations dp_dsc_slice_bpg_offset_debugfs_fops = {
1489 .owner = THIS_MODULE,
1490 .read = dp_dsc_slice_bpg_offset_read,
1491 .llseek = default_llseek
1494 static const struct file_operations dp_link_settings_debugfs_fops = {
1495 .owner = THIS_MODULE,
1496 .read = dp_link_settings_read,
1497 .write = dp_link_settings_write,
1498 .llseek = default_llseek
1501 static const struct file_operations dp_phy_settings_debugfs_fop = {
1502 .owner = THIS_MODULE,
1503 .read = dp_phy_settings_read,
1504 .write = dp_phy_settings_write,
1505 .llseek = default_llseek
1508 static const struct file_operations dp_phy_test_pattern_fops = {
1509 .owner = THIS_MODULE,
1510 .write = dp_phy_test_pattern_debugfs_write,
1511 .llseek = default_llseek
1514 static const struct file_operations sdp_message_fops = {
1515 .owner = THIS_MODULE,
1516 .write = dp_sdp_message_debugfs_write,
1517 .llseek = default_llseek
1520 static const struct file_operations dp_dpcd_address_debugfs_fops = {
1521 .owner = THIS_MODULE,
1522 .write = dp_dpcd_address_write,
1523 .llseek = default_llseek
1526 static const struct file_operations dp_dpcd_size_debugfs_fops = {
1527 .owner = THIS_MODULE,
1528 .write = dp_dpcd_size_write,
1529 .llseek = default_llseek
1532 static const struct file_operations dp_dpcd_data_debugfs_fops = {
1533 .owner = THIS_MODULE,
1534 .read = dp_dpcd_data_read,
1535 .write = dp_dpcd_data_write,
1536 .llseek = default_llseek
1539 static const struct {
1541 const struct file_operations *fops;
1542 } dp_debugfs_entries[] = {
1543 {"link_settings", &dp_link_settings_debugfs_fops},
1544 {"phy_settings", &dp_phy_settings_debugfs_fop},
1545 {"test_pattern", &dp_phy_test_pattern_fops},
1546 #ifdef CONFIG_DRM_AMD_DC_HDCP
1547 {"hdcp_sink_capability", &hdcp_sink_capability_fops},
1549 {"sdp_message", &sdp_message_fops},
1550 {"aux_dpcd_address", &dp_dpcd_address_debugfs_fops},
1551 {"aux_dpcd_size", &dp_dpcd_size_debugfs_fops},
1552 {"aux_dpcd_data", &dp_dpcd_data_debugfs_fops},
1553 {"dsc_clock_en", &dp_dsc_clock_en_debugfs_fops},
1554 {"dsc_slice_width", &dp_dsc_slice_width_debugfs_fops},
1555 {"dsc_slice_height", &dp_dsc_slice_height_debugfs_fops},
1556 {"dsc_bits_per_pixel", &dp_dsc_bits_per_pixel_debugfs_fops},
1557 {"dsc_pic_width", &dp_dsc_pic_width_debugfs_fops},
1558 {"dsc_pic_height", &dp_dsc_pic_height_debugfs_fops},
1559 {"dsc_chunk_size", &dp_dsc_chunk_size_debugfs_fops},
1560 {"dsc_slice_bpg", &dp_dsc_slice_bpg_offset_debugfs_fops}
1563 #ifdef CONFIG_DRM_AMD_DC_HDCP
1564 static const struct {
1566 const struct file_operations *fops;
1567 } hdmi_debugfs_entries[] = {
1568 {"hdcp_sink_capability", &hdcp_sink_capability_fops}
1572 * Force YUV420 output if available from the given mode
1574 static int force_yuv420_output_set(void *data, u64 val)
1576 struct amdgpu_dm_connector *connector = data;
1578 connector->force_yuv420_output = (bool)val;
1584 * Check if YUV420 is forced when available from the given mode
1586 static int force_yuv420_output_get(void *data, u64 *val)
1588 struct amdgpu_dm_connector *connector = data;
1590 *val = connector->force_yuv420_output;
1595 DEFINE_DEBUGFS_ATTRIBUTE(force_yuv420_output_fops, force_yuv420_output_get,
1596 force_yuv420_output_set, "%llu\n");
1601 static int psr_get(void *data, u64 *val)
1603 struct amdgpu_dm_connector *connector = data;
1604 struct dc_link *link = connector->dc_link;
1605 uint32_t psr_state = 0;
1607 dc_link_get_psr_state(link, &psr_state);
1615 DEFINE_DEBUGFS_ATTRIBUTE(psr_fops, psr_get, NULL, "%llu\n");
1617 void connector_debugfs_init(struct amdgpu_dm_connector *connector)
1620 struct dentry *dir = connector->base.debugfs_entry;
1622 if (connector->base.connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
1623 connector->base.connector_type == DRM_MODE_CONNECTOR_eDP) {
1624 for (i = 0; i < ARRAY_SIZE(dp_debugfs_entries); i++) {
1625 debugfs_create_file(dp_debugfs_entries[i].name,
1626 0644, dir, connector,
1627 dp_debugfs_entries[i].fops);
1630 if (connector->base.connector_type == DRM_MODE_CONNECTOR_eDP)
1631 debugfs_create_file_unsafe("psr_state", 0444, dir, connector, &psr_fops);
1633 debugfs_create_file_unsafe("force_yuv420_output", 0644, dir, connector,
1634 &force_yuv420_output_fops);
1636 debugfs_create_file("output_bpc", 0644, dir, connector,
1639 connector->debugfs_dpcd_address = 0;
1640 connector->debugfs_dpcd_size = 0;
1642 #ifdef CONFIG_DRM_AMD_DC_HDCP
1643 if (connector->base.connector_type == DRM_MODE_CONNECTOR_HDMIA) {
1644 for (i = 0; i < ARRAY_SIZE(hdmi_debugfs_entries); i++) {
1645 debugfs_create_file(hdmi_debugfs_entries[i].name,
1646 0644, dir, connector,
1647 hdmi_debugfs_entries[i].fops);
1654 * Writes DTN log state to the user supplied buffer.
1655 * Example usage: cat /sys/kernel/debug/dri/0/amdgpu_dm_dtn_log
1657 static ssize_t dtn_log_read(
1663 struct amdgpu_device *adev = file_inode(f)->i_private;
1664 struct dc *dc = adev->dm.dc;
1665 struct dc_log_buffer_ctx log_ctx = { 0 };
1671 if (!dc->hwss.log_hw_state)
1674 dc->hwss.log_hw_state(dc, &log_ctx);
1676 if (*pos < log_ctx.pos) {
1677 size_t to_copy = log_ctx.pos - *pos;
1679 to_copy = min(to_copy, size);
1681 if (!copy_to_user(buf, log_ctx.buf + *pos, to_copy)) {
1693 * Writes DTN log state to dmesg when triggered via a write.
1694 * Example usage: echo 1 > /sys/kernel/debug/dri/0/amdgpu_dm_dtn_log
1696 static ssize_t dtn_log_write(
1698 const char __user *buf,
1702 struct amdgpu_device *adev = file_inode(f)->i_private;
1703 struct dc *dc = adev->dm.dc;
1705 /* Write triggers log output via dmesg. */
1709 if (dc->hwss.log_hw_state)
1710 dc->hwss.log_hw_state(dc, NULL);
1716 * Backlight at this moment. Read only.
1717 * As written to display, taking ABM and backlight lut into account.
1718 * Ranges from 0x0 to 0x10000 (= 100% PWM)
1720 static int current_backlight_read(struct seq_file *m, void *data)
1722 struct drm_info_node *node = (struct drm_info_node *)m->private;
1723 struct drm_device *dev = node->minor->dev;
1724 struct amdgpu_device *adev = dev->dev_private;
1725 struct amdgpu_display_manager *dm = &adev->dm;
1727 unsigned int backlight = dc_link_get_backlight_level(dm->backlight_link);
1729 seq_printf(m, "0x%x\n", backlight);
1734 * Backlight value that is being approached. Read only.
1735 * As written to display, taking ABM and backlight lut into account.
1736 * Ranges from 0x0 to 0x10000 (= 100% PWM)
1738 static int target_backlight_read(struct seq_file *m, void *data)
1740 struct drm_info_node *node = (struct drm_info_node *)m->private;
1741 struct drm_device *dev = node->minor->dev;
1742 struct amdgpu_device *adev = dev->dev_private;
1743 struct amdgpu_display_manager *dm = &adev->dm;
1745 unsigned int backlight = dc_link_get_target_backlight_pwm(dm->backlight_link);
1747 seq_printf(m, "0x%x\n", backlight);
1751 static int mst_topo(struct seq_file *m, void *unused)
1753 struct drm_info_node *node = (struct drm_info_node *)m->private;
1754 struct drm_device *dev = node->minor->dev;
1755 struct drm_connector *connector;
1756 struct drm_connector_list_iter conn_iter;
1757 struct amdgpu_dm_connector *aconnector;
1759 drm_connector_list_iter_begin(dev, &conn_iter);
1760 drm_for_each_connector_iter(connector, &conn_iter) {
1761 if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort)
1764 aconnector = to_amdgpu_dm_connector(connector);
1766 seq_printf(m, "\nMST topology for connector %d\n", aconnector->connector_id);
1767 drm_dp_mst_dump_topology(m, &aconnector->mst_mgr);
1769 drm_connector_list_iter_end(&conn_iter);
1774 static const struct drm_info_list amdgpu_dm_debugfs_list[] = {
1775 {"amdgpu_current_backlight_pwm", ¤t_backlight_read},
1776 {"amdgpu_target_backlight_pwm", &target_backlight_read},
1777 {"amdgpu_mst_topology", &mst_topo},
1781 * Sets the DC visual confirm debug option from the given string.
1782 * Example usage: echo 1 > /sys/kernel/debug/dri/0/amdgpu_visual_confirm
1784 static int visual_confirm_set(void *data, u64 val)
1786 struct amdgpu_device *adev = data;
1788 adev->dm.dc->debug.visual_confirm = (enum visual_confirm)val;
1794 * Reads the DC visual confirm debug option value into the given buffer.
1795 * Example usage: cat /sys/kernel/debug/dri/0/amdgpu_dm_visual_confirm
1797 static int visual_confirm_get(void *data, u64 *val)
1799 struct amdgpu_device *adev = data;
1801 *val = adev->dm.dc->debug.visual_confirm;
1806 DEFINE_DEBUGFS_ATTRIBUTE(visual_confirm_fops, visual_confirm_get,
1807 visual_confirm_set, "%llu\n");
1809 int dtn_debugfs_init(struct amdgpu_device *adev)
1811 static const struct file_operations dtn_log_fops = {
1812 .owner = THIS_MODULE,
1813 .read = dtn_log_read,
1814 .write = dtn_log_write,
1815 .llseek = default_llseek
1818 struct drm_minor *minor = adev->ddev->primary;
1819 struct dentry *root = minor->debugfs_root;
1822 ret = amdgpu_debugfs_add_files(adev, amdgpu_dm_debugfs_list,
1823 ARRAY_SIZE(amdgpu_dm_debugfs_list));
1827 debugfs_create_file("amdgpu_dm_dtn_log", 0644, root, adev,
1830 debugfs_create_file_unsafe("amdgpu_dm_visual_confirm", 0644, root, adev,
1831 &visual_confirm_fops);
1833 debugfs_create_file_unsafe("amdgpu_dm_dmub_tracebuffer", 0644, root,
1834 adev, &dmub_tracebuffer_fops);
1836 debugfs_create_file_unsafe("amdgpu_dm_dmub_fw_state", 0644, root,
1837 adev, &dmub_fw_state_fops);