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 {
52 static inline const char *yesno(bool v)
54 return v ? "yes" : "no";
57 /* parse_write_buffer_into_params - Helper function to parse debugfs write buffer into an array
59 * Function takes in attributes passed to debugfs write entry
60 * and writes into param array.
61 * The user passes max_param_num to identify maximum number of
62 * parameters that could be parsed.
65 static int parse_write_buffer_into_params(char *wr_buf, uint32_t wr_buf_size,
66 long *param, const char __user *buf,
70 char *wr_buf_ptr = NULL;
71 uint32_t wr_buf_count = 0;
74 const char delimiter[3] = {' ', '\n', '\0'};
75 uint8_t param_index = 0;
81 r = copy_from_user(wr_buf_ptr, buf, wr_buf_size);
83 /* r is bytes not be copied */
84 if (r >= wr_buf_size) {
85 DRM_DEBUG_DRIVER("user data not be read\n");
89 /* check number of parameters. isspace could not differ space and \n */
90 while ((*wr_buf_ptr != 0xa) && (wr_buf_count < wr_buf_size)) {
92 while (isspace(*wr_buf_ptr) && (wr_buf_count < wr_buf_size)) {
97 if (wr_buf_count == wr_buf_size)
101 while ((!isspace(*wr_buf_ptr)) && (wr_buf_count < wr_buf_size)) {
108 if (wr_buf_count == wr_buf_size)
112 if (*param_nums > max_param_num)
113 *param_nums = max_param_num;
115 wr_buf_ptr = wr_buf; /* reset buf pointer */
116 wr_buf_count = 0; /* number of char already checked */
118 while (isspace(*wr_buf_ptr) && (wr_buf_count < wr_buf_size)) {
123 while (param_index < *param_nums) {
124 /* after strsep, wr_buf_ptr will be moved to after space */
125 sub_str = strsep(&wr_buf_ptr, delimiter);
127 r = kstrtol(sub_str, 16, &(param[param_index]));
130 DRM_DEBUG_DRIVER("string to int convert error code: %d\n", r);
138 /* function description
139 * get/ set DP configuration: lane_count, link_rate, spread_spectrum
141 * valid lane count value: 1, 2, 4
142 * valid link rate value:
143 * 06h = 1.62Gbps per lane
144 * 0Ah = 2.7Gbps per lane
145 * 0Ch = 3.24Gbps per lane
146 * 14h = 5.4Gbps per lane
147 * 1Eh = 8.1Gbps per lane
149 * debugfs is located at /sys/kernel/debug/dri/0/DP-x/link_settings
151 * --- to get dp configuration
155 * It will list current, verified, reported, preferred dp configuration.
156 * current -- for current video mode
157 * verified --- maximum configuration which pass link training
158 * reported --- DP rx report caps (DPCD register offset 0, 1 2)
159 * preferred --- user force settings
161 * --- set (or force) dp configuration
163 * echo <lane_count> <link_rate> > link_settings
165 * for example, to force to 2 lane, 2.7GHz,
166 * echo 4 0xa > link_settings
168 * spread_spectrum could not be changed dynamically.
170 * in case invalid lane count, link rate are force, no hw programming will be
171 * done. please check link settings after force operation to see if HW get
176 * check current and preferred settings.
179 static ssize_t dp_link_settings_read(struct file *f, char __user *buf,
180 size_t size, loff_t *pos)
182 struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
183 struct dc_link *link = connector->dc_link;
185 char *rd_buf_ptr = NULL;
186 const uint32_t rd_buf_size = 100;
191 if (*pos & 3 || size & 3)
194 rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
200 str_len = strlen("Current: %d %d %d ");
201 snprintf(rd_buf_ptr, str_len, "Current: %d %d %d ",
202 link->cur_link_settings.lane_count,
203 link->cur_link_settings.link_rate,
204 link->cur_link_settings.link_spread);
205 rd_buf_ptr += str_len;
207 str_len = strlen("Verified: %d %d %d ");
208 snprintf(rd_buf_ptr, str_len, "Verified: %d %d %d ",
209 link->verified_link_cap.lane_count,
210 link->verified_link_cap.link_rate,
211 link->verified_link_cap.link_spread);
212 rd_buf_ptr += str_len;
214 str_len = strlen("Reported: %d %d %d ");
215 snprintf(rd_buf_ptr, str_len, "Reported: %d %d %d ",
216 link->reported_link_cap.lane_count,
217 link->reported_link_cap.link_rate,
218 link->reported_link_cap.link_spread);
219 rd_buf_ptr += str_len;
221 str_len = strlen("Preferred: %d %d %d ");
222 snprintf(rd_buf_ptr, str_len, "Preferred: %d %d %d\n",
223 link->preferred_link_setting.lane_count,
224 link->preferred_link_setting.link_rate,
225 link->preferred_link_setting.link_spread);
228 if (*pos >= rd_buf_size)
231 r = put_user(*(rd_buf + result), buf);
233 return r; /* r = -EFAULT */
245 static ssize_t dp_link_settings_write(struct file *f, const char __user *buf,
246 size_t size, loff_t *pos)
248 struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
249 struct dc_link *link = connector->dc_link;
250 struct dc *dc = (struct dc *)link->dc;
251 struct dc_link_settings prefer_link_settings;
253 const uint32_t wr_buf_size = 40;
254 /* 0: lane_count; 1: link_rate */
255 int max_param_num = 2;
256 uint8_t param_nums = 0;
258 bool valid_input = false;
263 wr_buf = kcalloc(wr_buf_size, sizeof(char), GFP_KERNEL);
267 if (parse_write_buffer_into_params(wr_buf, size,
275 if (param_nums <= 0) {
277 DRM_DEBUG_DRIVER("user data not be read\n");
284 case LANE_COUNT_FOUR:
295 case LINK_RATE_HIGH2:
296 case LINK_RATE_HIGH3:
305 DRM_DEBUG_DRIVER("Invalid Input value No HW will be programmed\n");
309 /* save user force lane_count, link_rate to preferred settings
310 * spread spectrum will not be changed
312 prefer_link_settings.link_spread = link->cur_link_settings.link_spread;
313 prefer_link_settings.lane_count = param[0];
314 prefer_link_settings.link_rate = param[1];
316 dc_link_set_preferred_link_settings(dc, &prefer_link_settings, link);
322 /* function: get current DP PHY settings: voltage swing, pre-emphasis,
323 * post-cursor2 (defined by VESA DP specification)
326 * voltage swing: 0,1,2,3
327 * pre-emphasis : 0,1,2,3
328 * post cursor2 : 0,1,2,3
331 * how to use this debugfs
333 * debugfs is located at /sys/kernel/debug/dri/0/DP-x
335 * there will be directories, like DP-1, DP-2,DP-3, etc. for DP display
337 * To figure out which DP-x is the display for DP to be check,
340 * There should be debugfs file, like link_settings, phy_settings.
342 * from lane_count, link_rate to figure which DP-x is for display to be worked
345 * To get current DP PHY settings,
348 * To change DP PHY settings,
349 * echo <voltage_swing> <pre-emphasis> <post_cursor2> > phy_settings
350 * for examle, to change voltage swing to 2, pre-emphasis to 3, post_cursor2 to
352 * echo 2 3 0 > phy_settings
354 * To check if change be applied, get current phy settings by
357 * In case invalid values are set by user, like
358 * echo 1 4 0 > phy_settings
360 * HW will NOT be programmed by these settings.
361 * cat phy_settings will show the previous valid settings.
363 static ssize_t dp_phy_settings_read(struct file *f, char __user *buf,
364 size_t size, loff_t *pos)
366 struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
367 struct dc_link *link = connector->dc_link;
369 const uint32_t rd_buf_size = 20;
373 if (*pos & 3 || size & 3)
376 rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
380 snprintf(rd_buf, rd_buf_size, " %d %d %d ",
381 link->cur_lane_setting.VOLTAGE_SWING,
382 link->cur_lane_setting.PRE_EMPHASIS,
383 link->cur_lane_setting.POST_CURSOR2);
386 if (*pos >= rd_buf_size)
389 r = put_user((*(rd_buf + result)), buf);
391 return r; /* r = -EFAULT */
403 static ssize_t dp_phy_settings_write(struct file *f, const char __user *buf,
404 size_t size, loff_t *pos)
406 struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
407 struct dc_link *link = connector->dc_link;
408 struct dc *dc = (struct dc *)link->dc;
410 uint32_t wr_buf_size = 40;
412 bool use_prefer_link_setting;
413 struct link_training_settings link_lane_settings;
414 int max_param_num = 3;
415 uint8_t param_nums = 0;
422 wr_buf = kcalloc(wr_buf_size, sizeof(char), GFP_KERNEL);
426 if (parse_write_buffer_into_params(wr_buf, size,
434 if (param_nums <= 0) {
436 DRM_DEBUG_DRIVER("user data not be read\n");
440 if ((param[0] > VOLTAGE_SWING_MAX_LEVEL) ||
441 (param[1] > PRE_EMPHASIS_MAX_LEVEL) ||
442 (param[2] > POST_CURSOR2_MAX_LEVEL)) {
444 DRM_DEBUG_DRIVER("Invalid Input No HW will be programmed\n");
448 /* get link settings: lane count, link rate */
449 use_prefer_link_setting =
450 ((link->preferred_link_setting.link_rate != LINK_RATE_UNKNOWN) &&
451 (link->test_pattern_enabled));
453 memset(&link_lane_settings, 0, sizeof(link_lane_settings));
455 if (use_prefer_link_setting) {
456 link_lane_settings.link_settings.lane_count =
457 link->preferred_link_setting.lane_count;
458 link_lane_settings.link_settings.link_rate =
459 link->preferred_link_setting.link_rate;
460 link_lane_settings.link_settings.link_spread =
461 link->preferred_link_setting.link_spread;
463 link_lane_settings.link_settings.lane_count =
464 link->cur_link_settings.lane_count;
465 link_lane_settings.link_settings.link_rate =
466 link->cur_link_settings.link_rate;
467 link_lane_settings.link_settings.link_spread =
468 link->cur_link_settings.link_spread;
471 /* apply phy settings from user */
472 for (r = 0; r < link_lane_settings.link_settings.lane_count; r++) {
473 link_lane_settings.lane_settings[r].VOLTAGE_SWING =
474 (enum dc_voltage_swing) (param[0]);
475 link_lane_settings.lane_settings[r].PRE_EMPHASIS =
476 (enum dc_pre_emphasis) (param[1]);
477 link_lane_settings.lane_settings[r].POST_CURSOR2 =
478 (enum dc_post_cursor2) (param[2]);
481 /* program ASIC registers and DPCD registers */
482 dc_link_set_drive_settings(dc, &link_lane_settings, link);
488 /* function description
490 * set PHY layer or Link layer test pattern
491 * PHY test pattern is used for PHY SI check.
492 * Link layer test will not affect PHY SI.
494 * Reset Test Pattern:
495 * 0 = DP_TEST_PATTERN_VIDEO_MODE
497 * PHY test pattern supported:
498 * 1 = DP_TEST_PATTERN_D102
499 * 2 = DP_TEST_PATTERN_SYMBOL_ERROR
500 * 3 = DP_TEST_PATTERN_PRBS7
501 * 4 = DP_TEST_PATTERN_80BIT_CUSTOM
502 * 5 = DP_TEST_PATTERN_CP2520_1
503 * 6 = DP_TEST_PATTERN_CP2520_2 = DP_TEST_PATTERN_HBR2_COMPLIANCE_EYE
504 * 7 = DP_TEST_PATTERN_CP2520_3
506 * DP PHY Link Training Patterns
507 * 8 = DP_TEST_PATTERN_TRAINING_PATTERN1
508 * 9 = DP_TEST_PATTERN_TRAINING_PATTERN2
509 * a = DP_TEST_PATTERN_TRAINING_PATTERN3
510 * b = DP_TEST_PATTERN_TRAINING_PATTERN4
512 * DP Link Layer Test pattern
513 * c = DP_TEST_PATTERN_COLOR_SQUARES
514 * d = DP_TEST_PATTERN_COLOR_SQUARES_CEA
515 * e = DP_TEST_PATTERN_VERTICAL_BARS
516 * f = DP_TEST_PATTERN_HORIZONTAL_BARS
517 * 10= DP_TEST_PATTERN_COLOR_RAMP
519 * debugfs phy_test_pattern is located at /syskernel/debug/dri/0/DP-x
521 * --- set test pattern
522 * echo <test pattern #> > test_pattern
524 * If test pattern # is not supported, NO HW programming will be done.
525 * for DP_TEST_PATTERN_80BIT_CUSTOM, it needs extra 10 bytes of data
526 * for the user pattern. input 10 bytes data are separated by space
528 * echo 0x4 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88 0x99 0xaa > test_pattern
530 * --- reset test pattern
531 * echo 0 > test_pattern
533 * --- HPD detection is disabled when set PHY test pattern
535 * when PHY test pattern (pattern # within [1,7]) is set, HPD pin of HW ASIC
536 * is disable. User could unplug DP display from DP connected and plug scope to
537 * check test pattern PHY SI.
538 * If there is need unplug scope and plug DP display back, do steps below:
539 * echo 0 > phy_test_pattern
543 * "echo 0 > phy_test_pattern" will re-enable HPD pin again so that video sw
544 * driver could detect "unplug scope" and "plug DP display"
546 static ssize_t dp_phy_test_pattern_debugfs_write(struct file *f, const char __user *buf,
547 size_t size, loff_t *pos)
549 struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
550 struct dc_link *link = connector->dc_link;
552 uint32_t wr_buf_size = 100;
553 long param[11] = {0x0};
554 int max_param_num = 11;
555 enum dp_test_pattern test_pattern = DP_TEST_PATTERN_UNSUPPORTED;
556 bool disable_hpd = false;
557 bool valid_test_pattern = false;
558 uint8_t param_nums = 0;
559 /* init with default 80bit custom pattern */
560 uint8_t custom_pattern[10] = {
561 0x1f, 0x7c, 0xf0, 0xc1, 0x07,
562 0x1f, 0x7c, 0xf0, 0xc1, 0x07
564 struct dc_link_settings prefer_link_settings = {LANE_COUNT_UNKNOWN,
565 LINK_RATE_UNKNOWN, LINK_SPREAD_DISABLED};
566 struct dc_link_settings cur_link_settings = {LANE_COUNT_UNKNOWN,
567 LINK_RATE_UNKNOWN, LINK_SPREAD_DISABLED};
568 struct link_training_settings link_training_settings;
574 wr_buf = kcalloc(wr_buf_size, sizeof(char), GFP_KERNEL);
578 if (parse_write_buffer_into_params(wr_buf, size,
586 if (param_nums <= 0) {
588 DRM_DEBUG_DRIVER("user data not be read\n");
593 test_pattern = param[0];
595 switch (test_pattern) {
596 case DP_TEST_PATTERN_VIDEO_MODE:
597 case DP_TEST_PATTERN_COLOR_SQUARES:
598 case DP_TEST_PATTERN_COLOR_SQUARES_CEA:
599 case DP_TEST_PATTERN_VERTICAL_BARS:
600 case DP_TEST_PATTERN_HORIZONTAL_BARS:
601 case DP_TEST_PATTERN_COLOR_RAMP:
602 valid_test_pattern = true;
605 case DP_TEST_PATTERN_D102:
606 case DP_TEST_PATTERN_SYMBOL_ERROR:
607 case DP_TEST_PATTERN_PRBS7:
608 case DP_TEST_PATTERN_80BIT_CUSTOM:
609 case DP_TEST_PATTERN_HBR2_COMPLIANCE_EYE:
610 case DP_TEST_PATTERN_TRAINING_PATTERN4:
612 valid_test_pattern = true;
616 valid_test_pattern = false;
617 test_pattern = DP_TEST_PATTERN_UNSUPPORTED;
621 if (!valid_test_pattern) {
623 DRM_DEBUG_DRIVER("Invalid Test Pattern Parameters\n");
627 if (test_pattern == DP_TEST_PATTERN_80BIT_CUSTOM) {
628 for (i = 0; i < 10; i++) {
629 if ((uint8_t) param[i + 1] != 0x0)
634 /* not use default value */
635 for (i = 0; i < 10; i++)
636 custom_pattern[i] = (uint8_t) param[i + 1];
640 /* Usage: set DP physical test pattern using debugfs with normal DP
641 * panel. Then plug out DP panel and connect a scope to measure
642 * For normal video mode and test pattern generated from CRCT,
643 * they are visibile to user. So do not disable HPD.
644 * Video Mode is also set to clear the test pattern, so enable HPD
645 * because it might have been disabled after a test pattern was set.
646 * AUX depends on HPD * sequence dependent, do not move!
649 dc_link_enable_hpd(link);
651 prefer_link_settings.lane_count = link->verified_link_cap.lane_count;
652 prefer_link_settings.link_rate = link->verified_link_cap.link_rate;
653 prefer_link_settings.link_spread = link->verified_link_cap.link_spread;
655 cur_link_settings.lane_count = link->cur_link_settings.lane_count;
656 cur_link_settings.link_rate = link->cur_link_settings.link_rate;
657 cur_link_settings.link_spread = link->cur_link_settings.link_spread;
659 link_training_settings.link_settings = cur_link_settings;
662 if (test_pattern != DP_TEST_PATTERN_VIDEO_MODE) {
663 if (prefer_link_settings.lane_count != LANE_COUNT_UNKNOWN &&
664 prefer_link_settings.link_rate != LINK_RATE_UNKNOWN &&
665 (prefer_link_settings.lane_count != cur_link_settings.lane_count ||
666 prefer_link_settings.link_rate != cur_link_settings.link_rate))
667 link_training_settings.link_settings = prefer_link_settings;
670 for (i = 0; i < (unsigned int)(link_training_settings.link_settings.lane_count); i++)
671 link_training_settings.lane_settings[i] = link->cur_lane_setting;
673 dc_link_set_test_pattern(
676 DP_TEST_PATTERN_COLOR_SPACE_RGB,
677 &link_training_settings,
681 /* Usage: Set DP physical test pattern using AMDDP with normal DP panel
682 * Then plug out DP panel and connect a scope to measure DP PHY signal.
683 * Need disable interrupt to avoid SW driver disable DP output. This is
684 * done after the test pattern is set.
686 if (valid_test_pattern && disable_hpd)
687 dc_link_disable_hpd(link);
695 * Returns the DMCUB tracebuffer contents.
696 * Example usage: cat /sys/kernel/debug/dri/0/amdgpu_dm_dmub_tracebuffer
698 static int dmub_tracebuffer_show(struct seq_file *m, void *data)
700 struct amdgpu_device *adev = m->private;
701 struct dmub_srv_fb_info *fb_info = adev->dm.dmub_fb_info;
702 struct dmub_debugfs_trace_entry *entries;
704 uint32_t tbuf_size, max_entries, num_entries, i;
709 tbuf_base = (uint8_t *)fb_info->fb[DMUB_WINDOW_5_TRACEBUFF].cpu_addr;
713 tbuf_size = fb_info->fb[DMUB_WINDOW_5_TRACEBUFF].size;
714 max_entries = (tbuf_size - sizeof(struct dmub_debugfs_trace_header)) /
715 sizeof(struct dmub_debugfs_trace_entry);
718 ((struct dmub_debugfs_trace_header *)tbuf_base)->entry_count;
720 num_entries = min(num_entries, max_entries);
722 entries = (struct dmub_debugfs_trace_entry
724 sizeof(struct dmub_debugfs_trace_header));
726 for (i = 0; i < num_entries; ++i) {
727 struct dmub_debugfs_trace_entry *entry = &entries[i];
730 "trace_code=%u tick_count=%u param0=%u param1=%u\n",
731 entry->trace_code, entry->tick_count, entry->param0,
739 * Returns the DMCUB firmware state contents.
740 * Example usage: cat /sys/kernel/debug/dri/0/amdgpu_dm_dmub_fw_state
742 static int dmub_fw_state_show(struct seq_file *m, void *data)
744 struct amdgpu_device *adev = m->private;
745 struct dmub_srv_fb_info *fb_info = adev->dm.dmub_fb_info;
752 state_base = (uint8_t *)fb_info->fb[DMUB_WINDOW_6_FW_STATE].cpu_addr;
756 state_size = fb_info->fb[DMUB_WINDOW_6_FW_STATE].size;
758 return seq_write(m, state_base, state_size);
762 * Returns the current and maximum output bpc for the connector.
763 * Example usage: cat /sys/kernel/debug/dri/0/DP-1/output_bpc
765 static int output_bpc_show(struct seq_file *m, void *data)
767 struct drm_connector *connector = m->private;
768 struct drm_device *dev = connector->dev;
769 struct drm_crtc *crtc = NULL;
770 struct dm_crtc_state *dm_crtc_state = NULL;
774 mutex_lock(&dev->mode_config.mutex);
775 drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
777 if (connector->state == NULL)
780 crtc = connector->state->crtc;
784 drm_modeset_lock(&crtc->mutex, NULL);
785 if (crtc->state == NULL)
788 dm_crtc_state = to_dm_crtc_state(crtc->state);
789 if (dm_crtc_state->stream == NULL)
792 switch (dm_crtc_state->stream->timing.display_color_depth) {
793 case COLOR_DEPTH_666:
796 case COLOR_DEPTH_888:
799 case COLOR_DEPTH_101010:
802 case COLOR_DEPTH_121212:
805 case COLOR_DEPTH_161616:
812 seq_printf(m, "Current: %u\n", bpc);
813 seq_printf(m, "Maximum: %u\n", connector->display_info.bpc);
818 drm_modeset_unlock(&crtc->mutex);
820 drm_modeset_unlock(&dev->mode_config.connection_mutex);
821 mutex_unlock(&dev->mode_config.mutex);
826 #ifdef CONFIG_DRM_AMD_DC_HDCP
828 * Returns the HDCP capability of the Display (1.4 for now).
830 * NOTE* Not all HDMI displays report their HDCP caps even when they are capable.
831 * Since its rare for a display to not be HDCP 1.4 capable, we set HDMI as always capable.
833 * Example usage: cat /sys/kernel/debug/dri/0/DP-1/hdcp_sink_capability
834 * or cat /sys/kernel/debug/dri/0/HDMI-A-1/hdcp_sink_capability
836 static int hdcp_sink_capability_show(struct seq_file *m, void *data)
838 struct drm_connector *connector = m->private;
839 struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);
840 bool hdcp_cap, hdcp2_cap;
842 if (connector->status != connector_status_connected)
845 seq_printf(m, "%s:%d HDCP version: ", connector->name, connector->base.id);
847 hdcp_cap = dc_link_is_hdcp14(aconnector->dc_link, aconnector->dc_sink->sink_signal);
848 hdcp2_cap = dc_link_is_hdcp22(aconnector->dc_link, aconnector->dc_sink->sink_signal);
852 seq_printf(m, "%s ", "HDCP1.4");
854 seq_printf(m, "%s ", "HDCP2.2");
856 if (!hdcp_cap && !hdcp2_cap)
857 seq_printf(m, "%s ", "None");
864 /* function description
866 * generic SDP message access for testing
868 * debugfs sdp_message is located at /syskernel/debug/dri/0/DP-x
871 * Hb0 : Secondary-Data Packet ID
872 * Hb1 : Secondary-Data Packet type
873 * Hb2 : Secondary-Data-packet-specific header, Byte 0
874 * Hb3 : Secondary-Data-packet-specific header, Byte 1
876 * for using custom sdp message: input 4 bytes SDP header and 32 bytes raw data
878 static ssize_t dp_sdp_message_debugfs_write(struct file *f, const char __user *buf,
879 size_t size, loff_t *pos)
883 struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
884 struct dm_crtc_state *acrtc_state;
885 uint32_t write_size = 36;
887 if (connector->base.status != connector_status_connected)
893 acrtc_state = to_dm_crtc_state(connector->base.state->crtc->state);
895 r = copy_from_user(data, buf, write_size);
899 dc_stream_send_dp_sdp(acrtc_state->stream, data, write_size);
904 static ssize_t dp_dpcd_address_write(struct file *f, const char __user *buf,
905 size_t size, loff_t *pos)
908 struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
910 if (size < sizeof(connector->debugfs_dpcd_address))
913 r = copy_from_user(&connector->debugfs_dpcd_address,
914 buf, sizeof(connector->debugfs_dpcd_address));
919 static ssize_t dp_dpcd_size_write(struct file *f, const char __user *buf,
920 size_t size, loff_t *pos)
923 struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
925 if (size < sizeof(connector->debugfs_dpcd_size))
928 r = copy_from_user(&connector->debugfs_dpcd_size,
929 buf, sizeof(connector->debugfs_dpcd_size));
931 if (connector->debugfs_dpcd_size > 256)
932 connector->debugfs_dpcd_size = 0;
937 static ssize_t dp_dpcd_data_write(struct file *f, const char __user *buf,
938 size_t size, loff_t *pos)
942 struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
943 struct dc_link *link = connector->dc_link;
944 uint32_t write_size = connector->debugfs_dpcd_size;
946 if (!write_size || size < write_size)
949 data = kzalloc(write_size, GFP_KERNEL);
953 r = copy_from_user(data, buf, write_size);
955 dm_helpers_dp_write_dpcd(link->ctx, link,
956 connector->debugfs_dpcd_address, data, write_size - r);
958 return write_size - r;
961 static ssize_t dp_dpcd_data_read(struct file *f, char __user *buf,
962 size_t size, loff_t *pos)
966 struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
967 struct dc_link *link = connector->dc_link;
968 uint32_t read_size = connector->debugfs_dpcd_size;
970 if (!read_size || size < read_size)
973 data = kzalloc(read_size, GFP_KERNEL);
977 dm_helpers_dp_read_dpcd(link->ctx, link,
978 connector->debugfs_dpcd_address, data, read_size);
980 r = copy_to_user(buf, data, read_size);
983 return read_size - r;
986 /* function: Read link's DSC & FEC capabilities
989 * Access it with the following command (you need to specify
990 * connector like DP-1):
992 * cat /sys/kernel/debug/dri/0/DP-X/dp_dsc_fec_support
995 static int dp_dsc_fec_support_show(struct seq_file *m, void *data)
997 struct drm_connector *connector = m->private;
998 struct drm_modeset_acquire_ctx ctx;
999 struct drm_device *dev = connector->dev;
1000 struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);
1002 bool try_again = false;
1003 bool is_fec_supported = false;
1004 bool is_dsc_supported = false;
1005 struct dpcd_caps dpcd_caps;
1007 drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE);
1010 ret = drm_modeset_lock(&dev->mode_config.connection_mutex, &ctx);
1012 if (ret == -EDEADLK) {
1013 ret = drm_modeset_backoff(&ctx);
1021 if (connector->status != connector_status_connected) {
1025 dpcd_caps = aconnector->dc_link->dpcd_caps;
1026 if (aconnector->port) {
1027 /* aconnector sets dsc_aux during get_modes call
1028 * if MST connector has it means it can either
1029 * enable DSC on the sink device or on MST branch
1032 if (aconnector->dsc_aux) {
1033 is_fec_supported = true;
1034 is_dsc_supported = true;
1037 is_fec_supported = dpcd_caps.fec_cap.raw & 0x1;
1038 is_dsc_supported = dpcd_caps.dsc_caps.dsc_basic_caps.raw[0] & 0x1;
1040 } while (try_again);
1042 drm_modeset_drop_locks(&ctx);
1043 drm_modeset_acquire_fini(&ctx);
1045 seq_printf(m, "FEC_Sink_Support: %s\n", yesno(is_fec_supported));
1046 seq_printf(m, "DSC_Sink_Support: %s\n", yesno(is_dsc_supported));
1051 /* function: Trigger virtual HPD redetection on connector
1053 * This function will perform link rediscovery, link disable
1054 * and enable, and dm connector state update.
1056 * Retrigger HPD on an existing connector by echoing 1 into
1057 * its respectful "trigger_hotplug" debugfs entry:
1059 * echo 1 > /sys/kernel/debug/dri/0/DP-X/trigger_hotplug
1061 * This function can perform HPD unplug:
1063 * echo 0 > /sys/kernel/debug/dri/0/DP-X/trigger_hotplug
1066 static ssize_t trigger_hotplug(struct file *f, const char __user *buf,
1067 size_t size, loff_t *pos)
1069 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
1070 struct drm_connector *connector = &aconnector->base;
1071 struct dc_link *link = NULL;
1072 struct drm_device *dev = connector->dev;
1073 enum dc_connection_type new_connection_type = dc_connection_none;
1074 char *wr_buf = NULL;
1075 uint32_t wr_buf_size = 42;
1076 int max_param_num = 1;
1077 long param[1] = {0};
1078 uint8_t param_nums = 0;
1080 if (!aconnector || !aconnector->dc_link)
1086 wr_buf = kcalloc(wr_buf_size, sizeof(char), GFP_KERNEL);
1089 DRM_DEBUG_DRIVER("no memory to allocate write buffer\n");
1093 if (parse_write_buffer_into_params(wr_buf, size,
1101 if (param_nums <= 0) {
1102 DRM_DEBUG_DRIVER("user data not be read\n");
1107 if (param[0] == 1) {
1108 mutex_lock(&aconnector->hpd_lock);
1110 if (!dc_link_detect_sink(aconnector->dc_link, &new_connection_type) &&
1111 new_connection_type != dc_connection_none)
1114 if (!dc_link_detect(aconnector->dc_link, DETECT_REASON_HPD))
1117 amdgpu_dm_update_connector_after_detect(aconnector);
1119 drm_modeset_lock_all(dev);
1120 dm_restore_drm_connector_state(dev, connector);
1121 drm_modeset_unlock_all(dev);
1123 drm_kms_helper_hotplug_event(dev);
1124 } else if (param[0] == 0) {
1125 if (!aconnector->dc_link)
1128 link = aconnector->dc_link;
1130 if (link->local_sink) {
1131 dc_sink_release(link->local_sink);
1132 link->local_sink = NULL;
1135 link->dpcd_sink_count = 0;
1136 link->type = dc_connection_none;
1137 link->dongle_max_pix_clk = 0;
1139 amdgpu_dm_update_connector_after_detect(aconnector);
1141 drm_modeset_lock_all(dev);
1142 dm_restore_drm_connector_state(dev, connector);
1143 drm_modeset_unlock_all(dev);
1145 drm_kms_helper_hotplug_event(dev);
1149 mutex_unlock(&aconnector->hpd_lock);
1155 /* function: read DSC status on the connector
1157 * The read function: dp_dsc_clock_en_read
1158 * returns current status of DSC clock on the connector.
1159 * The return is a boolean flag: 1 or 0.
1161 * Access it with the following command (you need to specify
1162 * connector like DP-1):
1164 * cat /sys/kernel/debug/dri/0/DP-X/dsc_clock_en
1167 * 1 - means that DSC is currently enabled
1168 * 0 - means that DSC is disabled
1170 static ssize_t dp_dsc_clock_en_read(struct file *f, char __user *buf,
1171 size_t size, loff_t *pos)
1173 char *rd_buf = NULL;
1174 char *rd_buf_ptr = NULL;
1175 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
1176 struct display_stream_compressor *dsc;
1177 struct dcn_dsc_state dsc_state = {0};
1178 const uint32_t rd_buf_size = 10;
1179 struct pipe_ctx *pipe_ctx;
1181 int i, r, str_len = 30;
1183 rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
1188 rd_buf_ptr = rd_buf;
1190 for (i = 0; i < MAX_PIPES; i++) {
1191 pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
1192 if (pipe_ctx && pipe_ctx->stream &&
1193 pipe_ctx->stream->link == aconnector->dc_link)
1200 dsc = pipe_ctx->stream_res.dsc;
1202 dsc->funcs->dsc_read_state(dsc, &dsc_state);
1204 snprintf(rd_buf_ptr, str_len,
1206 dsc_state.dsc_clock_en);
1207 rd_buf_ptr += str_len;
1210 if (*pos >= rd_buf_size)
1213 r = put_user(*(rd_buf + result), buf);
1215 return r; /* r = -EFAULT */
1227 /* function: write force DSC on the connector
1229 * The write function: dp_dsc_clock_en_write
1230 * enables to force DSC on the connector.
1231 * User can write to either force enable or force disable DSC
1232 * on the next modeset or set it to driver default
1235 * 0 - default DSC enablement policy
1236 * 1 - force enable DSC on the connector
1237 * 2 - force disable DSC on the connector (might cause fail in atomic_check)
1239 * Writing DSC settings is done with the following command:
1240 * - To force enable DSC (you need to specify
1241 * connector like DP-1):
1243 * echo 0x1 > /sys/kernel/debug/dri/0/DP-X/dsc_clock_en
1245 * - To return to default state set the flag to zero and
1246 * let driver deal with DSC automatically
1247 * (you need to specify connector like DP-1):
1249 * echo 0x0 > /sys/kernel/debug/dri/0/DP-X/dsc_clock_en
1252 static ssize_t dp_dsc_clock_en_write(struct file *f, const char __user *buf,
1253 size_t size, loff_t *pos)
1255 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
1256 struct drm_connector *connector = &aconnector->base;
1257 struct drm_device *dev = connector->dev;
1258 struct drm_crtc *crtc = NULL;
1259 struct dm_crtc_state *dm_crtc_state = NULL;
1260 struct pipe_ctx *pipe_ctx;
1262 char *wr_buf = NULL;
1263 uint32_t wr_buf_size = 42;
1264 int max_param_num = 1;
1265 long param[1] = {0};
1266 uint8_t param_nums = 0;
1271 wr_buf = kcalloc(wr_buf_size, sizeof(char), GFP_KERNEL);
1274 DRM_DEBUG_DRIVER("no memory to allocate write buffer\n");
1278 if (parse_write_buffer_into_params(wr_buf, size,
1286 if (param_nums <= 0) {
1287 DRM_DEBUG_DRIVER("user data not be read\n");
1292 for (i = 0; i < MAX_PIPES; i++) {
1293 pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
1294 if (pipe_ctx && pipe_ctx->stream &&
1295 pipe_ctx->stream->link == aconnector->dc_link)
1299 if (!pipe_ctx || !pipe_ctx->stream)
1303 mutex_lock(&dev->mode_config.mutex);
1304 drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
1306 if (connector->state == NULL)
1309 crtc = connector->state->crtc;
1313 drm_modeset_lock(&crtc->mutex, NULL);
1314 if (crtc->state == NULL)
1317 dm_crtc_state = to_dm_crtc_state(crtc->state);
1318 if (dm_crtc_state->stream == NULL)
1322 aconnector->dsc_settings.dsc_force_enable = DSC_CLK_FORCE_ENABLE;
1323 else if (param[0] == 2)
1324 aconnector->dsc_settings.dsc_force_enable = DSC_CLK_FORCE_DISABLE;
1326 aconnector->dsc_settings.dsc_force_enable = DSC_CLK_FORCE_DEFAULT;
1328 dm_crtc_state->dsc_force_changed = true;
1332 drm_modeset_unlock(&crtc->mutex);
1333 drm_modeset_unlock(&dev->mode_config.connection_mutex);
1334 mutex_unlock(&dev->mode_config.mutex);
1341 /* function: read DSC slice width parameter on the connector
1343 * The read function: dp_dsc_slice_width_read
1344 * returns dsc slice width used in the current configuration
1345 * The return is an integer: 0 or other positive number
1347 * Access the status with the following command:
1349 * cat /sys/kernel/debug/dri/0/DP-X/dsc_slice_width
1351 * 0 - means that DSC is disabled
1353 * Any other number more than zero represents the
1354 * slice width currently used by DSC in pixels
1357 static ssize_t dp_dsc_slice_width_read(struct file *f, char __user *buf,
1358 size_t size, loff_t *pos)
1360 char *rd_buf = NULL;
1361 char *rd_buf_ptr = NULL;
1362 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
1363 struct display_stream_compressor *dsc;
1364 struct dcn_dsc_state dsc_state = {0};
1365 const uint32_t rd_buf_size = 100;
1366 struct pipe_ctx *pipe_ctx;
1368 int i, r, str_len = 30;
1370 rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
1375 rd_buf_ptr = rd_buf;
1377 for (i = 0; i < MAX_PIPES; i++) {
1378 pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
1379 if (pipe_ctx && pipe_ctx->stream &&
1380 pipe_ctx->stream->link == aconnector->dc_link)
1387 dsc = pipe_ctx->stream_res.dsc;
1389 dsc->funcs->dsc_read_state(dsc, &dsc_state);
1391 snprintf(rd_buf_ptr, str_len,
1393 dsc_state.dsc_slice_width);
1394 rd_buf_ptr += str_len;
1397 if (*pos >= rd_buf_size)
1400 r = put_user(*(rd_buf + result), buf);
1402 return r; /* r = -EFAULT */
1414 /* function: write DSC slice width parameter
1416 * The write function: dp_dsc_slice_width_write
1417 * overwrites automatically generated DSC configuration
1420 * The user has to write the slice width divisible by the
1423 * Also the user has to write width in hexidecimal
1424 * rather than in decimal.
1426 * Writing DSC settings is done with the following command:
1427 * - To force overwrite slice width: (example sets to 1920 pixels)
1429 * echo 0x780 > /sys/kernel/debug/dri/0/DP-X/dsc_slice_width
1431 * - To stop overwriting and let driver find the optimal size,
1432 * set the width to zero:
1434 * echo 0x0 > /sys/kernel/debug/dri/0/DP-X/dsc_slice_width
1437 static ssize_t dp_dsc_slice_width_write(struct file *f, const char __user *buf,
1438 size_t size, loff_t *pos)
1440 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
1441 struct pipe_ctx *pipe_ctx;
1442 struct drm_connector *connector = &aconnector->base;
1443 struct drm_device *dev = connector->dev;
1444 struct drm_crtc *crtc = NULL;
1445 struct dm_crtc_state *dm_crtc_state = NULL;
1447 char *wr_buf = NULL;
1448 uint32_t wr_buf_size = 42;
1449 int max_param_num = 1;
1450 long param[1] = {0};
1451 uint8_t param_nums = 0;
1456 wr_buf = kcalloc(wr_buf_size, sizeof(char), GFP_KERNEL);
1459 DRM_DEBUG_DRIVER("no memory to allocate write buffer\n");
1463 if (parse_write_buffer_into_params(wr_buf, size,
1471 if (param_nums <= 0) {
1472 DRM_DEBUG_DRIVER("user data not be read\n");
1477 for (i = 0; i < MAX_PIPES; i++) {
1478 pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
1479 if (pipe_ctx && pipe_ctx->stream &&
1480 pipe_ctx->stream->link == aconnector->dc_link)
1484 if (!pipe_ctx || !pipe_ctx->stream)
1487 // Safely get CRTC state
1488 mutex_lock(&dev->mode_config.mutex);
1489 drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
1491 if (connector->state == NULL)
1494 crtc = connector->state->crtc;
1498 drm_modeset_lock(&crtc->mutex, NULL);
1499 if (crtc->state == NULL)
1502 dm_crtc_state = to_dm_crtc_state(crtc->state);
1503 if (dm_crtc_state->stream == NULL)
1507 aconnector->dsc_settings.dsc_num_slices_h = DIV_ROUND_UP(
1508 pipe_ctx->stream->timing.h_addressable,
1511 aconnector->dsc_settings.dsc_num_slices_h = 0;
1513 dm_crtc_state->dsc_force_changed = true;
1517 drm_modeset_unlock(&crtc->mutex);
1518 drm_modeset_unlock(&dev->mode_config.connection_mutex);
1519 mutex_unlock(&dev->mode_config.mutex);
1526 /* function: read DSC slice height parameter on the connector
1528 * The read function: dp_dsc_slice_height_read
1529 * returns dsc slice height used in the current configuration
1530 * The return is an integer: 0 or other positive number
1532 * Access the status with the following command:
1534 * cat /sys/kernel/debug/dri/0/DP-X/dsc_slice_height
1536 * 0 - means that DSC is disabled
1538 * Any other number more than zero represents the
1539 * slice height currently used by DSC in pixels
1542 static ssize_t dp_dsc_slice_height_read(struct file *f, char __user *buf,
1543 size_t size, loff_t *pos)
1545 char *rd_buf = NULL;
1546 char *rd_buf_ptr = NULL;
1547 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
1548 struct display_stream_compressor *dsc;
1549 struct dcn_dsc_state dsc_state = {0};
1550 const uint32_t rd_buf_size = 100;
1551 struct pipe_ctx *pipe_ctx;
1553 int i, r, str_len = 30;
1555 rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
1560 rd_buf_ptr = rd_buf;
1562 for (i = 0; i < MAX_PIPES; i++) {
1563 pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
1564 if (pipe_ctx && pipe_ctx->stream &&
1565 pipe_ctx->stream->link == aconnector->dc_link)
1572 dsc = pipe_ctx->stream_res.dsc;
1574 dsc->funcs->dsc_read_state(dsc, &dsc_state);
1576 snprintf(rd_buf_ptr, str_len,
1578 dsc_state.dsc_slice_height);
1579 rd_buf_ptr += str_len;
1582 if (*pos >= rd_buf_size)
1585 r = put_user(*(rd_buf + result), buf);
1587 return r; /* r = -EFAULT */
1599 /* function: write DSC slice height parameter
1601 * The write function: dp_dsc_slice_height_write
1602 * overwrites automatically generated DSC configuration
1605 * The user has to write the slice height divisible by the
1608 * Also the user has to write height in hexidecimal
1609 * rather than in decimal.
1611 * Writing DSC settings is done with the following command:
1612 * - To force overwrite slice height (example sets to 128 pixels):
1614 * echo 0x80 > /sys/kernel/debug/dri/0/DP-X/dsc_slice_height
1616 * - To stop overwriting and let driver find the optimal size,
1617 * set the height to zero:
1619 * echo 0x0 > /sys/kernel/debug/dri/0/DP-X/dsc_slice_height
1622 static ssize_t dp_dsc_slice_height_write(struct file *f, const char __user *buf,
1623 size_t size, loff_t *pos)
1625 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
1626 struct drm_connector *connector = &aconnector->base;
1627 struct drm_device *dev = connector->dev;
1628 struct drm_crtc *crtc = NULL;
1629 struct dm_crtc_state *dm_crtc_state = NULL;
1630 struct pipe_ctx *pipe_ctx;
1632 char *wr_buf = NULL;
1633 uint32_t wr_buf_size = 42;
1634 int max_param_num = 1;
1635 uint8_t param_nums = 0;
1636 long param[1] = {0};
1641 wr_buf = kcalloc(wr_buf_size, sizeof(char), GFP_KERNEL);
1644 DRM_DEBUG_DRIVER("no memory to allocate write buffer\n");
1648 if (parse_write_buffer_into_params(wr_buf, size,
1656 if (param_nums <= 0) {
1657 DRM_DEBUG_DRIVER("user data not be read\n");
1662 for (i = 0; i < MAX_PIPES; i++) {
1663 pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
1664 if (pipe_ctx && pipe_ctx->stream &&
1665 pipe_ctx->stream->link == aconnector->dc_link)
1669 if (!pipe_ctx || !pipe_ctx->stream)
1673 mutex_lock(&dev->mode_config.mutex);
1674 drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
1676 if (connector->state == NULL)
1679 crtc = connector->state->crtc;
1683 drm_modeset_lock(&crtc->mutex, NULL);
1684 if (crtc->state == NULL)
1687 dm_crtc_state = to_dm_crtc_state(crtc->state);
1688 if (dm_crtc_state->stream == NULL)
1692 aconnector->dsc_settings.dsc_num_slices_v = DIV_ROUND_UP(
1693 pipe_ctx->stream->timing.v_addressable,
1696 aconnector->dsc_settings.dsc_num_slices_v = 0;
1698 dm_crtc_state->dsc_force_changed = true;
1702 drm_modeset_unlock(&crtc->mutex);
1703 drm_modeset_unlock(&dev->mode_config.connection_mutex);
1704 mutex_unlock(&dev->mode_config.mutex);
1711 /* function: read DSC target rate on the connector in bits per pixel
1713 * The read function: dp_dsc_bits_per_pixel_read
1714 * returns target rate of compression in bits per pixel
1715 * The return is an integer: 0 or other positive integer
1717 * Access it with the following command:
1719 * cat /sys/kernel/debug/dri/0/DP-X/dsc_bits_per_pixel
1721 * 0 - means that DSC is disabled
1723 static ssize_t dp_dsc_bits_per_pixel_read(struct file *f, char __user *buf,
1724 size_t size, loff_t *pos)
1726 char *rd_buf = NULL;
1727 char *rd_buf_ptr = NULL;
1728 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
1729 struct display_stream_compressor *dsc;
1730 struct dcn_dsc_state dsc_state = {0};
1731 const uint32_t rd_buf_size = 100;
1732 struct pipe_ctx *pipe_ctx;
1734 int i, r, str_len = 30;
1736 rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
1741 rd_buf_ptr = rd_buf;
1743 for (i = 0; i < MAX_PIPES; i++) {
1744 pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
1745 if (pipe_ctx && pipe_ctx->stream &&
1746 pipe_ctx->stream->link == aconnector->dc_link)
1753 dsc = pipe_ctx->stream_res.dsc;
1755 dsc->funcs->dsc_read_state(dsc, &dsc_state);
1757 snprintf(rd_buf_ptr, str_len,
1759 dsc_state.dsc_bits_per_pixel);
1760 rd_buf_ptr += str_len;
1763 if (*pos >= rd_buf_size)
1766 r = put_user(*(rd_buf + result), buf);
1768 return r; /* r = -EFAULT */
1780 /* function: write DSC target rate in bits per pixel
1782 * The write function: dp_dsc_bits_per_pixel_write
1783 * overwrites automatically generated DSC configuration
1784 * of DSC target bit rate.
1786 * Also the user has to write bpp in hexidecimal
1787 * rather than in decimal.
1789 * Writing DSC settings is done with the following command:
1790 * - To force overwrite rate (example sets to 256 bpp x 1/16):
1792 * echo 0x100 > /sys/kernel/debug/dri/0/DP-X/dsc_bits_per_pixel
1794 * - To stop overwriting and let driver find the optimal rate,
1795 * set the rate to zero:
1797 * echo 0x0 > /sys/kernel/debug/dri/0/DP-X/dsc_bits_per_pixel
1800 static ssize_t dp_dsc_bits_per_pixel_write(struct file *f, const char __user *buf,
1801 size_t size, loff_t *pos)
1803 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
1804 struct drm_connector *connector = &aconnector->base;
1805 struct drm_device *dev = connector->dev;
1806 struct drm_crtc *crtc = NULL;
1807 struct dm_crtc_state *dm_crtc_state = NULL;
1808 struct pipe_ctx *pipe_ctx;
1810 char *wr_buf = NULL;
1811 uint32_t wr_buf_size = 42;
1812 int max_param_num = 1;
1813 uint8_t param_nums = 0;
1814 long param[1] = {0};
1819 wr_buf = kcalloc(wr_buf_size, sizeof(char), GFP_KERNEL);
1822 DRM_DEBUG_DRIVER("no memory to allocate write buffer\n");
1826 if (parse_write_buffer_into_params(wr_buf, size,
1834 if (param_nums <= 0) {
1835 DRM_DEBUG_DRIVER("user data not be read\n");
1840 for (i = 0; i < MAX_PIPES; i++) {
1841 pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
1842 if (pipe_ctx && pipe_ctx->stream &&
1843 pipe_ctx->stream->link == aconnector->dc_link)
1847 if (!pipe_ctx || !pipe_ctx->stream)
1851 mutex_lock(&dev->mode_config.mutex);
1852 drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
1854 if (connector->state == NULL)
1857 crtc = connector->state->crtc;
1861 drm_modeset_lock(&crtc->mutex, NULL);
1862 if (crtc->state == NULL)
1865 dm_crtc_state = to_dm_crtc_state(crtc->state);
1866 if (dm_crtc_state->stream == NULL)
1869 aconnector->dsc_settings.dsc_bits_per_pixel = param[0];
1871 dm_crtc_state->dsc_force_changed = true;
1875 drm_modeset_unlock(&crtc->mutex);
1876 drm_modeset_unlock(&dev->mode_config.connection_mutex);
1877 mutex_unlock(&dev->mode_config.mutex);
1884 /* function: read DSC picture width parameter on the connector
1886 * The read function: dp_dsc_pic_width_read
1887 * returns dsc picture width used in the current configuration
1888 * It is the same as h_addressable of the current
1890 * The return is an integer: 0 or other positive integer
1891 * If 0 then DSC is disabled.
1893 * Access it with the following command:
1895 * cat /sys/kernel/debug/dri/0/DP-X/dsc_pic_width
1897 * 0 - means that DSC is disabled
1899 static ssize_t dp_dsc_pic_width_read(struct file *f, char __user *buf,
1900 size_t size, loff_t *pos)
1902 char *rd_buf = NULL;
1903 char *rd_buf_ptr = NULL;
1904 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
1905 struct display_stream_compressor *dsc;
1906 struct dcn_dsc_state dsc_state = {0};
1907 const uint32_t rd_buf_size = 100;
1908 struct pipe_ctx *pipe_ctx;
1910 int i, r, str_len = 30;
1912 rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
1917 rd_buf_ptr = rd_buf;
1919 for (i = 0; i < MAX_PIPES; i++) {
1920 pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
1921 if (pipe_ctx && pipe_ctx->stream &&
1922 pipe_ctx->stream->link == aconnector->dc_link)
1929 dsc = pipe_ctx->stream_res.dsc;
1931 dsc->funcs->dsc_read_state(dsc, &dsc_state);
1933 snprintf(rd_buf_ptr, str_len,
1935 dsc_state.dsc_pic_width);
1936 rd_buf_ptr += str_len;
1939 if (*pos >= rd_buf_size)
1942 r = put_user(*(rd_buf + result), buf);
1944 return r; /* r = -EFAULT */
1956 static ssize_t dp_dsc_pic_height_read(struct file *f, char __user *buf,
1957 size_t size, loff_t *pos)
1959 char *rd_buf = NULL;
1960 char *rd_buf_ptr = NULL;
1961 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
1962 struct display_stream_compressor *dsc;
1963 struct dcn_dsc_state dsc_state = {0};
1964 const uint32_t rd_buf_size = 100;
1965 struct pipe_ctx *pipe_ctx;
1967 int i, r, str_len = 30;
1969 rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
1974 rd_buf_ptr = rd_buf;
1976 for (i = 0; i < MAX_PIPES; i++) {
1977 pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
1978 if (pipe_ctx && pipe_ctx->stream &&
1979 pipe_ctx->stream->link == aconnector->dc_link)
1986 dsc = pipe_ctx->stream_res.dsc;
1988 dsc->funcs->dsc_read_state(dsc, &dsc_state);
1990 snprintf(rd_buf_ptr, str_len,
1992 dsc_state.dsc_pic_height);
1993 rd_buf_ptr += str_len;
1996 if (*pos >= rd_buf_size)
1999 r = put_user(*(rd_buf + result), buf);
2001 return r; /* r = -EFAULT */
2013 /* function: read DSC chunk size parameter on the connector
2015 * The read function: dp_dsc_chunk_size_read
2016 * returns dsc chunk size set in the current configuration
2017 * The value is calculated automatically by DSC code
2018 * and depends on slice parameters and bpp target rate
2019 * The return is an integer: 0 or other positive integer
2020 * If 0 then DSC is disabled.
2022 * Access it with the following command:
2024 * cat /sys/kernel/debug/dri/0/DP-X/dsc_chunk_size
2026 * 0 - means that DSC is disabled
2028 static ssize_t dp_dsc_chunk_size_read(struct file *f, char __user *buf,
2029 size_t size, loff_t *pos)
2031 char *rd_buf = NULL;
2032 char *rd_buf_ptr = NULL;
2033 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
2034 struct display_stream_compressor *dsc;
2035 struct dcn_dsc_state dsc_state = {0};
2036 const uint32_t rd_buf_size = 100;
2037 struct pipe_ctx *pipe_ctx;
2039 int i, r, str_len = 30;
2041 rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
2046 rd_buf_ptr = rd_buf;
2048 for (i = 0; i < MAX_PIPES; i++) {
2049 pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
2050 if (pipe_ctx && pipe_ctx->stream &&
2051 pipe_ctx->stream->link == aconnector->dc_link)
2058 dsc = pipe_ctx->stream_res.dsc;
2060 dsc->funcs->dsc_read_state(dsc, &dsc_state);
2062 snprintf(rd_buf_ptr, str_len,
2064 dsc_state.dsc_chunk_size);
2065 rd_buf_ptr += str_len;
2068 if (*pos >= rd_buf_size)
2071 r = put_user(*(rd_buf + result), buf);
2073 return r; /* r = -EFAULT */
2085 /* function: read DSC slice bpg offset on the connector
2087 * The read function: dp_dsc_slice_bpg_offset_read
2088 * returns dsc bpg slice offset set in the current configuration
2089 * The value is calculated automatically by DSC code
2090 * and depends on slice parameters and bpp target rate
2091 * The return is an integer: 0 or other positive integer
2092 * If 0 then DSC is disabled.
2094 * Access it with the following command:
2096 * cat /sys/kernel/debug/dri/0/DP-X/dsc_slice_bpg_offset
2098 * 0 - means that DSC is disabled
2100 static ssize_t dp_dsc_slice_bpg_offset_read(struct file *f, char __user *buf,
2101 size_t size, loff_t *pos)
2103 char *rd_buf = NULL;
2104 char *rd_buf_ptr = NULL;
2105 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
2106 struct display_stream_compressor *dsc;
2107 struct dcn_dsc_state dsc_state = {0};
2108 const uint32_t rd_buf_size = 100;
2109 struct pipe_ctx *pipe_ctx;
2111 int i, r, str_len = 30;
2113 rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
2118 rd_buf_ptr = rd_buf;
2120 for (i = 0; i < MAX_PIPES; i++) {
2121 pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
2122 if (pipe_ctx && pipe_ctx->stream &&
2123 pipe_ctx->stream->link == aconnector->dc_link)
2130 dsc = pipe_ctx->stream_res.dsc;
2132 dsc->funcs->dsc_read_state(dsc, &dsc_state);
2134 snprintf(rd_buf_ptr, str_len,
2136 dsc_state.dsc_slice_bpg_offset);
2137 rd_buf_ptr += str_len;
2140 if (*pos >= rd_buf_size)
2143 r = put_user(*(rd_buf + result), buf);
2145 return r; /* r = -EFAULT */
2157 DEFINE_SHOW_ATTRIBUTE(dp_dsc_fec_support);
2158 DEFINE_SHOW_ATTRIBUTE(dmub_fw_state);
2159 DEFINE_SHOW_ATTRIBUTE(dmub_tracebuffer);
2160 DEFINE_SHOW_ATTRIBUTE(output_bpc);
2161 #ifdef CONFIG_DRM_AMD_DC_HDCP
2162 DEFINE_SHOW_ATTRIBUTE(hdcp_sink_capability);
2165 static const struct file_operations dp_dsc_clock_en_debugfs_fops = {
2166 .owner = THIS_MODULE,
2167 .read = dp_dsc_clock_en_read,
2168 .write = dp_dsc_clock_en_write,
2169 .llseek = default_llseek
2172 static const struct file_operations dp_dsc_slice_width_debugfs_fops = {
2173 .owner = THIS_MODULE,
2174 .read = dp_dsc_slice_width_read,
2175 .write = dp_dsc_slice_width_write,
2176 .llseek = default_llseek
2179 static const struct file_operations dp_dsc_slice_height_debugfs_fops = {
2180 .owner = THIS_MODULE,
2181 .read = dp_dsc_slice_height_read,
2182 .write = dp_dsc_slice_height_write,
2183 .llseek = default_llseek
2186 static const struct file_operations dp_dsc_bits_per_pixel_debugfs_fops = {
2187 .owner = THIS_MODULE,
2188 .read = dp_dsc_bits_per_pixel_read,
2189 .write = dp_dsc_bits_per_pixel_write,
2190 .llseek = default_llseek
2193 static const struct file_operations dp_dsc_pic_width_debugfs_fops = {
2194 .owner = THIS_MODULE,
2195 .read = dp_dsc_pic_width_read,
2196 .llseek = default_llseek
2199 static const struct file_operations dp_dsc_pic_height_debugfs_fops = {
2200 .owner = THIS_MODULE,
2201 .read = dp_dsc_pic_height_read,
2202 .llseek = default_llseek
2205 static const struct file_operations dp_dsc_chunk_size_debugfs_fops = {
2206 .owner = THIS_MODULE,
2207 .read = dp_dsc_chunk_size_read,
2208 .llseek = default_llseek
2211 static const struct file_operations dp_dsc_slice_bpg_offset_debugfs_fops = {
2212 .owner = THIS_MODULE,
2213 .read = dp_dsc_slice_bpg_offset_read,
2214 .llseek = default_llseek
2217 static const struct file_operations trigger_hotplug_debugfs_fops = {
2218 .owner = THIS_MODULE,
2219 .write = trigger_hotplug,
2220 .llseek = default_llseek
2223 static const struct file_operations dp_link_settings_debugfs_fops = {
2224 .owner = THIS_MODULE,
2225 .read = dp_link_settings_read,
2226 .write = dp_link_settings_write,
2227 .llseek = default_llseek
2230 static const struct file_operations dp_phy_settings_debugfs_fop = {
2231 .owner = THIS_MODULE,
2232 .read = dp_phy_settings_read,
2233 .write = dp_phy_settings_write,
2234 .llseek = default_llseek
2237 static const struct file_operations dp_phy_test_pattern_fops = {
2238 .owner = THIS_MODULE,
2239 .write = dp_phy_test_pattern_debugfs_write,
2240 .llseek = default_llseek
2243 static const struct file_operations sdp_message_fops = {
2244 .owner = THIS_MODULE,
2245 .write = dp_sdp_message_debugfs_write,
2246 .llseek = default_llseek
2249 static const struct file_operations dp_dpcd_address_debugfs_fops = {
2250 .owner = THIS_MODULE,
2251 .write = dp_dpcd_address_write,
2252 .llseek = default_llseek
2255 static const struct file_operations dp_dpcd_size_debugfs_fops = {
2256 .owner = THIS_MODULE,
2257 .write = dp_dpcd_size_write,
2258 .llseek = default_llseek
2261 static const struct file_operations dp_dpcd_data_debugfs_fops = {
2262 .owner = THIS_MODULE,
2263 .read = dp_dpcd_data_read,
2264 .write = dp_dpcd_data_write,
2265 .llseek = default_llseek
2268 static const struct {
2270 const struct file_operations *fops;
2271 } dp_debugfs_entries[] = {
2272 {"link_settings", &dp_link_settings_debugfs_fops},
2273 {"phy_settings", &dp_phy_settings_debugfs_fop},
2274 {"test_pattern", &dp_phy_test_pattern_fops},
2275 #ifdef CONFIG_DRM_AMD_DC_HDCP
2276 {"hdcp_sink_capability", &hdcp_sink_capability_fops},
2278 {"sdp_message", &sdp_message_fops},
2279 {"aux_dpcd_address", &dp_dpcd_address_debugfs_fops},
2280 {"aux_dpcd_size", &dp_dpcd_size_debugfs_fops},
2281 {"aux_dpcd_data", &dp_dpcd_data_debugfs_fops},
2282 {"dsc_clock_en", &dp_dsc_clock_en_debugfs_fops},
2283 {"dsc_slice_width", &dp_dsc_slice_width_debugfs_fops},
2284 {"dsc_slice_height", &dp_dsc_slice_height_debugfs_fops},
2285 {"dsc_bits_per_pixel", &dp_dsc_bits_per_pixel_debugfs_fops},
2286 {"dsc_pic_width", &dp_dsc_pic_width_debugfs_fops},
2287 {"dsc_pic_height", &dp_dsc_pic_height_debugfs_fops},
2288 {"dsc_chunk_size", &dp_dsc_chunk_size_debugfs_fops},
2289 {"dsc_slice_bpg", &dp_dsc_slice_bpg_offset_debugfs_fops},
2290 {"dp_dsc_fec_support", &dp_dsc_fec_support_fops}
2293 #ifdef CONFIG_DRM_AMD_DC_HDCP
2294 static const struct {
2296 const struct file_operations *fops;
2297 } hdmi_debugfs_entries[] = {
2298 {"hdcp_sink_capability", &hdcp_sink_capability_fops}
2302 * Force YUV420 output if available from the given mode
2304 static int force_yuv420_output_set(void *data, u64 val)
2306 struct amdgpu_dm_connector *connector = data;
2308 connector->force_yuv420_output = (bool)val;
2314 * Check if YUV420 is forced when available from the given mode
2316 static int force_yuv420_output_get(void *data, u64 *val)
2318 struct amdgpu_dm_connector *connector = data;
2320 *val = connector->force_yuv420_output;
2325 DEFINE_DEBUGFS_ATTRIBUTE(force_yuv420_output_fops, force_yuv420_output_get,
2326 force_yuv420_output_set, "%llu\n");
2331 static int psr_get(void *data, u64 *val)
2333 struct amdgpu_dm_connector *connector = data;
2334 struct dc_link *link = connector->dc_link;
2335 enum dc_psr_state state = PSR_STATE0;
2337 dc_link_get_psr_state(link, &state);
2345 DEFINE_DEBUGFS_ATTRIBUTE(psr_fops, psr_get, NULL, "%llu\n");
2347 void connector_debugfs_init(struct amdgpu_dm_connector *connector)
2350 struct dentry *dir = connector->base.debugfs_entry;
2352 if (connector->base.connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
2353 connector->base.connector_type == DRM_MODE_CONNECTOR_eDP) {
2354 for (i = 0; i < ARRAY_SIZE(dp_debugfs_entries); i++) {
2355 debugfs_create_file(dp_debugfs_entries[i].name,
2356 0644, dir, connector,
2357 dp_debugfs_entries[i].fops);
2360 if (connector->base.connector_type == DRM_MODE_CONNECTOR_eDP)
2361 debugfs_create_file_unsafe("psr_state", 0444, dir, connector, &psr_fops);
2363 debugfs_create_file_unsafe("force_yuv420_output", 0644, dir, connector,
2364 &force_yuv420_output_fops);
2366 debugfs_create_file("output_bpc", 0644, dir, connector,
2369 debugfs_create_file("trigger_hotplug", 0644, dir, connector,
2370 &trigger_hotplug_debugfs_fops);
2372 connector->debugfs_dpcd_address = 0;
2373 connector->debugfs_dpcd_size = 0;
2375 #ifdef CONFIG_DRM_AMD_DC_HDCP
2376 if (connector->base.connector_type == DRM_MODE_CONNECTOR_HDMIA) {
2377 for (i = 0; i < ARRAY_SIZE(hdmi_debugfs_entries); i++) {
2378 debugfs_create_file(hdmi_debugfs_entries[i].name,
2379 0644, dir, connector,
2380 hdmi_debugfs_entries[i].fops);
2387 * Writes DTN log state to the user supplied buffer.
2388 * Example usage: cat /sys/kernel/debug/dri/0/amdgpu_dm_dtn_log
2390 static ssize_t dtn_log_read(
2396 struct amdgpu_device *adev = file_inode(f)->i_private;
2397 struct dc *dc = adev->dm.dc;
2398 struct dc_log_buffer_ctx log_ctx = { 0 };
2404 if (!dc->hwss.log_hw_state)
2407 dc->hwss.log_hw_state(dc, &log_ctx);
2409 if (*pos < log_ctx.pos) {
2410 size_t to_copy = log_ctx.pos - *pos;
2412 to_copy = min(to_copy, size);
2414 if (!copy_to_user(buf, log_ctx.buf + *pos, to_copy)) {
2426 * Writes DTN log state to dmesg when triggered via a write.
2427 * Example usage: echo 1 > /sys/kernel/debug/dri/0/amdgpu_dm_dtn_log
2429 static ssize_t dtn_log_write(
2431 const char __user *buf,
2435 struct amdgpu_device *adev = file_inode(f)->i_private;
2436 struct dc *dc = adev->dm.dc;
2438 /* Write triggers log output via dmesg. */
2442 if (dc->hwss.log_hw_state)
2443 dc->hwss.log_hw_state(dc, NULL);
2449 * Backlight at this moment. Read only.
2450 * As written to display, taking ABM and backlight lut into account.
2451 * Ranges from 0x0 to 0x10000 (= 100% PWM)
2453 static int current_backlight_read(struct seq_file *m, void *data)
2455 struct drm_info_node *node = (struct drm_info_node *)m->private;
2456 struct drm_device *dev = node->minor->dev;
2457 struct amdgpu_device *adev = drm_to_adev(dev);
2458 struct amdgpu_display_manager *dm = &adev->dm;
2460 unsigned int backlight = dc_link_get_backlight_level(dm->backlight_link);
2462 seq_printf(m, "0x%x\n", backlight);
2467 * Backlight value that is being approached. Read only.
2468 * As written to display, taking ABM and backlight lut into account.
2469 * Ranges from 0x0 to 0x10000 (= 100% PWM)
2471 static int target_backlight_read(struct seq_file *m, void *data)
2473 struct drm_info_node *node = (struct drm_info_node *)m->private;
2474 struct drm_device *dev = node->minor->dev;
2475 struct amdgpu_device *adev = drm_to_adev(dev);
2476 struct amdgpu_display_manager *dm = &adev->dm;
2478 unsigned int backlight = dc_link_get_target_backlight_pwm(dm->backlight_link);
2480 seq_printf(m, "0x%x\n", backlight);
2484 static int mst_topo(struct seq_file *m, void *unused)
2486 struct drm_info_node *node = (struct drm_info_node *)m->private;
2487 struct drm_device *dev = node->minor->dev;
2488 struct drm_connector *connector;
2489 struct drm_connector_list_iter conn_iter;
2490 struct amdgpu_dm_connector *aconnector;
2492 drm_connector_list_iter_begin(dev, &conn_iter);
2493 drm_for_each_connector_iter(connector, &conn_iter) {
2494 if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort)
2497 aconnector = to_amdgpu_dm_connector(connector);
2499 seq_printf(m, "\nMST topology for connector %d\n", aconnector->connector_id);
2500 drm_dp_mst_dump_topology(m, &aconnector->mst_mgr);
2502 drm_connector_list_iter_end(&conn_iter);
2507 static const struct drm_info_list amdgpu_dm_debugfs_list[] = {
2508 {"amdgpu_current_backlight_pwm", ¤t_backlight_read},
2509 {"amdgpu_target_backlight_pwm", &target_backlight_read},
2510 {"amdgpu_mst_topology", &mst_topo},
2514 * Sets the force_timing_sync debug optino from the given string.
2515 * All connected displays will be force synchronized immediately.
2516 * Usage: echo 1 > /sys/kernel/debug/dri/0/amdgpu_dm_force_timing_sync
2518 static int force_timing_sync_set(void *data, u64 val)
2520 struct amdgpu_device *adev = data;
2522 adev->dm.force_timing_sync = (bool)val;
2524 amdgpu_dm_trigger_timing_sync(adev_to_drm(adev));
2530 * Gets the force_timing_sync debug option value into the given buffer.
2531 * Usage: cat /sys/kernel/debug/dri/0/amdgpu_dm_force_timing_sync
2533 static int force_timing_sync_get(void *data, u64 *val)
2535 struct amdgpu_device *adev = data;
2537 *val = adev->dm.force_timing_sync;
2542 DEFINE_DEBUGFS_ATTRIBUTE(force_timing_sync_ops, force_timing_sync_get,
2543 force_timing_sync_set, "%llu\n");
2546 * Sets the DC visual confirm debug option from the given string.
2547 * Example usage: echo 1 > /sys/kernel/debug/dri/0/amdgpu_visual_confirm
2549 static int visual_confirm_set(void *data, u64 val)
2551 struct amdgpu_device *adev = data;
2553 adev->dm.dc->debug.visual_confirm = (enum visual_confirm)val;
2559 * Reads the DC visual confirm debug option value into the given buffer.
2560 * Example usage: cat /sys/kernel/debug/dri/0/amdgpu_dm_visual_confirm
2562 static int visual_confirm_get(void *data, u64 *val)
2564 struct amdgpu_device *adev = data;
2566 *val = adev->dm.dc->debug.visual_confirm;
2571 DEFINE_DEBUGFS_ATTRIBUTE(visual_confirm_fops, visual_confirm_get,
2572 visual_confirm_set, "%llu\n");
2574 int dtn_debugfs_init(struct amdgpu_device *adev)
2576 static const struct file_operations dtn_log_fops = {
2577 .owner = THIS_MODULE,
2578 .read = dtn_log_read,
2579 .write = dtn_log_write,
2580 .llseek = default_llseek
2583 struct drm_minor *minor = adev_to_drm(adev)->primary;
2584 struct dentry *root = minor->debugfs_root;
2587 ret = amdgpu_debugfs_add_files(adev, amdgpu_dm_debugfs_list,
2588 ARRAY_SIZE(amdgpu_dm_debugfs_list));
2592 debugfs_create_file("amdgpu_dm_dtn_log", 0644, root, adev,
2595 debugfs_create_file_unsafe("amdgpu_dm_visual_confirm", 0644, root, adev,
2596 &visual_confirm_fops);
2598 debugfs_create_file_unsafe("amdgpu_dm_dmub_tracebuffer", 0644, root,
2599 adev, &dmub_tracebuffer_fops);
2601 debugfs_create_file_unsafe("amdgpu_dm_dmub_fw_state", 0644, root,
2602 adev, &dmub_fw_state_fops);
2604 debugfs_create_file_unsafe("amdgpu_dm_force_timing_sync", 0644, root,
2605 adev, &force_timing_sync_ops);