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/string_helpers.h>
27 #include <linux/uaccess.h>
31 #include "amdgpu_dm.h"
32 #include "amdgpu_dm_debugfs.h"
33 #include "dm_helpers.h"
34 #include "dmub/dmub_srv.h"
37 #include "link_hwss.h"
38 #include "dc/dc_dmub_srv.h"
39 #include "link/protocols/link_dp_capability.h"
40 #include "inc/hw/dchubbub.h"
42 #ifdef CONFIG_DRM_AMD_SECURE_DISPLAY
43 #include "amdgpu_dm_psr.h"
46 struct dmub_debugfs_trace_header {
51 struct dmub_debugfs_trace_entry {
58 static const char *const mst_progress_status[] = {
61 "allocate_new_payload",
62 "clear_allocated_payload",
65 /* parse_write_buffer_into_params - Helper function to parse debugfs write buffer into an array
67 * Function takes in attributes passed to debugfs write entry
68 * and writes into param array.
69 * The user passes max_param_num to identify maximum number of
70 * parameters that could be parsed.
73 static int parse_write_buffer_into_params(char *wr_buf, uint32_t wr_buf_size,
74 long *param, const char __user *buf,
78 char *wr_buf_ptr = NULL;
79 uint32_t wr_buf_count = 0;
82 const char delimiter[3] = {' ', '\n', '\0'};
83 uint8_t param_index = 0;
89 /* r is bytes not be copied */
90 if (copy_from_user(wr_buf_ptr, buf, wr_buf_size)) {
91 DRM_DEBUG_DRIVER("user data could not be read successfully\n");
95 /* check number of parameters. isspace could not differ space and \n */
96 while ((*wr_buf_ptr != 0xa) && (wr_buf_count < wr_buf_size)) {
98 while (isspace(*wr_buf_ptr) && (wr_buf_count < wr_buf_size)) {
103 if (wr_buf_count == wr_buf_size)
107 while ((!isspace(*wr_buf_ptr)) && (wr_buf_count < wr_buf_size)) {
114 if (wr_buf_count == wr_buf_size)
118 if (*param_nums > max_param_num)
119 *param_nums = max_param_num;
121 wr_buf_ptr = wr_buf; /* reset buf pointer */
122 wr_buf_count = 0; /* number of char already checked */
124 while (isspace(*wr_buf_ptr) && (wr_buf_count < wr_buf_size)) {
129 while (param_index < *param_nums) {
130 /* after strsep, wr_buf_ptr will be moved to after space */
131 sub_str = strsep(&wr_buf_ptr, delimiter);
133 r = kstrtol(sub_str, 16, &(param[param_index]));
136 DRM_DEBUG_DRIVER("string to int convert error code: %d\n", r);
144 /* function description
145 * get/ set DP configuration: lane_count, link_rate, spread_spectrum
147 * valid lane count value: 1, 2, 4
148 * valid link rate value:
149 * 06h = 1.62Gbps per lane
150 * 0Ah = 2.7Gbps per lane
151 * 0Ch = 3.24Gbps per lane
152 * 14h = 5.4Gbps per lane
153 * 1Eh = 8.1Gbps per lane
155 * debugfs is located at /sys/kernel/debug/dri/0/DP-x/link_settings
157 * --- to get dp configuration
159 * cat /sys/kernel/debug/dri/0/DP-x/link_settings
161 * It will list current, verified, reported, preferred dp configuration.
162 * current -- for current video mode
163 * verified --- maximum configuration which pass link training
164 * reported --- DP rx report caps (DPCD register offset 0, 1 2)
165 * preferred --- user force settings
167 * --- set (or force) dp configuration
169 * echo <lane_count> <link_rate> > link_settings
171 * for example, to force to 2 lane, 2.7GHz,
172 * echo 4 0xa > /sys/kernel/debug/dri/0/DP-x/link_settings
174 * spread_spectrum could not be changed dynamically.
176 * in case invalid lane count, link rate are force, no hw programming will be
177 * done. please check link settings after force operation to see if HW get
180 * cat /sys/kernel/debug/dri/0/DP-x/link_settings
182 * check current and preferred settings.
185 static ssize_t dp_link_settings_read(struct file *f, char __user *buf,
186 size_t size, loff_t *pos)
188 struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
189 struct dc_link *link = connector->dc_link;
191 char *rd_buf_ptr = NULL;
192 const uint32_t rd_buf_size = 100;
197 if (*pos & 3 || size & 3)
200 rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
206 str_len = strlen("Current: %d 0x%x %d ");
207 snprintf(rd_buf_ptr, str_len, "Current: %d 0x%x %d ",
208 link->cur_link_settings.lane_count,
209 link->cur_link_settings.link_rate,
210 link->cur_link_settings.link_spread);
211 rd_buf_ptr += str_len;
213 str_len = strlen("Verified: %d 0x%x %d ");
214 snprintf(rd_buf_ptr, str_len, "Verified: %d 0x%x %d ",
215 link->verified_link_cap.lane_count,
216 link->verified_link_cap.link_rate,
217 link->verified_link_cap.link_spread);
218 rd_buf_ptr += str_len;
220 str_len = strlen("Reported: %d 0x%x %d ");
221 snprintf(rd_buf_ptr, str_len, "Reported: %d 0x%x %d ",
222 link->reported_link_cap.lane_count,
223 link->reported_link_cap.link_rate,
224 link->reported_link_cap.link_spread);
225 rd_buf_ptr += str_len;
227 str_len = strlen("Preferred: %d 0x%x %d ");
228 snprintf(rd_buf_ptr, str_len, "Preferred: %d 0x%x %d\n",
229 link->preferred_link_setting.lane_count,
230 link->preferred_link_setting.link_rate,
231 link->preferred_link_setting.link_spread);
234 if (*pos >= rd_buf_size)
237 r = put_user(*(rd_buf + result), buf);
240 return r; /* r = -EFAULT */
253 static ssize_t dp_link_settings_write(struct file *f, const char __user *buf,
254 size_t size, loff_t *pos)
256 struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
257 struct dc_link *link = connector->dc_link;
258 struct amdgpu_device *adev = drm_to_adev(connector->base.dev);
259 struct dc *dc = (struct dc *)link->dc;
260 struct dc_link_settings prefer_link_settings;
262 const uint32_t wr_buf_size = 40;
263 /* 0: lane_count; 1: link_rate */
264 int max_param_num = 2;
265 uint8_t param_nums = 0;
267 bool valid_input = true;
272 wr_buf = kcalloc(wr_buf_size, sizeof(char), GFP_KERNEL);
276 if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
284 if (param_nums <= 0) {
286 DRM_DEBUG_DRIVER("user data not be read\n");
293 case LANE_COUNT_FOUR:
304 case LINK_RATE_HIGH2:
305 case LINK_RATE_HIGH3:
306 case LINK_RATE_UHBR10:
307 case LINK_RATE_UHBR13_5:
308 case LINK_RATE_UHBR20:
317 DRM_DEBUG_DRIVER("Invalid Input value No HW will be programmed\n");
318 mutex_lock(&adev->dm.dc_lock);
319 dc_link_set_preferred_training_settings(dc, NULL, NULL, link, false);
320 mutex_unlock(&adev->dm.dc_lock);
324 /* save user force lane_count, link_rate to preferred settings
325 * spread spectrum will not be changed
327 prefer_link_settings.link_spread = link->cur_link_settings.link_spread;
328 prefer_link_settings.use_link_rate_set = false;
329 prefer_link_settings.lane_count = param[0];
330 prefer_link_settings.link_rate = param[1];
332 mutex_lock(&adev->dm.dc_lock);
333 dc_link_set_preferred_training_settings(dc, &prefer_link_settings, NULL, link, false);
334 mutex_unlock(&adev->dm.dc_lock);
340 static bool dp_mst_is_end_device(struct amdgpu_dm_connector *aconnector)
342 bool is_end_device = false;
343 struct drm_dp_mst_topology_mgr *mgr = NULL;
344 struct drm_dp_mst_port *port = NULL;
346 if (aconnector->mst_root && aconnector->mst_root->mst_mgr.mst_state) {
347 mgr = &aconnector->mst_root->mst_mgr;
348 port = aconnector->mst_output_port;
350 drm_modeset_lock(&mgr->base.lock, NULL);
351 if (port->pdt == DP_PEER_DEVICE_SST_SINK ||
352 port->pdt == DP_PEER_DEVICE_DP_LEGACY_CONV)
353 is_end_device = true;
354 drm_modeset_unlock(&mgr->base.lock);
357 return is_end_device;
360 /* Change MST link setting
362 * valid lane count value: 1, 2, 4
363 * valid link rate value:
364 * 06h = 1.62Gbps per lane
365 * 0Ah = 2.7Gbps per lane
366 * 0Ch = 3.24Gbps per lane
367 * 14h = 5.4Gbps per lane
368 * 1Eh = 8.1Gbps per lane
369 * 3E8h = 10.0Gbps per lane
370 * 546h = 13.5Gbps per lane
371 * 7D0h = 20.0Gbps per lane
373 * debugfs is located at /sys/kernel/debug/dri/0/DP-x/mst_link_settings
375 * for example, to force to 2 lane, 10.0GHz,
376 * echo 2 0x3e8 > /sys/kernel/debug/dri/0/DP-x/mst_link_settings
378 * Valid input will trigger hotplug event to get new link setting applied
379 * Invalid input will trigger training setting reset
381 * The usage can be referred to link_settings entry
384 static ssize_t dp_mst_link_setting(struct file *f, const char __user *buf,
385 size_t size, loff_t *pos)
387 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
388 struct dc_link *link = aconnector->dc_link;
389 struct amdgpu_device *adev = drm_to_adev(aconnector->base.dev);
390 struct dc *dc = (struct dc *)link->dc;
391 struct dc_link_settings prefer_link_settings;
393 const uint32_t wr_buf_size = 40;
394 /* 0: lane_count; 1: link_rate */
395 int max_param_num = 2;
396 uint8_t param_nums = 0;
398 bool valid_input = true;
400 if (!dp_mst_is_end_device(aconnector))
406 wr_buf = kcalloc(wr_buf_size, sizeof(char), GFP_KERNEL);
410 if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
418 if (param_nums <= 0) {
420 DRM_DEBUG_DRIVER("user data not be read\n");
427 case LANE_COUNT_FOUR:
438 case LINK_RATE_HIGH2:
439 case LINK_RATE_HIGH3:
440 case LINK_RATE_UHBR10:
441 case LINK_RATE_UHBR13_5:
442 case LINK_RATE_UHBR20:
451 DRM_DEBUG_DRIVER("Invalid Input value No HW will be programmed\n");
452 mutex_lock(&adev->dm.dc_lock);
453 dc_link_set_preferred_training_settings(dc, NULL, NULL, link, false);
454 mutex_unlock(&adev->dm.dc_lock);
458 /* save user force lane_count, link_rate to preferred settings
459 * spread spectrum will not be changed
461 prefer_link_settings.link_spread = link->cur_link_settings.link_spread;
462 prefer_link_settings.use_link_rate_set = false;
463 prefer_link_settings.lane_count = param[0];
464 prefer_link_settings.link_rate = param[1];
466 /* skip immediate retrain, and train to new link setting after hotplug event triggered */
467 mutex_lock(&adev->dm.dc_lock);
468 dc_link_set_preferred_training_settings(dc, &prefer_link_settings, NULL, link, true);
469 mutex_unlock(&adev->dm.dc_lock);
471 mutex_lock(&aconnector->base.dev->mode_config.mutex);
472 aconnector->base.force = DRM_FORCE_OFF;
473 mutex_unlock(&aconnector->base.dev->mode_config.mutex);
474 drm_kms_helper_hotplug_event(aconnector->base.dev);
478 mutex_lock(&aconnector->base.dev->mode_config.mutex);
479 aconnector->base.force = DRM_FORCE_UNSPECIFIED;
480 mutex_unlock(&aconnector->base.dev->mode_config.mutex);
481 drm_kms_helper_hotplug_event(aconnector->base.dev);
487 /* function: get current DP PHY settings: voltage swing, pre-emphasis,
488 * post-cursor2 (defined by VESA DP specification)
491 * voltage swing: 0,1,2,3
492 * pre-emphasis : 0,1,2,3
493 * post cursor2 : 0,1,2,3
496 * how to use this debugfs
498 * debugfs is located at /sys/kernel/debug/dri/0/DP-x
500 * there will be directories, like DP-1, DP-2,DP-3, etc. for DP display
502 * To figure out which DP-x is the display for DP to be check,
505 * There should be debugfs file, like link_settings, phy_settings.
507 * from lane_count, link_rate to figure which DP-x is for display to be worked
510 * To get current DP PHY settings,
513 * To change DP PHY settings,
514 * echo <voltage_swing> <pre-emphasis> <post_cursor2> > phy_settings
515 * for examle, to change voltage swing to 2, pre-emphasis to 3, post_cursor2 to
517 * echo 2 3 0 > phy_settings
519 * To check if change be applied, get current phy settings by
522 * In case invalid values are set by user, like
523 * echo 1 4 0 > phy_settings
525 * HW will NOT be programmed by these settings.
526 * cat phy_settings will show the previous valid settings.
528 static ssize_t dp_phy_settings_read(struct file *f, char __user *buf,
529 size_t size, loff_t *pos)
531 struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
532 struct dc_link *link = connector->dc_link;
534 const uint32_t rd_buf_size = 20;
538 if (*pos & 3 || size & 3)
541 rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
545 snprintf(rd_buf, rd_buf_size, " %d %d %d\n",
546 link->cur_lane_setting[0].VOLTAGE_SWING,
547 link->cur_lane_setting[0].PRE_EMPHASIS,
548 link->cur_lane_setting[0].POST_CURSOR2);
551 if (*pos >= rd_buf_size)
554 r = put_user((*(rd_buf + result)), buf);
557 return r; /* r = -EFAULT */
570 static int dp_lttpr_status_show(struct seq_file *m, void *unused)
572 struct drm_connector *connector = m->private;
573 struct amdgpu_dm_connector *aconnector =
574 to_amdgpu_dm_connector(connector);
575 struct dc_lttpr_caps caps = aconnector->dc_link->dpcd_caps.lttpr_caps;
577 if (connector->status != connector_status_connected)
580 seq_printf(m, "phy repeater count: %u (raw: 0x%x)\n",
581 dp_parse_lttpr_repeater_count(caps.phy_repeater_cnt),
582 caps.phy_repeater_cnt);
584 seq_puts(m, "phy repeater mode: ");
587 case DP_PHY_REPEATER_MODE_TRANSPARENT:
588 seq_puts(m, "transparent");
590 case DP_PHY_REPEATER_MODE_NON_TRANSPARENT:
591 seq_puts(m, "non-transparent");
594 seq_puts(m, "non lttpr");
597 seq_printf(m, "read error (raw: 0x%x)", caps.mode);
605 static ssize_t dp_phy_settings_write(struct file *f, const char __user *buf,
606 size_t size, loff_t *pos)
608 struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
609 struct dc_link *link = connector->dc_link;
610 struct dc *dc = (struct dc *)link->dc;
612 uint32_t wr_buf_size = 40;
614 bool use_prefer_link_setting;
615 struct link_training_settings link_lane_settings;
616 int max_param_num = 3;
617 uint8_t param_nums = 0;
624 wr_buf = kcalloc(wr_buf_size, sizeof(char), GFP_KERNEL);
628 if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
636 if (param_nums <= 0) {
638 DRM_DEBUG_DRIVER("user data not be read\n");
642 if ((param[0] > VOLTAGE_SWING_MAX_LEVEL) ||
643 (param[1] > PRE_EMPHASIS_MAX_LEVEL) ||
644 (param[2] > POST_CURSOR2_MAX_LEVEL)) {
646 DRM_DEBUG_DRIVER("Invalid Input No HW will be programmed\n");
650 /* get link settings: lane count, link rate */
651 use_prefer_link_setting =
652 ((link->preferred_link_setting.link_rate != LINK_RATE_UNKNOWN) &&
653 (link->test_pattern_enabled));
655 memset(&link_lane_settings, 0, sizeof(link_lane_settings));
657 if (use_prefer_link_setting) {
658 link_lane_settings.link_settings.lane_count =
659 link->preferred_link_setting.lane_count;
660 link_lane_settings.link_settings.link_rate =
661 link->preferred_link_setting.link_rate;
662 link_lane_settings.link_settings.link_spread =
663 link->preferred_link_setting.link_spread;
665 link_lane_settings.link_settings.lane_count =
666 link->cur_link_settings.lane_count;
667 link_lane_settings.link_settings.link_rate =
668 link->cur_link_settings.link_rate;
669 link_lane_settings.link_settings.link_spread =
670 link->cur_link_settings.link_spread;
673 /* apply phy settings from user */
674 for (r = 0; r < link_lane_settings.link_settings.lane_count; r++) {
675 link_lane_settings.hw_lane_settings[r].VOLTAGE_SWING =
676 (enum dc_voltage_swing) (param[0]);
677 link_lane_settings.hw_lane_settings[r].PRE_EMPHASIS =
678 (enum dc_pre_emphasis) (param[1]);
679 link_lane_settings.hw_lane_settings[r].POST_CURSOR2 =
680 (enum dc_post_cursor2) (param[2]);
683 /* program ASIC registers and DPCD registers */
684 dc_link_set_drive_settings(dc, &link_lane_settings, link);
690 /* function description
692 * set PHY layer or Link layer test pattern
693 * PHY test pattern is used for PHY SI check.
694 * Link layer test will not affect PHY SI.
696 * Reset Test Pattern:
697 * 0 = DP_TEST_PATTERN_VIDEO_MODE
699 * PHY test pattern supported:
700 * 1 = DP_TEST_PATTERN_D102
701 * 2 = DP_TEST_PATTERN_SYMBOL_ERROR
702 * 3 = DP_TEST_PATTERN_PRBS7
703 * 4 = DP_TEST_PATTERN_80BIT_CUSTOM
704 * 5 = DP_TEST_PATTERN_CP2520_1
705 * 6 = DP_TEST_PATTERN_CP2520_2 = DP_TEST_PATTERN_HBR2_COMPLIANCE_EYE
706 * 7 = DP_TEST_PATTERN_CP2520_3
708 * DP PHY Link Training Patterns
709 * 8 = DP_TEST_PATTERN_TRAINING_PATTERN1
710 * 9 = DP_TEST_PATTERN_TRAINING_PATTERN2
711 * a = DP_TEST_PATTERN_TRAINING_PATTERN3
712 * b = DP_TEST_PATTERN_TRAINING_PATTERN4
714 * DP Link Layer Test pattern
715 * c = DP_TEST_PATTERN_COLOR_SQUARES
716 * d = DP_TEST_PATTERN_COLOR_SQUARES_CEA
717 * e = DP_TEST_PATTERN_VERTICAL_BARS
718 * f = DP_TEST_PATTERN_HORIZONTAL_BARS
719 * 10= DP_TEST_PATTERN_COLOR_RAMP
721 * debugfs phy_test_pattern is located at /syskernel/debug/dri/0/DP-x
723 * --- set test pattern
724 * echo <test pattern #> > test_pattern
726 * If test pattern # is not supported, NO HW programming will be done.
727 * for DP_TEST_PATTERN_80BIT_CUSTOM, it needs extra 10 bytes of data
728 * for the user pattern. input 10 bytes data are separated by space
730 * echo 0x4 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88 0x99 0xaa > test_pattern
732 * --- reset test pattern
733 * echo 0 > test_pattern
735 * --- HPD detection is disabled when set PHY test pattern
737 * when PHY test pattern (pattern # within [1,7]) is set, HPD pin of HW ASIC
738 * is disable. User could unplug DP display from DP connected and plug scope to
739 * check test pattern PHY SI.
740 * If there is need unplug scope and plug DP display back, do steps below:
741 * echo 0 > phy_test_pattern
745 * "echo 0 > phy_test_pattern" will re-enable HPD pin again so that video sw
746 * driver could detect "unplug scope" and "plug DP display"
748 static ssize_t dp_phy_test_pattern_debugfs_write(struct file *f, const char __user *buf,
749 size_t size, loff_t *pos)
751 struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
752 struct dc_link *link = connector->dc_link;
754 uint32_t wr_buf_size = 100;
755 long param[11] = {0x0};
756 int max_param_num = 11;
757 enum dp_test_pattern test_pattern = DP_TEST_PATTERN_UNSUPPORTED;
758 bool disable_hpd = false;
759 bool valid_test_pattern = false;
760 uint8_t param_nums = 0;
761 /* init with default 80bit custom pattern */
762 uint8_t custom_pattern[10] = {
763 0x1f, 0x7c, 0xf0, 0xc1, 0x07,
764 0x1f, 0x7c, 0xf0, 0xc1, 0x07
766 struct dc_link_settings prefer_link_settings = {LANE_COUNT_UNKNOWN,
767 LINK_RATE_UNKNOWN, LINK_SPREAD_DISABLED};
768 struct dc_link_settings cur_link_settings = {LANE_COUNT_UNKNOWN,
769 LINK_RATE_UNKNOWN, LINK_SPREAD_DISABLED};
770 struct link_training_settings link_training_settings;
776 wr_buf = kcalloc(wr_buf_size, sizeof(char), GFP_KERNEL);
780 if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
788 if (param_nums <= 0) {
790 DRM_DEBUG_DRIVER("user data not be read\n");
795 test_pattern = param[0];
797 switch (test_pattern) {
798 case DP_TEST_PATTERN_VIDEO_MODE:
799 case DP_TEST_PATTERN_COLOR_SQUARES:
800 case DP_TEST_PATTERN_COLOR_SQUARES_CEA:
801 case DP_TEST_PATTERN_VERTICAL_BARS:
802 case DP_TEST_PATTERN_HORIZONTAL_BARS:
803 case DP_TEST_PATTERN_COLOR_RAMP:
804 valid_test_pattern = true;
807 case DP_TEST_PATTERN_D102:
808 case DP_TEST_PATTERN_SYMBOL_ERROR:
809 case DP_TEST_PATTERN_PRBS7:
810 case DP_TEST_PATTERN_80BIT_CUSTOM:
811 case DP_TEST_PATTERN_HBR2_COMPLIANCE_EYE:
812 case DP_TEST_PATTERN_TRAINING_PATTERN4:
814 valid_test_pattern = true;
818 valid_test_pattern = false;
819 test_pattern = DP_TEST_PATTERN_UNSUPPORTED;
823 if (!valid_test_pattern) {
825 DRM_DEBUG_DRIVER("Invalid Test Pattern Parameters\n");
829 if (test_pattern == DP_TEST_PATTERN_80BIT_CUSTOM) {
830 for (i = 0; i < 10; i++) {
831 if ((uint8_t) param[i + 1] != 0x0)
836 /* not use default value */
837 for (i = 0; i < 10; i++)
838 custom_pattern[i] = (uint8_t) param[i + 1];
842 /* Usage: set DP physical test pattern using debugfs with normal DP
843 * panel. Then plug out DP panel and connect a scope to measure
844 * For normal video mode and test pattern generated from CRCT,
845 * they are visibile to user. So do not disable HPD.
846 * Video Mode is also set to clear the test pattern, so enable HPD
847 * because it might have been disabled after a test pattern was set.
848 * AUX depends on HPD * sequence dependent, do not move!
851 dc_link_enable_hpd(link);
853 prefer_link_settings.lane_count = link->verified_link_cap.lane_count;
854 prefer_link_settings.link_rate = link->verified_link_cap.link_rate;
855 prefer_link_settings.link_spread = link->verified_link_cap.link_spread;
857 cur_link_settings.lane_count = link->cur_link_settings.lane_count;
858 cur_link_settings.link_rate = link->cur_link_settings.link_rate;
859 cur_link_settings.link_spread = link->cur_link_settings.link_spread;
861 link_training_settings.link_settings = cur_link_settings;
864 if (test_pattern != DP_TEST_PATTERN_VIDEO_MODE) {
865 if (prefer_link_settings.lane_count != LANE_COUNT_UNKNOWN &&
866 prefer_link_settings.link_rate != LINK_RATE_UNKNOWN &&
867 (prefer_link_settings.lane_count != cur_link_settings.lane_count ||
868 prefer_link_settings.link_rate != cur_link_settings.link_rate))
869 link_training_settings.link_settings = prefer_link_settings;
872 for (i = 0; i < (unsigned int)(link_training_settings.link_settings.lane_count); i++)
873 link_training_settings.hw_lane_settings[i] = link->cur_lane_setting[i];
875 dc_link_dp_set_test_pattern(
878 DP_TEST_PATTERN_COLOR_SPACE_RGB,
879 &link_training_settings,
883 /* Usage: Set DP physical test pattern using AMDDP with normal DP panel
884 * Then plug out DP panel and connect a scope to measure DP PHY signal.
885 * Need disable interrupt to avoid SW driver disable DP output. This is
886 * done after the test pattern is set.
888 if (valid_test_pattern && disable_hpd)
889 dc_link_disable_hpd(link);
897 * Returns the DMCUB tracebuffer contents.
898 * Example usage: cat /sys/kernel/debug/dri/0/amdgpu_dm_dmub_tracebuffer
900 static int dmub_tracebuffer_show(struct seq_file *m, void *data)
902 struct amdgpu_device *adev = m->private;
903 struct dmub_srv_fb_info *fb_info = adev->dm.dmub_fb_info;
904 struct dmub_debugfs_trace_entry *entries;
906 uint32_t tbuf_size, max_entries, num_entries, i;
911 tbuf_base = (uint8_t *)fb_info->fb[DMUB_WINDOW_5_TRACEBUFF].cpu_addr;
915 tbuf_size = fb_info->fb[DMUB_WINDOW_5_TRACEBUFF].size;
916 max_entries = (tbuf_size - sizeof(struct dmub_debugfs_trace_header)) /
917 sizeof(struct dmub_debugfs_trace_entry);
920 ((struct dmub_debugfs_trace_header *)tbuf_base)->entry_count;
922 num_entries = min(num_entries, max_entries);
924 entries = (struct dmub_debugfs_trace_entry
926 sizeof(struct dmub_debugfs_trace_header));
928 for (i = 0; i < num_entries; ++i) {
929 struct dmub_debugfs_trace_entry *entry = &entries[i];
932 "trace_code=%u tick_count=%u param0=%u param1=%u\n",
933 entry->trace_code, entry->tick_count, entry->param0,
941 * Returns the DMCUB firmware state contents.
942 * Example usage: cat /sys/kernel/debug/dri/0/amdgpu_dm_dmub_fw_state
944 static int dmub_fw_state_show(struct seq_file *m, void *data)
946 struct amdgpu_device *adev = m->private;
947 struct dmub_srv_fb_info *fb_info = adev->dm.dmub_fb_info;
954 state_base = (uint8_t *)fb_info->fb[DMUB_WINDOW_6_FW_STATE].cpu_addr;
958 state_size = fb_info->fb[DMUB_WINDOW_6_FW_STATE].size;
960 return seq_write(m, state_base, state_size);
963 /* psr_capability_show() - show eDP panel PSR capability
965 * The read function: sink_psr_capability_show
966 * Shows if sink has PSR capability or not.
967 * If yes - the PSR version is appended
969 * cat /sys/kernel/debug/dri/0/eDP-X/psr_capability
972 * "Sink support: no\n" - if panel doesn't support PSR
973 * "Sink support: yes [0x01]\n" - if panel supports PSR1
974 * "Driver support: no\n" - if driver doesn't support PSR
975 * "Driver support: yes [0x01]\n" - if driver supports PSR1
977 static int psr_capability_show(struct seq_file *m, void *data)
979 struct drm_connector *connector = m->private;
980 struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);
981 struct dc_link *link = aconnector->dc_link;
986 if (link->type == dc_connection_none)
989 if (!(link->connector_signal & SIGNAL_TYPE_EDP))
992 seq_printf(m, "Sink support: %s", str_yes_no(link->dpcd_caps.psr_info.psr_version != 0));
993 if (link->dpcd_caps.psr_info.psr_version)
994 seq_printf(m, " [0x%02x]", link->dpcd_caps.psr_info.psr_version);
997 seq_printf(m, "Driver support: %s", str_yes_no(link->psr_settings.psr_feature_enabled));
998 if (link->psr_settings.psr_version)
999 seq_printf(m, " [0x%02x]", link->psr_settings.psr_version);
1006 * Returns the current bpc for the crtc.
1007 * Example usage: cat /sys/kernel/debug/dri/0/crtc-0/amdgpu_current_bpc
1009 static int amdgpu_current_bpc_show(struct seq_file *m, void *data)
1011 struct drm_crtc *crtc = m->private;
1012 struct drm_device *dev = crtc->dev;
1013 struct dm_crtc_state *dm_crtc_state = NULL;
1017 mutex_lock(&dev->mode_config.mutex);
1018 drm_modeset_lock(&crtc->mutex, NULL);
1019 if (crtc->state == NULL)
1022 dm_crtc_state = to_dm_crtc_state(crtc->state);
1023 if (dm_crtc_state->stream == NULL)
1026 switch (dm_crtc_state->stream->timing.display_color_depth) {
1027 case COLOR_DEPTH_666:
1030 case COLOR_DEPTH_888:
1033 case COLOR_DEPTH_101010:
1036 case COLOR_DEPTH_121212:
1039 case COLOR_DEPTH_161616:
1046 seq_printf(m, "Current: %u\n", bpc);
1050 drm_modeset_unlock(&crtc->mutex);
1051 mutex_unlock(&dev->mode_config.mutex);
1055 DEFINE_SHOW_ATTRIBUTE(amdgpu_current_bpc);
1058 * Returns the current colorspace for the crtc.
1059 * Example usage: cat /sys/kernel/debug/dri/0/crtc-0/amdgpu_current_colorspace
1061 static int amdgpu_current_colorspace_show(struct seq_file *m, void *data)
1063 struct drm_crtc *crtc = m->private;
1064 struct drm_device *dev = crtc->dev;
1065 struct dm_crtc_state *dm_crtc_state = NULL;
1068 mutex_lock(&dev->mode_config.mutex);
1069 drm_modeset_lock(&crtc->mutex, NULL);
1070 if (crtc->state == NULL)
1073 dm_crtc_state = to_dm_crtc_state(crtc->state);
1074 if (dm_crtc_state->stream == NULL)
1077 switch (dm_crtc_state->stream->output_color_space) {
1078 case COLOR_SPACE_SRGB:
1079 seq_puts(m, "sRGB");
1081 case COLOR_SPACE_YCBCR601:
1082 case COLOR_SPACE_YCBCR601_LIMITED:
1083 seq_puts(m, "BT601_YCC");
1085 case COLOR_SPACE_YCBCR709:
1086 case COLOR_SPACE_YCBCR709_LIMITED:
1087 seq_puts(m, "BT709_YCC");
1089 case COLOR_SPACE_ADOBERGB:
1090 seq_puts(m, "opRGB");
1092 case COLOR_SPACE_2020_RGB_FULLRANGE:
1093 seq_puts(m, "BT2020_RGB");
1095 case COLOR_SPACE_2020_YCBCR:
1096 seq_puts(m, "BT2020_YCC");
1104 drm_modeset_unlock(&crtc->mutex);
1105 mutex_unlock(&dev->mode_config.mutex);
1109 DEFINE_SHOW_ATTRIBUTE(amdgpu_current_colorspace);
1114 * Disable dsc passthrough, i.e.,: have dsc decoding at converver, not external RX
1115 * echo 1 /sys/kernel/debug/dri/0/DP-1/dsc_disable_passthrough
1116 * Enable dsc passthrough, i.e.,: have dsc passthrough to external RX
1117 * echo 0 /sys/kernel/debug/dri/0/DP-1/dsc_disable_passthrough
1119 static ssize_t dp_dsc_passthrough_set(struct file *f, const char __user *buf,
1120 size_t size, loff_t *pos)
1122 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
1123 char *wr_buf = NULL;
1124 uint32_t wr_buf_size = 42;
1125 int max_param_num = 1;
1127 uint8_t param_nums = 0;
1132 wr_buf = kcalloc(wr_buf_size, sizeof(char), GFP_KERNEL);
1135 DRM_DEBUG_DRIVER("no memory to allocate write buffer\n");
1139 if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
1147 aconnector->dsc_settings.dsc_force_disable_passthrough = param;
1154 * Returns the HDCP capability of the Display (1.4 for now).
1156 * NOTE* Not all HDMI displays report their HDCP caps even when they are capable.
1157 * Since its rare for a display to not be HDCP 1.4 capable, we set HDMI as always capable.
1159 * Example usage: cat /sys/kernel/debug/dri/0/DP-1/hdcp_sink_capability
1160 * or cat /sys/kernel/debug/dri/0/HDMI-A-1/hdcp_sink_capability
1162 static int hdcp_sink_capability_show(struct seq_file *m, void *data)
1164 struct drm_connector *connector = m->private;
1165 struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);
1166 bool hdcp_cap, hdcp2_cap;
1168 if (connector->status != connector_status_connected)
1171 seq_printf(m, "%s:%d HDCP version: ", connector->name, connector->base.id);
1173 hdcp_cap = dc_link_is_hdcp14(aconnector->dc_link, aconnector->dc_sink->sink_signal);
1174 hdcp2_cap = dc_link_is_hdcp22(aconnector->dc_link, aconnector->dc_sink->sink_signal);
1178 seq_printf(m, "%s ", "HDCP1.4");
1180 seq_printf(m, "%s ", "HDCP2.2");
1182 if (!hdcp_cap && !hdcp2_cap)
1183 seq_printf(m, "%s ", "None");
1191 * Returns whether the connected display is internal and not hotpluggable.
1192 * Example usage: cat /sys/kernel/debug/dri/0/DP-1/internal_display
1194 static int internal_display_show(struct seq_file *m, void *data)
1196 struct drm_connector *connector = m->private;
1197 struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);
1198 struct dc_link *link = aconnector->dc_link;
1200 seq_printf(m, "Internal: %u\n", link->is_internal_display);
1206 * Returns the number of segments used if ODM Combine mode is enabled.
1207 * Example usage: cat /sys/kernel/debug/dri/0/DP-1/odm_combine_segments
1209 static int odm_combine_segments_show(struct seq_file *m, void *unused)
1211 struct drm_connector *connector = m->private;
1212 struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);
1213 struct dc_link *link = aconnector->dc_link;
1214 struct pipe_ctx *pipe_ctx = NULL;
1215 int i, segments = -EOPNOTSUPP;
1217 for (i = 0; i < MAX_PIPES; i++) {
1218 pipe_ctx = &link->dc->current_state->res_ctx.pipe_ctx[i];
1219 if (pipe_ctx->stream &&
1220 pipe_ctx->stream->link == link)
1224 if (connector->status != connector_status_connected)
1227 if (pipe_ctx != NULL && pipe_ctx->stream_res.tg->funcs->get_odm_combine_segments)
1228 pipe_ctx->stream_res.tg->funcs->get_odm_combine_segments(pipe_ctx->stream_res.tg, &segments);
1230 seq_printf(m, "%d\n", segments);
1234 /* function description
1236 * generic SDP message access for testing
1238 * debugfs sdp_message is located at /syskernel/debug/dri/0/DP-x
1241 * Hb0 : Secondary-Data Packet ID
1242 * Hb1 : Secondary-Data Packet type
1243 * Hb2 : Secondary-Data-packet-specific header, Byte 0
1244 * Hb3 : Secondary-Data-packet-specific header, Byte 1
1246 * for using custom sdp message: input 4 bytes SDP header and 32 bytes raw data
1248 static ssize_t dp_sdp_message_debugfs_write(struct file *f, const char __user *buf,
1249 size_t size, loff_t *pos)
1253 struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
1254 struct dm_crtc_state *acrtc_state;
1255 uint32_t write_size = 36;
1257 if (connector->base.status != connector_status_connected)
1263 acrtc_state = to_dm_crtc_state(connector->base.state->crtc->state);
1265 r = copy_from_user(data, buf, write_size);
1269 dc_stream_send_dp_sdp(acrtc_state->stream, data, write_size);
1274 /* function: Read link's DSC & FEC capabilities
1277 * Access it with the following command (you need to specify
1278 * connector like DP-1):
1280 * cat /sys/kernel/debug/dri/0/DP-X/dp_dsc_fec_support
1283 static int dp_dsc_fec_support_show(struct seq_file *m, void *data)
1285 struct drm_connector *connector = m->private;
1286 struct drm_modeset_acquire_ctx ctx;
1287 struct drm_device *dev = connector->dev;
1288 struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);
1290 bool try_again = false;
1291 bool is_fec_supported = false;
1292 bool is_dsc_supported = false;
1293 struct dpcd_caps dpcd_caps;
1295 drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE);
1298 ret = drm_modeset_lock(&dev->mode_config.connection_mutex, &ctx);
1300 if (ret == -EDEADLK) {
1301 ret = drm_modeset_backoff(&ctx);
1309 if (connector->status != connector_status_connected) {
1313 dpcd_caps = aconnector->dc_link->dpcd_caps;
1314 if (aconnector->mst_output_port) {
1315 /* aconnector sets dsc_aux during get_modes call
1316 * if MST connector has it means it can either
1317 * enable DSC on the sink device or on MST branch
1320 if (aconnector->dsc_aux) {
1321 is_fec_supported = true;
1322 is_dsc_supported = true;
1325 is_fec_supported = dpcd_caps.fec_cap.raw & 0x1;
1326 is_dsc_supported = dpcd_caps.dsc_caps.dsc_basic_caps.raw[0] & 0x1;
1328 } while (try_again);
1330 drm_modeset_drop_locks(&ctx);
1331 drm_modeset_acquire_fini(&ctx);
1333 seq_printf(m, "FEC_Sink_Support: %s\n", str_yes_no(is_fec_supported));
1334 seq_printf(m, "DSC_Sink_Support: %s\n", str_yes_no(is_dsc_supported));
1339 /* function: Trigger virtual HPD redetection on connector
1341 * This function will perform link rediscovery, link disable
1342 * and enable, and dm connector state update.
1344 * Retrigger HPD on an existing connector by echoing 1 into
1345 * its respectful "trigger_hotplug" debugfs entry:
1347 * echo 1 > /sys/kernel/debug/dri/0/DP-X/trigger_hotplug
1349 * This function can perform HPD unplug:
1351 * echo 0 > /sys/kernel/debug/dri/0/DP-X/trigger_hotplug
1354 static ssize_t trigger_hotplug(struct file *f, const char __user *buf,
1355 size_t size, loff_t *pos)
1357 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
1358 struct drm_connector *connector = &aconnector->base;
1359 struct dc_link *link = NULL;
1360 struct drm_device *dev = connector->dev;
1361 struct amdgpu_device *adev = drm_to_adev(dev);
1362 enum dc_connection_type new_connection_type = dc_connection_none;
1363 char *wr_buf = NULL;
1364 uint32_t wr_buf_size = 42;
1365 int max_param_num = 1;
1366 long param[1] = {0};
1367 uint8_t param_nums = 0;
1370 if (!aconnector || !aconnector->dc_link)
1376 wr_buf = kcalloc(wr_buf_size, sizeof(char), GFP_KERNEL);
1379 DRM_DEBUG_DRIVER("no memory to allocate write buffer\n");
1383 if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
1393 if (param_nums <= 0) {
1394 DRM_DEBUG_DRIVER("user data not be read\n");
1398 mutex_lock(&aconnector->hpd_lock);
1400 /* Don't support for mst end device*/
1401 if (aconnector->mst_root) {
1402 mutex_unlock(&aconnector->hpd_lock);
1406 if (param[0] == 1) {
1408 if (!dc_link_detect_connection_type(aconnector->dc_link, &new_connection_type) &&
1409 new_connection_type != dc_connection_none)
1412 mutex_lock(&adev->dm.dc_lock);
1413 ret = dc_link_detect(aconnector->dc_link, DETECT_REASON_HPD);
1414 mutex_unlock(&adev->dm.dc_lock);
1419 amdgpu_dm_update_connector_after_detect(aconnector);
1421 drm_modeset_lock_all(dev);
1422 dm_restore_drm_connector_state(dev, connector);
1423 drm_modeset_unlock_all(dev);
1425 drm_kms_helper_connector_hotplug_event(connector);
1426 } else if (param[0] == 0) {
1427 if (!aconnector->dc_link)
1430 link = aconnector->dc_link;
1432 if (link->local_sink) {
1433 dc_sink_release(link->local_sink);
1434 link->local_sink = NULL;
1437 link->dpcd_sink_count = 0;
1438 link->type = dc_connection_none;
1439 link->dongle_max_pix_clk = 0;
1441 amdgpu_dm_update_connector_after_detect(aconnector);
1443 /* If the aconnector is the root node in mst topology */
1444 if (aconnector->mst_mgr.mst_state == true)
1445 dc_link_reset_cur_dp_mst_topology(link);
1447 drm_modeset_lock_all(dev);
1448 dm_restore_drm_connector_state(dev, connector);
1449 drm_modeset_unlock_all(dev);
1451 drm_kms_helper_connector_hotplug_event(connector);
1455 mutex_unlock(&aconnector->hpd_lock);
1460 /* function: read DSC status on the connector
1462 * The read function: dp_dsc_clock_en_read
1463 * returns current status of DSC clock on the connector.
1464 * The return is a boolean flag: 1 or 0.
1466 * Access it with the following command (you need to specify
1467 * connector like DP-1):
1469 * cat /sys/kernel/debug/dri/0/DP-X/dsc_clock_en
1472 * 1 - means that DSC is currently enabled
1473 * 0 - means that DSC is disabled
1475 static ssize_t dp_dsc_clock_en_read(struct file *f, char __user *buf,
1476 size_t size, loff_t *pos)
1478 char *rd_buf = NULL;
1479 char *rd_buf_ptr = NULL;
1480 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
1481 struct display_stream_compressor *dsc;
1482 struct dcn_dsc_state dsc_state = {0};
1483 const uint32_t rd_buf_size = 10;
1484 struct pipe_ctx *pipe_ctx;
1486 int i, r, str_len = 10;
1488 rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
1493 rd_buf_ptr = rd_buf;
1495 for (i = 0; i < MAX_PIPES; i++) {
1496 pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
1497 if (pipe_ctx->stream &&
1498 pipe_ctx->stream->link == aconnector->dc_link &&
1499 pipe_ctx->stream->sink &&
1500 pipe_ctx->stream->sink == aconnector->dc_sink)
1504 dsc = pipe_ctx->stream_res.dsc;
1506 dsc->funcs->dsc_read_state(dsc, &dsc_state);
1508 snprintf(rd_buf_ptr, str_len,
1510 dsc_state.dsc_clock_en);
1511 rd_buf_ptr += str_len;
1514 if (*pos >= rd_buf_size)
1517 r = put_user(*(rd_buf + result), buf);
1520 return r; /* r = -EFAULT */
1533 /* function: write force DSC on the connector
1535 * The write function: dp_dsc_clock_en_write
1536 * enables to force DSC on the connector.
1537 * User can write to either force enable or force disable DSC
1538 * on the next modeset or set it to driver default
1541 * 0 - default DSC enablement policy
1542 * 1 - force enable DSC on the connector
1543 * 2 - force disable DSC on the connector (might cause fail in atomic_check)
1545 * Writing DSC settings is done with the following command:
1546 * - To force enable DSC (you need to specify
1547 * connector like DP-1):
1549 * echo 0x1 > /sys/kernel/debug/dri/0/DP-X/dsc_clock_en
1551 * - To return to default state set the flag to zero and
1552 * let driver deal with DSC automatically
1553 * (you need to specify connector like DP-1):
1555 * echo 0x0 > /sys/kernel/debug/dri/0/DP-X/dsc_clock_en
1558 static ssize_t dp_dsc_clock_en_write(struct file *f, const char __user *buf,
1559 size_t size, loff_t *pos)
1561 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
1562 struct drm_connector *connector = &aconnector->base;
1563 struct drm_device *dev = connector->dev;
1564 struct drm_crtc *crtc = NULL;
1565 struct dm_crtc_state *dm_crtc_state = NULL;
1566 struct pipe_ctx *pipe_ctx;
1568 char *wr_buf = NULL;
1569 uint32_t wr_buf_size = 42;
1570 int max_param_num = 1;
1571 long param[1] = {0};
1572 uint8_t param_nums = 0;
1577 wr_buf = kcalloc(wr_buf_size, sizeof(char), GFP_KERNEL);
1580 DRM_DEBUG_DRIVER("no memory to allocate write buffer\n");
1584 if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
1592 if (param_nums <= 0) {
1593 DRM_DEBUG_DRIVER("user data not be read\n");
1598 for (i = 0; i < MAX_PIPES; i++) {
1599 pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
1600 if (pipe_ctx->stream &&
1601 pipe_ctx->stream->link == aconnector->dc_link &&
1602 pipe_ctx->stream->sink &&
1603 pipe_ctx->stream->sink == aconnector->dc_sink)
1607 if (!pipe_ctx->stream)
1611 mutex_lock(&dev->mode_config.mutex);
1612 drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
1614 if (connector->state == NULL)
1617 crtc = connector->state->crtc;
1621 drm_modeset_lock(&crtc->mutex, NULL);
1622 if (crtc->state == NULL)
1625 dm_crtc_state = to_dm_crtc_state(crtc->state);
1626 if (dm_crtc_state->stream == NULL)
1630 aconnector->dsc_settings.dsc_force_enable = DSC_CLK_FORCE_ENABLE;
1631 else if (param[0] == 2)
1632 aconnector->dsc_settings.dsc_force_enable = DSC_CLK_FORCE_DISABLE;
1634 aconnector->dsc_settings.dsc_force_enable = DSC_CLK_FORCE_DEFAULT;
1636 dm_crtc_state->dsc_force_changed = true;
1640 drm_modeset_unlock(&crtc->mutex);
1641 drm_modeset_unlock(&dev->mode_config.connection_mutex);
1642 mutex_unlock(&dev->mode_config.mutex);
1649 /* function: read DSC slice width parameter on the connector
1651 * The read function: dp_dsc_slice_width_read
1652 * returns dsc slice width used in the current configuration
1653 * The return is an integer: 0 or other positive number
1655 * Access the status with the following command:
1657 * cat /sys/kernel/debug/dri/0/DP-X/dsc_slice_width
1659 * 0 - means that DSC is disabled
1661 * Any other number more than zero represents the
1662 * slice width currently used by DSC in pixels
1665 static ssize_t dp_dsc_slice_width_read(struct file *f, char __user *buf,
1666 size_t size, loff_t *pos)
1668 char *rd_buf = NULL;
1669 char *rd_buf_ptr = NULL;
1670 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
1671 struct display_stream_compressor *dsc;
1672 struct dcn_dsc_state dsc_state = {0};
1673 const uint32_t rd_buf_size = 100;
1674 struct pipe_ctx *pipe_ctx;
1676 int i, r, str_len = 30;
1678 rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
1683 rd_buf_ptr = rd_buf;
1685 for (i = 0; i < MAX_PIPES; i++) {
1686 pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
1687 if (pipe_ctx->stream &&
1688 pipe_ctx->stream->link == aconnector->dc_link &&
1689 pipe_ctx->stream->sink &&
1690 pipe_ctx->stream->sink == aconnector->dc_sink)
1694 dsc = pipe_ctx->stream_res.dsc;
1696 dsc->funcs->dsc_read_state(dsc, &dsc_state);
1698 snprintf(rd_buf_ptr, str_len,
1700 dsc_state.dsc_slice_width);
1701 rd_buf_ptr += str_len;
1704 if (*pos >= rd_buf_size)
1707 r = put_user(*(rd_buf + result), buf);
1710 return r; /* r = -EFAULT */
1723 /* function: write DSC slice width parameter
1725 * The write function: dp_dsc_slice_width_write
1726 * overwrites automatically generated DSC configuration
1729 * The user has to write the slice width divisible by the
1732 * Also the user has to write width in hexidecimal
1733 * rather than in decimal.
1735 * Writing DSC settings is done with the following command:
1736 * - To force overwrite slice width: (example sets to 1920 pixels)
1738 * echo 0x780 > /sys/kernel/debug/dri/0/DP-X/dsc_slice_width
1740 * - To stop overwriting and let driver find the optimal size,
1741 * set the width to zero:
1743 * echo 0x0 > /sys/kernel/debug/dri/0/DP-X/dsc_slice_width
1746 static ssize_t dp_dsc_slice_width_write(struct file *f, const char __user *buf,
1747 size_t size, loff_t *pos)
1749 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
1750 struct pipe_ctx *pipe_ctx;
1751 struct drm_connector *connector = &aconnector->base;
1752 struct drm_device *dev = connector->dev;
1753 struct drm_crtc *crtc = NULL;
1754 struct dm_crtc_state *dm_crtc_state = NULL;
1756 char *wr_buf = NULL;
1757 uint32_t wr_buf_size = 42;
1758 int max_param_num = 1;
1759 long param[1] = {0};
1760 uint8_t param_nums = 0;
1765 wr_buf = kcalloc(wr_buf_size, sizeof(char), GFP_KERNEL);
1768 DRM_DEBUG_DRIVER("no memory to allocate write buffer\n");
1772 if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
1780 if (param_nums <= 0) {
1781 DRM_DEBUG_DRIVER("user data not be read\n");
1786 for (i = 0; i < MAX_PIPES; i++) {
1787 pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
1788 if (pipe_ctx->stream &&
1789 pipe_ctx->stream->link == aconnector->dc_link &&
1790 pipe_ctx->stream->sink &&
1791 pipe_ctx->stream->sink == aconnector->dc_sink)
1795 if (!pipe_ctx->stream)
1798 // Safely get CRTC state
1799 mutex_lock(&dev->mode_config.mutex);
1800 drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
1802 if (connector->state == NULL)
1805 crtc = connector->state->crtc;
1809 drm_modeset_lock(&crtc->mutex, NULL);
1810 if (crtc->state == NULL)
1813 dm_crtc_state = to_dm_crtc_state(crtc->state);
1814 if (dm_crtc_state->stream == NULL)
1818 aconnector->dsc_settings.dsc_num_slices_h = DIV_ROUND_UP(
1819 pipe_ctx->stream->timing.h_addressable,
1822 aconnector->dsc_settings.dsc_num_slices_h = 0;
1824 dm_crtc_state->dsc_force_changed = true;
1828 drm_modeset_unlock(&crtc->mutex);
1829 drm_modeset_unlock(&dev->mode_config.connection_mutex);
1830 mutex_unlock(&dev->mode_config.mutex);
1837 /* function: read DSC slice height parameter on the connector
1839 * The read function: dp_dsc_slice_height_read
1840 * returns dsc slice height used in the current configuration
1841 * The return is an integer: 0 or other positive number
1843 * Access the status with the following command:
1845 * cat /sys/kernel/debug/dri/0/DP-X/dsc_slice_height
1847 * 0 - means that DSC is disabled
1849 * Any other number more than zero represents the
1850 * slice height currently used by DSC in pixels
1853 static ssize_t dp_dsc_slice_height_read(struct file *f, char __user *buf,
1854 size_t size, loff_t *pos)
1856 char *rd_buf = NULL;
1857 char *rd_buf_ptr = NULL;
1858 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
1859 struct display_stream_compressor *dsc;
1860 struct dcn_dsc_state dsc_state = {0};
1861 const uint32_t rd_buf_size = 100;
1862 struct pipe_ctx *pipe_ctx;
1864 int i, r, str_len = 30;
1866 rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
1871 rd_buf_ptr = rd_buf;
1873 for (i = 0; i < MAX_PIPES; i++) {
1874 pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
1875 if (pipe_ctx->stream &&
1876 pipe_ctx->stream->link == aconnector->dc_link &&
1877 pipe_ctx->stream->sink &&
1878 pipe_ctx->stream->sink == aconnector->dc_sink)
1882 dsc = pipe_ctx->stream_res.dsc;
1884 dsc->funcs->dsc_read_state(dsc, &dsc_state);
1886 snprintf(rd_buf_ptr, str_len,
1888 dsc_state.dsc_slice_height);
1889 rd_buf_ptr += str_len;
1892 if (*pos >= rd_buf_size)
1895 r = put_user(*(rd_buf + result), buf);
1898 return r; /* r = -EFAULT */
1911 /* function: write DSC slice height parameter
1913 * The write function: dp_dsc_slice_height_write
1914 * overwrites automatically generated DSC configuration
1917 * The user has to write the slice height divisible by the
1920 * Also the user has to write height in hexidecimal
1921 * rather than in decimal.
1923 * Writing DSC settings is done with the following command:
1924 * - To force overwrite slice height (example sets to 128 pixels):
1926 * echo 0x80 > /sys/kernel/debug/dri/0/DP-X/dsc_slice_height
1928 * - To stop overwriting and let driver find the optimal size,
1929 * set the height to zero:
1931 * echo 0x0 > /sys/kernel/debug/dri/0/DP-X/dsc_slice_height
1934 static ssize_t dp_dsc_slice_height_write(struct file *f, const char __user *buf,
1935 size_t size, loff_t *pos)
1937 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
1938 struct drm_connector *connector = &aconnector->base;
1939 struct drm_device *dev = connector->dev;
1940 struct drm_crtc *crtc = NULL;
1941 struct dm_crtc_state *dm_crtc_state = NULL;
1942 struct pipe_ctx *pipe_ctx;
1944 char *wr_buf = NULL;
1945 uint32_t wr_buf_size = 42;
1946 int max_param_num = 1;
1947 uint8_t param_nums = 0;
1948 long param[1] = {0};
1953 wr_buf = kcalloc(wr_buf_size, sizeof(char), GFP_KERNEL);
1956 DRM_DEBUG_DRIVER("no memory to allocate write buffer\n");
1960 if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
1968 if (param_nums <= 0) {
1969 DRM_DEBUG_DRIVER("user data not be read\n");
1974 for (i = 0; i < MAX_PIPES; i++) {
1975 pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
1976 if (pipe_ctx->stream &&
1977 pipe_ctx->stream->link == aconnector->dc_link &&
1978 pipe_ctx->stream->sink &&
1979 pipe_ctx->stream->sink == aconnector->dc_sink)
1983 if (!pipe_ctx->stream)
1987 mutex_lock(&dev->mode_config.mutex);
1988 drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
1990 if (connector->state == NULL)
1993 crtc = connector->state->crtc;
1997 drm_modeset_lock(&crtc->mutex, NULL);
1998 if (crtc->state == NULL)
2001 dm_crtc_state = to_dm_crtc_state(crtc->state);
2002 if (dm_crtc_state->stream == NULL)
2006 aconnector->dsc_settings.dsc_num_slices_v = DIV_ROUND_UP(
2007 pipe_ctx->stream->timing.v_addressable,
2010 aconnector->dsc_settings.dsc_num_slices_v = 0;
2012 dm_crtc_state->dsc_force_changed = true;
2016 drm_modeset_unlock(&crtc->mutex);
2017 drm_modeset_unlock(&dev->mode_config.connection_mutex);
2018 mutex_unlock(&dev->mode_config.mutex);
2025 /* function: read DSC target rate on the connector in bits per pixel
2027 * The read function: dp_dsc_bits_per_pixel_read
2028 * returns target rate of compression in bits per pixel
2029 * The return is an integer: 0 or other positive integer
2031 * Access it with the following command:
2033 * cat /sys/kernel/debug/dri/0/DP-X/dsc_bits_per_pixel
2035 * 0 - means that DSC is disabled
2037 static ssize_t dp_dsc_bits_per_pixel_read(struct file *f, char __user *buf,
2038 size_t size, loff_t *pos)
2040 char *rd_buf = NULL;
2041 char *rd_buf_ptr = NULL;
2042 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
2043 struct display_stream_compressor *dsc;
2044 struct dcn_dsc_state dsc_state = {0};
2045 const uint32_t rd_buf_size = 100;
2046 struct pipe_ctx *pipe_ctx;
2048 int i, r, str_len = 30;
2050 rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
2055 rd_buf_ptr = rd_buf;
2057 for (i = 0; i < MAX_PIPES; i++) {
2058 pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
2059 if (pipe_ctx->stream &&
2060 pipe_ctx->stream->link == aconnector->dc_link &&
2061 pipe_ctx->stream->sink &&
2062 pipe_ctx->stream->sink == aconnector->dc_sink)
2066 dsc = pipe_ctx->stream_res.dsc;
2068 dsc->funcs->dsc_read_state(dsc, &dsc_state);
2070 snprintf(rd_buf_ptr, str_len,
2072 dsc_state.dsc_bits_per_pixel);
2073 rd_buf_ptr += str_len;
2076 if (*pos >= rd_buf_size)
2079 r = put_user(*(rd_buf + result), buf);
2082 return r; /* r = -EFAULT */
2095 /* function: write DSC target rate in bits per pixel
2097 * The write function: dp_dsc_bits_per_pixel_write
2098 * overwrites automatically generated DSC configuration
2099 * of DSC target bit rate.
2101 * Also the user has to write bpp in hexidecimal
2102 * rather than in decimal.
2104 * Writing DSC settings is done with the following command:
2105 * - To force overwrite rate (example sets to 256 bpp x 1/16):
2107 * echo 0x100 > /sys/kernel/debug/dri/0/DP-X/dsc_bits_per_pixel
2109 * - To stop overwriting and let driver find the optimal rate,
2110 * set the rate to zero:
2112 * echo 0x0 > /sys/kernel/debug/dri/0/DP-X/dsc_bits_per_pixel
2115 static ssize_t dp_dsc_bits_per_pixel_write(struct file *f, const char __user *buf,
2116 size_t size, loff_t *pos)
2118 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
2119 struct drm_connector *connector = &aconnector->base;
2120 struct drm_device *dev = connector->dev;
2121 struct drm_crtc *crtc = NULL;
2122 struct dm_crtc_state *dm_crtc_state = NULL;
2123 struct pipe_ctx *pipe_ctx;
2125 char *wr_buf = NULL;
2126 uint32_t wr_buf_size = 42;
2127 int max_param_num = 1;
2128 uint8_t param_nums = 0;
2129 long param[1] = {0};
2134 wr_buf = kcalloc(wr_buf_size, sizeof(char), GFP_KERNEL);
2137 DRM_DEBUG_DRIVER("no memory to allocate write buffer\n");
2141 if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
2149 if (param_nums <= 0) {
2150 DRM_DEBUG_DRIVER("user data not be read\n");
2155 for (i = 0; i < MAX_PIPES; i++) {
2156 pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
2157 if (pipe_ctx->stream &&
2158 pipe_ctx->stream->link == aconnector->dc_link &&
2159 pipe_ctx->stream->sink &&
2160 pipe_ctx->stream->sink == aconnector->dc_sink)
2164 if (!pipe_ctx->stream)
2168 mutex_lock(&dev->mode_config.mutex);
2169 drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
2171 if (connector->state == NULL)
2174 crtc = connector->state->crtc;
2178 drm_modeset_lock(&crtc->mutex, NULL);
2179 if (crtc->state == NULL)
2182 dm_crtc_state = to_dm_crtc_state(crtc->state);
2183 if (dm_crtc_state->stream == NULL)
2186 aconnector->dsc_settings.dsc_bits_per_pixel = param[0];
2188 dm_crtc_state->dsc_force_changed = true;
2192 drm_modeset_unlock(&crtc->mutex);
2193 drm_modeset_unlock(&dev->mode_config.connection_mutex);
2194 mutex_unlock(&dev->mode_config.mutex);
2201 /* function: read DSC picture width parameter on the connector
2203 * The read function: dp_dsc_pic_width_read
2204 * returns dsc picture width used in the current configuration
2205 * It is the same as h_addressable of the current
2207 * The return is an integer: 0 or other positive integer
2208 * If 0 then DSC is disabled.
2210 * Access it with the following command:
2212 * cat /sys/kernel/debug/dri/0/DP-X/dsc_pic_width
2214 * 0 - means that DSC is disabled
2216 static ssize_t dp_dsc_pic_width_read(struct file *f, char __user *buf,
2217 size_t size, loff_t *pos)
2219 char *rd_buf = NULL;
2220 char *rd_buf_ptr = NULL;
2221 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
2222 struct display_stream_compressor *dsc;
2223 struct dcn_dsc_state dsc_state = {0};
2224 const uint32_t rd_buf_size = 100;
2225 struct pipe_ctx *pipe_ctx;
2227 int i, r, str_len = 30;
2229 rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
2234 rd_buf_ptr = rd_buf;
2236 for (i = 0; i < MAX_PIPES; i++) {
2237 pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
2238 if (pipe_ctx->stream &&
2239 pipe_ctx->stream->link == aconnector->dc_link &&
2240 pipe_ctx->stream->sink &&
2241 pipe_ctx->stream->sink == aconnector->dc_sink)
2245 dsc = pipe_ctx->stream_res.dsc;
2247 dsc->funcs->dsc_read_state(dsc, &dsc_state);
2249 snprintf(rd_buf_ptr, str_len,
2251 dsc_state.dsc_pic_width);
2252 rd_buf_ptr += str_len;
2255 if (*pos >= rd_buf_size)
2258 r = put_user(*(rd_buf + result), buf);
2261 return r; /* r = -EFAULT */
2274 static ssize_t dp_dsc_pic_height_read(struct file *f, char __user *buf,
2275 size_t size, loff_t *pos)
2277 char *rd_buf = NULL;
2278 char *rd_buf_ptr = NULL;
2279 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
2280 struct display_stream_compressor *dsc;
2281 struct dcn_dsc_state dsc_state = {0};
2282 const uint32_t rd_buf_size = 100;
2283 struct pipe_ctx *pipe_ctx;
2285 int i, r, str_len = 30;
2287 rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
2292 rd_buf_ptr = rd_buf;
2294 for (i = 0; i < MAX_PIPES; i++) {
2295 pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
2296 if (pipe_ctx->stream &&
2297 pipe_ctx->stream->link == aconnector->dc_link &&
2298 pipe_ctx->stream->sink &&
2299 pipe_ctx->stream->sink == aconnector->dc_sink)
2303 dsc = pipe_ctx->stream_res.dsc;
2305 dsc->funcs->dsc_read_state(dsc, &dsc_state);
2307 snprintf(rd_buf_ptr, str_len,
2309 dsc_state.dsc_pic_height);
2310 rd_buf_ptr += str_len;
2313 if (*pos >= rd_buf_size)
2316 r = put_user(*(rd_buf + result), buf);
2319 return r; /* r = -EFAULT */
2332 /* function: read DSC chunk size parameter on the connector
2334 * The read function: dp_dsc_chunk_size_read
2335 * returns dsc chunk size set in the current configuration
2336 * The value is calculated automatically by DSC code
2337 * and depends on slice parameters and bpp target rate
2338 * The return is an integer: 0 or other positive integer
2339 * If 0 then DSC is disabled.
2341 * Access it with the following command:
2343 * cat /sys/kernel/debug/dri/0/DP-X/dsc_chunk_size
2345 * 0 - means that DSC is disabled
2347 static ssize_t dp_dsc_chunk_size_read(struct file *f, char __user *buf,
2348 size_t size, loff_t *pos)
2350 char *rd_buf = NULL;
2351 char *rd_buf_ptr = NULL;
2352 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
2353 struct display_stream_compressor *dsc;
2354 struct dcn_dsc_state dsc_state = {0};
2355 const uint32_t rd_buf_size = 100;
2356 struct pipe_ctx *pipe_ctx;
2358 int i, r, str_len = 30;
2360 rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
2365 rd_buf_ptr = rd_buf;
2367 for (i = 0; i < MAX_PIPES; i++) {
2368 pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
2369 if (pipe_ctx->stream &&
2370 pipe_ctx->stream->link == aconnector->dc_link &&
2371 pipe_ctx->stream->sink &&
2372 pipe_ctx->stream->sink == aconnector->dc_sink)
2376 dsc = pipe_ctx->stream_res.dsc;
2378 dsc->funcs->dsc_read_state(dsc, &dsc_state);
2380 snprintf(rd_buf_ptr, str_len,
2382 dsc_state.dsc_chunk_size);
2383 rd_buf_ptr += str_len;
2386 if (*pos >= rd_buf_size)
2389 r = put_user(*(rd_buf + result), buf);
2392 return r; /* r = -EFAULT */
2405 /* function: read DSC slice bpg offset on the connector
2407 * The read function: dp_dsc_slice_bpg_offset_read
2408 * returns dsc bpg slice offset set in the current configuration
2409 * The value is calculated automatically by DSC code
2410 * and depends on slice parameters and bpp target rate
2411 * The return is an integer: 0 or other positive integer
2412 * If 0 then DSC is disabled.
2414 * Access it with the following command:
2416 * cat /sys/kernel/debug/dri/0/DP-X/dsc_slice_bpg_offset
2418 * 0 - means that DSC is disabled
2420 static ssize_t dp_dsc_slice_bpg_offset_read(struct file *f, char __user *buf,
2421 size_t size, loff_t *pos)
2423 char *rd_buf = NULL;
2424 char *rd_buf_ptr = NULL;
2425 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
2426 struct display_stream_compressor *dsc;
2427 struct dcn_dsc_state dsc_state = {0};
2428 const uint32_t rd_buf_size = 100;
2429 struct pipe_ctx *pipe_ctx;
2431 int i, r, str_len = 30;
2433 rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
2438 rd_buf_ptr = rd_buf;
2440 for (i = 0; i < MAX_PIPES; i++) {
2441 pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
2442 if (pipe_ctx->stream &&
2443 pipe_ctx->stream->link == aconnector->dc_link &&
2444 pipe_ctx->stream->sink &&
2445 pipe_ctx->stream->sink == aconnector->dc_sink)
2449 dsc = pipe_ctx->stream_res.dsc;
2451 dsc->funcs->dsc_read_state(dsc, &dsc_state);
2453 snprintf(rd_buf_ptr, str_len,
2455 dsc_state.dsc_slice_bpg_offset);
2456 rd_buf_ptr += str_len;
2459 if (*pos >= rd_buf_size)
2462 r = put_user(*(rd_buf + result), buf);
2465 return r; /* r = -EFAULT */
2480 * function description: Read max_requested_bpc property from the connector
2482 * Access it with the following command:
2484 * cat /sys/kernel/debug/dri/0/DP-X/max_bpc
2487 static ssize_t dp_max_bpc_read(struct file *f, char __user *buf,
2488 size_t size, loff_t *pos)
2490 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
2491 struct drm_connector *connector = &aconnector->base;
2492 struct drm_device *dev = connector->dev;
2493 struct dm_connector_state *state;
2495 char *rd_buf = NULL;
2496 char *rd_buf_ptr = NULL;
2497 const uint32_t rd_buf_size = 10;
2500 rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
2505 mutex_lock(&dev->mode_config.mutex);
2506 drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
2508 if (connector->state == NULL)
2511 state = to_dm_connector_state(connector->state);
2513 rd_buf_ptr = rd_buf;
2514 snprintf(rd_buf_ptr, rd_buf_size,
2516 state->base.max_requested_bpc);
2519 if (*pos >= rd_buf_size)
2522 r = put_user(*(rd_buf + result), buf);
2524 result = r; /* r = -EFAULT */
2533 drm_modeset_unlock(&dev->mode_config.connection_mutex);
2534 mutex_unlock(&dev->mode_config.mutex);
2541 * function description: Set max_requested_bpc property on the connector
2543 * This function will not force the input BPC on connector, it will only
2544 * change the max value. This is equivalent to setting max_bpc through
2547 * The BPC value written must be >= 6 and <= 16. Values outside of this
2548 * range will result in errors.
2557 * Write the max_bpc in the following way:
2559 * echo 0x6 > /sys/kernel/debug/dri/0/DP-X/max_bpc
2562 static ssize_t dp_max_bpc_write(struct file *f, const char __user *buf,
2563 size_t size, loff_t *pos)
2565 struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
2566 struct drm_connector *connector = &aconnector->base;
2567 struct dm_connector_state *state;
2568 struct drm_device *dev = connector->dev;
2569 char *wr_buf = NULL;
2570 uint32_t wr_buf_size = 42;
2571 int max_param_num = 1;
2572 long param[1] = {0};
2573 uint8_t param_nums = 0;
2578 wr_buf = kcalloc(wr_buf_size, sizeof(char), GFP_KERNEL);
2581 DRM_DEBUG_DRIVER("no memory to allocate write buffer\n");
2585 if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
2593 if (param_nums <= 0) {
2594 DRM_DEBUG_DRIVER("user data not be read\n");
2599 if (param[0] < 6 || param[0] > 16) {
2600 DRM_DEBUG_DRIVER("bad max_bpc value\n");
2605 mutex_lock(&dev->mode_config.mutex);
2606 drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
2608 if (connector->state == NULL)
2611 state = to_dm_connector_state(connector->state);
2612 state->base.max_requested_bpc = param[0];
2614 drm_modeset_unlock(&dev->mode_config.connection_mutex);
2615 mutex_unlock(&dev->mode_config.mutex);
2622 * Backlight at this moment. Read only.
2623 * As written to display, taking ABM and backlight lut into account.
2624 * Ranges from 0x0 to 0x10000 (= 100% PWM)
2626 * Example usage: cat /sys/kernel/debug/dri/0/eDP-1/current_backlight
2628 static int current_backlight_show(struct seq_file *m, void *unused)
2630 struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(m->private);
2631 struct dc_link *link = aconnector->dc_link;
2632 unsigned int backlight;
2634 backlight = dc_link_get_backlight_level(link);
2635 seq_printf(m, "0x%x\n", backlight);
2641 * Backlight value that is being approached. Read only.
2642 * As written to display, taking ABM and backlight lut into account.
2643 * Ranges from 0x0 to 0x10000 (= 100% PWM)
2645 * Example usage: cat /sys/kernel/debug/dri/0/eDP-1/target_backlight
2647 static int target_backlight_show(struct seq_file *m, void *unused)
2649 struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(m->private);
2650 struct dc_link *link = aconnector->dc_link;
2651 unsigned int backlight;
2653 backlight = dc_link_get_target_backlight_pwm(link);
2654 seq_printf(m, "0x%x\n", backlight);
2660 * function description: Determine if the connector is mst connector
2662 * This function helps to determine whether a connector is a mst connector.
2663 * - "root" stands for the root connector of the topology
2664 * - "branch" stands for branch device of the topology
2665 * - "end" stands for leaf node connector of the topology
2666 * - "no" stands for the connector is not a device of a mst topology
2667 * Access it with the following command:
2669 * cat /sys/kernel/debug/dri/0/DP-X/is_mst_connector
2672 static int dp_is_mst_connector_show(struct seq_file *m, void *unused)
2674 struct drm_connector *connector = m->private;
2675 struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);
2676 struct drm_dp_mst_topology_mgr *mgr = NULL;
2677 struct drm_dp_mst_port *port = NULL;
2680 mutex_lock(&aconnector->hpd_lock);
2682 if (aconnector->mst_mgr.mst_state) {
2684 } else if (aconnector->mst_root &&
2685 aconnector->mst_root->mst_mgr.mst_state) {
2689 mgr = &aconnector->mst_root->mst_mgr;
2690 port = aconnector->mst_output_port;
2692 drm_modeset_lock(&mgr->base.lock, NULL);
2693 if (port->pdt == DP_PEER_DEVICE_MST_BRANCHING &&
2696 drm_modeset_unlock(&mgr->base.lock);
2702 seq_printf(m, "%s\n", role);
2704 mutex_unlock(&aconnector->hpd_lock);
2710 * function description: Read out the mst progress status
2712 * This function helps to determine the mst progress status of
2715 * Access it with the following command:
2717 * cat /sys/kernel/debug/dri/0/DP-X/mst_progress_status
2720 static int dp_mst_progress_status_show(struct seq_file *m, void *unused)
2722 struct drm_connector *connector = m->private;
2723 struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);
2724 struct amdgpu_device *adev = drm_to_adev(connector->dev);
2727 mutex_lock(&aconnector->hpd_lock);
2728 mutex_lock(&adev->dm.dc_lock);
2730 if (aconnector->mst_status == MST_STATUS_DEFAULT) {
2731 seq_puts(m, "disabled\n");
2733 for (i = 0; i < sizeof(mst_progress_status)/sizeof(char *); i++)
2734 seq_printf(m, "%s:%s\n",
2735 mst_progress_status[i],
2736 aconnector->mst_status & BIT(i) ? "done" : "not_done");
2739 mutex_unlock(&adev->dm.dc_lock);
2740 mutex_unlock(&aconnector->hpd_lock);
2746 * Reports whether the connected display is a USB4 DPIA tunneled display
2747 * Example usage: cat /sys/kernel/debug/dri/0/DP-8/is_dpia_link
2749 static int is_dpia_link_show(struct seq_file *m, void *data)
2751 struct drm_connector *connector = m->private;
2752 struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);
2753 struct dc_link *link = aconnector->dc_link;
2755 if (connector->status != connector_status_connected)
2758 seq_printf(m, "%s\n", (link->ep_type == DISPLAY_ENDPOINT_USB4_DPIA) ? "yes" :
2759 (link->ep_type == DISPLAY_ENDPOINT_PHY) ? "no" : "unknown");
2764 DEFINE_SHOW_ATTRIBUTE(dp_dsc_fec_support);
2765 DEFINE_SHOW_ATTRIBUTE(dmub_fw_state);
2766 DEFINE_SHOW_ATTRIBUTE(dmub_tracebuffer);
2767 DEFINE_SHOW_ATTRIBUTE(dp_lttpr_status);
2768 DEFINE_SHOW_ATTRIBUTE(hdcp_sink_capability);
2769 DEFINE_SHOW_ATTRIBUTE(internal_display);
2770 DEFINE_SHOW_ATTRIBUTE(odm_combine_segments);
2771 DEFINE_SHOW_ATTRIBUTE(psr_capability);
2772 DEFINE_SHOW_ATTRIBUTE(dp_is_mst_connector);
2773 DEFINE_SHOW_ATTRIBUTE(dp_mst_progress_status);
2774 DEFINE_SHOW_ATTRIBUTE(is_dpia_link);
2776 static const struct file_operations dp_dsc_clock_en_debugfs_fops = {
2777 .owner = THIS_MODULE,
2778 .read = dp_dsc_clock_en_read,
2779 .write = dp_dsc_clock_en_write,
2780 .llseek = default_llseek
2783 static const struct file_operations dp_dsc_slice_width_debugfs_fops = {
2784 .owner = THIS_MODULE,
2785 .read = dp_dsc_slice_width_read,
2786 .write = dp_dsc_slice_width_write,
2787 .llseek = default_llseek
2790 static const struct file_operations dp_dsc_slice_height_debugfs_fops = {
2791 .owner = THIS_MODULE,
2792 .read = dp_dsc_slice_height_read,
2793 .write = dp_dsc_slice_height_write,
2794 .llseek = default_llseek
2797 static const struct file_operations dp_dsc_bits_per_pixel_debugfs_fops = {
2798 .owner = THIS_MODULE,
2799 .read = dp_dsc_bits_per_pixel_read,
2800 .write = dp_dsc_bits_per_pixel_write,
2801 .llseek = default_llseek
2804 static const struct file_operations dp_dsc_pic_width_debugfs_fops = {
2805 .owner = THIS_MODULE,
2806 .read = dp_dsc_pic_width_read,
2807 .llseek = default_llseek
2810 static const struct file_operations dp_dsc_pic_height_debugfs_fops = {
2811 .owner = THIS_MODULE,
2812 .read = dp_dsc_pic_height_read,
2813 .llseek = default_llseek
2816 static const struct file_operations dp_dsc_chunk_size_debugfs_fops = {
2817 .owner = THIS_MODULE,
2818 .read = dp_dsc_chunk_size_read,
2819 .llseek = default_llseek
2822 static const struct file_operations dp_dsc_slice_bpg_offset_debugfs_fops = {
2823 .owner = THIS_MODULE,
2824 .read = dp_dsc_slice_bpg_offset_read,
2825 .llseek = default_llseek
2828 static const struct file_operations trigger_hotplug_debugfs_fops = {
2829 .owner = THIS_MODULE,
2830 .write = trigger_hotplug,
2831 .llseek = default_llseek
2834 static const struct file_operations dp_link_settings_debugfs_fops = {
2835 .owner = THIS_MODULE,
2836 .read = dp_link_settings_read,
2837 .write = dp_link_settings_write,
2838 .llseek = default_llseek
2841 static const struct file_operations dp_phy_settings_debugfs_fop = {
2842 .owner = THIS_MODULE,
2843 .read = dp_phy_settings_read,
2844 .write = dp_phy_settings_write,
2845 .llseek = default_llseek
2848 static const struct file_operations dp_phy_test_pattern_fops = {
2849 .owner = THIS_MODULE,
2850 .write = dp_phy_test_pattern_debugfs_write,
2851 .llseek = default_llseek
2854 static const struct file_operations sdp_message_fops = {
2855 .owner = THIS_MODULE,
2856 .write = dp_sdp_message_debugfs_write,
2857 .llseek = default_llseek
2860 static const struct file_operations dp_max_bpc_debugfs_fops = {
2861 .owner = THIS_MODULE,
2862 .read = dp_max_bpc_read,
2863 .write = dp_max_bpc_write,
2864 .llseek = default_llseek
2867 static const struct file_operations dp_dsc_disable_passthrough_debugfs_fops = {
2868 .owner = THIS_MODULE,
2869 .write = dp_dsc_passthrough_set,
2870 .llseek = default_llseek
2873 static const struct file_operations dp_mst_link_settings_debugfs_fops = {
2874 .owner = THIS_MODULE,
2875 .write = dp_mst_link_setting,
2876 .llseek = default_llseek
2879 static const struct {
2881 const struct file_operations *fops;
2882 } dp_debugfs_entries[] = {
2883 {"link_settings", &dp_link_settings_debugfs_fops},
2884 {"phy_settings", &dp_phy_settings_debugfs_fop},
2885 {"lttpr_status", &dp_lttpr_status_fops},
2886 {"test_pattern", &dp_phy_test_pattern_fops},
2887 {"hdcp_sink_capability", &hdcp_sink_capability_fops},
2888 {"sdp_message", &sdp_message_fops},
2889 {"dsc_clock_en", &dp_dsc_clock_en_debugfs_fops},
2890 {"dsc_slice_width", &dp_dsc_slice_width_debugfs_fops},
2891 {"dsc_slice_height", &dp_dsc_slice_height_debugfs_fops},
2892 {"dsc_bits_per_pixel", &dp_dsc_bits_per_pixel_debugfs_fops},
2893 {"dsc_pic_width", &dp_dsc_pic_width_debugfs_fops},
2894 {"dsc_pic_height", &dp_dsc_pic_height_debugfs_fops},
2895 {"dsc_chunk_size", &dp_dsc_chunk_size_debugfs_fops},
2896 {"dsc_slice_bpg", &dp_dsc_slice_bpg_offset_debugfs_fops},
2897 {"dp_dsc_fec_support", &dp_dsc_fec_support_fops},
2898 {"max_bpc", &dp_max_bpc_debugfs_fops},
2899 {"dsc_disable_passthrough", &dp_dsc_disable_passthrough_debugfs_fops},
2900 {"is_mst_connector", &dp_is_mst_connector_fops},
2901 {"mst_progress_status", &dp_mst_progress_status_fops},
2902 {"is_dpia_link", &is_dpia_link_fops},
2903 {"mst_link_settings", &dp_mst_link_settings_debugfs_fops}
2906 static const struct {
2908 const struct file_operations *fops;
2909 } hdmi_debugfs_entries[] = {
2910 {"hdcp_sink_capability", &hdcp_sink_capability_fops}
2914 * Force YUV420 output if available from the given mode
2916 static int force_yuv420_output_set(void *data, u64 val)
2918 struct amdgpu_dm_connector *connector = data;
2920 connector->force_yuv420_output = (bool)val;
2926 * Check if YUV420 is forced when available from the given mode
2928 static int force_yuv420_output_get(void *data, u64 *val)
2930 struct amdgpu_dm_connector *connector = data;
2932 *val = connector->force_yuv420_output;
2937 DEFINE_DEBUGFS_ATTRIBUTE(force_yuv420_output_fops, force_yuv420_output_get,
2938 force_yuv420_output_set, "%llu\n");
2943 static int psr_get(void *data, u64 *val)
2945 struct amdgpu_dm_connector *connector = data;
2946 struct dc_link *link = connector->dc_link;
2947 enum dc_psr_state state = PSR_STATE0;
2949 dc_link_get_psr_state(link, &state);
2957 * Read PSR state residency
2959 static int psr_read_residency(void *data, u64 *val)
2961 struct amdgpu_dm_connector *connector = data;
2962 struct dc_link *link = connector->dc_link;
2965 link->dc->link_srv->edp_get_psr_residency(link, &residency);
2967 *val = (u64)residency;
2972 /* read allow_edp_hotplug_detection */
2973 static int allow_edp_hotplug_detection_get(void *data, u64 *val)
2975 struct amdgpu_dm_connector *aconnector = data;
2976 struct drm_connector *connector = &aconnector->base;
2977 struct drm_device *dev = connector->dev;
2978 struct amdgpu_device *adev = drm_to_adev(dev);
2980 *val = adev->dm.dc->config.allow_edp_hotplug_detection;
2985 /* set allow_edp_hotplug_detection */
2986 static int allow_edp_hotplug_detection_set(void *data, u64 val)
2988 struct amdgpu_dm_connector *aconnector = data;
2989 struct drm_connector *connector = &aconnector->base;
2990 struct drm_device *dev = connector->dev;
2991 struct amdgpu_device *adev = drm_to_adev(dev);
2993 adev->dm.dc->config.allow_edp_hotplug_detection = (uint32_t) val;
2998 /* check if kernel disallow eDP enter psr state
2999 * cat /sys/kernel/debug/dri/0/eDP-X/disallow_edp_enter_psr
3000 * 0: allow edp enter psr; 1: disallow
3002 static int disallow_edp_enter_psr_get(void *data, u64 *val)
3004 struct amdgpu_dm_connector *aconnector = data;
3006 *val = (u64) aconnector->disallow_edp_enter_psr;
3010 /* set kernel disallow eDP enter psr state
3011 * echo 0x0 /sys/kernel/debug/dri/0/eDP-X/disallow_edp_enter_psr
3012 * 0: allow edp enter psr; 1: disallow
3014 * usage: test app read crc from PSR eDP rx.
3016 * during kernel boot up, kernel write dpcd 0x170 = 5.
3017 * this notify eDP rx psr enable and let rx check crc.
3018 * rx fw will start checking crc for rx internal logic.
3019 * crc read count within dpcd 0x246 is not updated and
3020 * value is 0. when eDP tx driver wants to read rx crc
3021 * from dpcd 0x246, 0x270, read count 0 lead tx driver
3024 * to avoid this, we add this debugfs to let test app to disbable
3025 * rx crc checking for rx internal logic. then test app can read
3026 * non-zero crc read count.
3028 * expected app sequence is as below:
3029 * 1. disable eDP PHY and notify eDP rx with dpcd 0x600 = 2.
3030 * 2. echo 0x1 /sys/kernel/debug/dri/0/eDP-X/disallow_edp_enter_psr
3031 * 3. enable eDP PHY and notify eDP rx with dpcd 0x600 = 1 but
3032 * without dpcd 0x170 = 5.
3033 * 4. read crc from rx dpcd 0x270, 0x246, etc.
3034 * 5. echo 0x0 /sys/kernel/debug/dri/0/eDP-X/disallow_edp_enter_psr.
3035 * this will let eDP back to normal with psr setup dpcd 0x170 = 5.
3037 static int disallow_edp_enter_psr_set(void *data, u64 val)
3039 struct amdgpu_dm_connector *aconnector = data;
3041 aconnector->disallow_edp_enter_psr = val ? true : false;
3045 static int dmub_trace_mask_set(void *data, u64 val)
3047 struct amdgpu_device *adev = data;
3048 struct dmub_srv *srv = adev->dm.dc->ctx->dmub_srv->dmub;
3049 enum dmub_gpint_command cmd;
3055 if (!srv->fw_version)
3058 for (i = 0; i < 4; i++) {
3059 res = (val & mask) >> shift;
3063 cmd = DMUB_GPINT__SET_TRACE_BUFFER_MASK_WORD0;
3066 cmd = DMUB_GPINT__SET_TRACE_BUFFER_MASK_WORD1;
3069 cmd = DMUB_GPINT__SET_TRACE_BUFFER_MASK_WORD2;
3072 cmd = DMUB_GPINT__SET_TRACE_BUFFER_MASK_WORD3;
3076 if (!dc_wake_and_execute_gpint(adev->dm.dc->ctx, cmd, res, NULL, DM_DMUB_WAIT_TYPE_WAIT))
3079 usleep_range(100, 1000);
3088 static int dmub_trace_mask_show(void *data, u64 *val)
3090 enum dmub_gpint_command cmd = DMUB_GPINT__GET_TRACE_BUFFER_MASK_WORD0;
3091 struct amdgpu_device *adev = data;
3092 struct dmub_srv *srv = adev->dm.dc->ctx->dmub_srv->dmub;
3098 if (!srv->fw_version)
3104 if (!dc_wake_and_execute_gpint(adev->dm.dc->ctx, cmd, 0, &response, DM_DMUB_WAIT_TYPE_WAIT_WITH_REPLY))
3108 usleep_range(100, 1000);
3111 res |= (raw << shift);
3121 DEFINE_DEBUGFS_ATTRIBUTE(dmub_trace_mask_fops, dmub_trace_mask_show,
3122 dmub_trace_mask_set, "0x%llx\n");
3125 * Set dmcub trace event IRQ enable or disable.
3126 * Usage to enable dmcub trace event IRQ: echo 1 > /sys/kernel/debug/dri/0/amdgpu_dm_dmcub_trace_event_en
3127 * Usage to disable dmcub trace event IRQ: echo 0 > /sys/kernel/debug/dri/0/amdgpu_dm_dmcub_trace_event_en
3129 static int dmcub_trace_event_state_set(void *data, u64 val)
3131 struct amdgpu_device *adev = data;
3133 if (val == 1 || val == 0) {
3134 dc_dmub_trace_event_control(adev->dm.dc, val);
3135 adev->dm.dmcub_trace_event_en = (bool)val;
3143 * The interface doesn't need get function, so it will return the
3145 * Usage: cat /sys/kernel/debug/dri/0/amdgpu_dm_dmcub_trace_event_en
3147 static int dmcub_trace_event_state_get(void *data, u64 *val)
3149 struct amdgpu_device *adev = data;
3151 *val = adev->dm.dmcub_trace_event_en;
3155 DEFINE_DEBUGFS_ATTRIBUTE(dmcub_trace_event_state_fops, dmcub_trace_event_state_get,
3156 dmcub_trace_event_state_set, "%llu\n");
3158 DEFINE_DEBUGFS_ATTRIBUTE(psr_fops, psr_get, NULL, "%llu\n");
3159 DEFINE_DEBUGFS_ATTRIBUTE(psr_residency_fops, psr_read_residency, NULL,
3162 DEFINE_DEBUGFS_ATTRIBUTE(allow_edp_hotplug_detection_fops,
3163 allow_edp_hotplug_detection_get,
3164 allow_edp_hotplug_detection_set, "%llu\n");
3166 DEFINE_DEBUGFS_ATTRIBUTE(disallow_edp_enter_psr_fops,
3167 disallow_edp_enter_psr_get,
3168 disallow_edp_enter_psr_set, "%llu\n");
3170 DEFINE_SHOW_ATTRIBUTE(current_backlight);
3171 DEFINE_SHOW_ATTRIBUTE(target_backlight);
3173 static const struct {
3175 const struct file_operations *fops;
3176 } connector_debugfs_entries[] = {
3177 {"force_yuv420_output", &force_yuv420_output_fops},
3178 {"trigger_hotplug", &trigger_hotplug_debugfs_fops},
3179 {"internal_display", &internal_display_fops},
3180 {"odm_combine_segments", &odm_combine_segments_fops}
3184 * Returns supported customized link rates by this eDP panel.
3185 * Example usage: cat /sys/kernel/debug/dri/0/eDP-x/ilr_setting
3187 static int edp_ilr_show(struct seq_file *m, void *unused)
3189 struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(m->private);
3190 struct dc_link *link = aconnector->dc_link;
3191 uint8_t supported_link_rates[16];
3192 uint32_t link_rate_in_khz;
3196 memset(supported_link_rates, 0, sizeof(supported_link_rates));
3197 dm_helpers_dp_read_dpcd(link->ctx, link, DP_SUPPORTED_LINK_RATES,
3198 supported_link_rates, sizeof(supported_link_rates));
3200 dpcd_rev = link->dpcd_caps.dpcd_rev.raw;
3202 if (dpcd_rev >= DP_DPCD_REV_13 &&
3203 (supported_link_rates[entry+1] != 0 || supported_link_rates[entry] != 0)) {
3205 for (entry = 0; entry < 16; entry += 2) {
3206 link_rate_in_khz = (supported_link_rates[entry+1] * 0x100 +
3207 supported_link_rates[entry]) * 200;
3208 seq_printf(m, "[%d] %d kHz\n", entry/2, link_rate_in_khz);
3211 seq_puts(m, "ILR is not supported by this eDP panel.\n");
3218 * Set supported customized link rate to eDP panel.
3220 * echo <lane_count> <link_rate option> > ilr_setting
3222 * for example, supported ILR : [0] 1620000 kHz [1] 2160000 kHz [2] 2430000 kHz ...
3223 * echo 4 1 > /sys/kernel/debug/dri/0/eDP-x/ilr_setting
3224 * to set 4 lanes and 2.16 GHz
3226 static ssize_t edp_ilr_write(struct file *f, const char __user *buf,
3227 size_t size, loff_t *pos)
3229 struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
3230 struct dc_link *link = connector->dc_link;
3231 struct amdgpu_device *adev = drm_to_adev(connector->base.dev);
3232 struct dc *dc = (struct dc *)link->dc;
3233 struct dc_link_settings prefer_link_settings;
3234 char *wr_buf = NULL;
3235 const uint32_t wr_buf_size = 40;
3236 /* 0: lane_count; 1: link_rate */
3237 int max_param_num = 2;
3238 uint8_t param_nums = 0;
3240 bool valid_input = true;
3245 wr_buf = kcalloc(wr_buf_size, sizeof(char), GFP_KERNEL);
3249 if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
3257 if (param_nums <= 0) {
3263 case LANE_COUNT_ONE:
3264 case LANE_COUNT_TWO:
3265 case LANE_COUNT_FOUR:
3268 valid_input = false;
3272 if (param[1] >= link->dpcd_caps.edp_supported_link_rates_count)
3273 valid_input = false;
3277 DRM_DEBUG_DRIVER("Invalid Input value. No HW will be programmed\n");
3278 prefer_link_settings.use_link_rate_set = false;
3279 mutex_lock(&adev->dm.dc_lock);
3280 dc_link_set_preferred_training_settings(dc, NULL, NULL, link, false);
3281 mutex_unlock(&adev->dm.dc_lock);
3285 /* save user force lane_count, link_rate to preferred settings
3286 * spread spectrum will not be changed
3288 prefer_link_settings.link_spread = link->cur_link_settings.link_spread;
3289 prefer_link_settings.lane_count = param[0];
3290 prefer_link_settings.use_link_rate_set = true;
3291 prefer_link_settings.link_rate_set = param[1];
3292 prefer_link_settings.link_rate = link->dpcd_caps.edp_supported_link_rates[param[1]];
3294 mutex_lock(&adev->dm.dc_lock);
3295 dc_link_set_preferred_training_settings(dc, &prefer_link_settings,
3297 mutex_unlock(&adev->dm.dc_lock);
3303 static int edp_ilr_open(struct inode *inode, struct file *file)
3305 return single_open(file, edp_ilr_show, inode->i_private);
3308 static const struct file_operations edp_ilr_debugfs_fops = {
3309 .owner = THIS_MODULE,
3310 .open = edp_ilr_open,
3312 .llseek = seq_lseek,
3313 .release = single_release,
3314 .write = edp_ilr_write
3317 void connector_debugfs_init(struct amdgpu_dm_connector *connector)
3320 struct dentry *dir = connector->base.debugfs_entry;
3322 if (connector->base.connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
3323 connector->base.connector_type == DRM_MODE_CONNECTOR_eDP) {
3324 for (i = 0; i < ARRAY_SIZE(dp_debugfs_entries); i++) {
3325 debugfs_create_file(dp_debugfs_entries[i].name,
3326 0644, dir, connector,
3327 dp_debugfs_entries[i].fops);
3330 if (connector->base.connector_type == DRM_MODE_CONNECTOR_eDP) {
3331 debugfs_create_file_unsafe("psr_capability", 0444, dir, connector, &psr_capability_fops);
3332 debugfs_create_file_unsafe("psr_state", 0444, dir, connector, &psr_fops);
3333 debugfs_create_file_unsafe("psr_residency", 0444, dir,
3334 connector, &psr_residency_fops);
3335 debugfs_create_file("amdgpu_current_backlight_pwm", 0444, dir, connector,
3336 ¤t_backlight_fops);
3337 debugfs_create_file("amdgpu_target_backlight_pwm", 0444, dir, connector,
3338 &target_backlight_fops);
3339 debugfs_create_file("ilr_setting", 0644, dir, connector,
3340 &edp_ilr_debugfs_fops);
3341 debugfs_create_file("allow_edp_hotplug_detection", 0644, dir, connector,
3342 &allow_edp_hotplug_detection_fops);
3343 debugfs_create_file("disallow_edp_enter_psr", 0644, dir, connector,
3344 &disallow_edp_enter_psr_fops);
3347 for (i = 0; i < ARRAY_SIZE(connector_debugfs_entries); i++) {
3348 debugfs_create_file(connector_debugfs_entries[i].name,
3349 0644, dir, connector,
3350 connector_debugfs_entries[i].fops);
3353 if (connector->base.connector_type == DRM_MODE_CONNECTOR_HDMIA) {
3354 for (i = 0; i < ARRAY_SIZE(hdmi_debugfs_entries); i++) {
3355 debugfs_create_file(hdmi_debugfs_entries[i].name,
3356 0644, dir, connector,
3357 hdmi_debugfs_entries[i].fops);
3362 #ifdef CONFIG_DRM_AMD_SECURE_DISPLAY
3364 * Set crc window coordinate x start
3366 static int crc_win_x_start_set(void *data, u64 val)
3368 struct drm_crtc *crtc = data;
3369 struct drm_device *drm_dev = crtc->dev;
3370 struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
3372 spin_lock_irq(&drm_dev->event_lock);
3373 acrtc->dm_irq_params.window_param.x_start = (uint16_t) val;
3374 acrtc->dm_irq_params.window_param.update_win = false;
3375 spin_unlock_irq(&drm_dev->event_lock);
3381 * Get crc window coordinate x start
3383 static int crc_win_x_start_get(void *data, u64 *val)
3385 struct drm_crtc *crtc = data;
3386 struct drm_device *drm_dev = crtc->dev;
3387 struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
3389 spin_lock_irq(&drm_dev->event_lock);
3390 *val = acrtc->dm_irq_params.window_param.x_start;
3391 spin_unlock_irq(&drm_dev->event_lock);
3396 DEFINE_DEBUGFS_ATTRIBUTE(crc_win_x_start_fops, crc_win_x_start_get,
3397 crc_win_x_start_set, "%llu\n");
3401 * Set crc window coordinate y start
3403 static int crc_win_y_start_set(void *data, u64 val)
3405 struct drm_crtc *crtc = data;
3406 struct drm_device *drm_dev = crtc->dev;
3407 struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
3409 spin_lock_irq(&drm_dev->event_lock);
3410 acrtc->dm_irq_params.window_param.y_start = (uint16_t) val;
3411 acrtc->dm_irq_params.window_param.update_win = false;
3412 spin_unlock_irq(&drm_dev->event_lock);
3418 * Get crc window coordinate y start
3420 static int crc_win_y_start_get(void *data, u64 *val)
3422 struct drm_crtc *crtc = data;
3423 struct drm_device *drm_dev = crtc->dev;
3424 struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
3426 spin_lock_irq(&drm_dev->event_lock);
3427 *val = acrtc->dm_irq_params.window_param.y_start;
3428 spin_unlock_irq(&drm_dev->event_lock);
3433 DEFINE_DEBUGFS_ATTRIBUTE(crc_win_y_start_fops, crc_win_y_start_get,
3434 crc_win_y_start_set, "%llu\n");
3437 * Set crc window coordinate x end
3439 static int crc_win_x_end_set(void *data, u64 val)
3441 struct drm_crtc *crtc = data;
3442 struct drm_device *drm_dev = crtc->dev;
3443 struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
3445 spin_lock_irq(&drm_dev->event_lock);
3446 acrtc->dm_irq_params.window_param.x_end = (uint16_t) val;
3447 acrtc->dm_irq_params.window_param.update_win = false;
3448 spin_unlock_irq(&drm_dev->event_lock);
3454 * Get crc window coordinate x end
3456 static int crc_win_x_end_get(void *data, u64 *val)
3458 struct drm_crtc *crtc = data;
3459 struct drm_device *drm_dev = crtc->dev;
3460 struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
3462 spin_lock_irq(&drm_dev->event_lock);
3463 *val = acrtc->dm_irq_params.window_param.x_end;
3464 spin_unlock_irq(&drm_dev->event_lock);
3469 DEFINE_DEBUGFS_ATTRIBUTE(crc_win_x_end_fops, crc_win_x_end_get,
3470 crc_win_x_end_set, "%llu\n");
3473 * Set crc window coordinate y end
3475 static int crc_win_y_end_set(void *data, u64 val)
3477 struct drm_crtc *crtc = data;
3478 struct drm_device *drm_dev = crtc->dev;
3479 struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
3481 spin_lock_irq(&drm_dev->event_lock);
3482 acrtc->dm_irq_params.window_param.y_end = (uint16_t) val;
3483 acrtc->dm_irq_params.window_param.update_win = false;
3484 spin_unlock_irq(&drm_dev->event_lock);
3490 * Get crc window coordinate y end
3492 static int crc_win_y_end_get(void *data, u64 *val)
3494 struct drm_crtc *crtc = data;
3495 struct drm_device *drm_dev = crtc->dev;
3496 struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
3498 spin_lock_irq(&drm_dev->event_lock);
3499 *val = acrtc->dm_irq_params.window_param.y_end;
3500 spin_unlock_irq(&drm_dev->event_lock);
3505 DEFINE_DEBUGFS_ATTRIBUTE(crc_win_y_end_fops, crc_win_y_end_get,
3506 crc_win_y_end_set, "%llu\n");
3508 * Trigger to commit crc window
3510 static int crc_win_update_set(void *data, u64 val)
3512 struct drm_crtc *crtc = data;
3513 struct amdgpu_crtc *acrtc;
3514 struct amdgpu_device *adev = drm_to_adev(crtc->dev);
3517 acrtc = to_amdgpu_crtc(crtc);
3518 mutex_lock(&adev->dm.dc_lock);
3519 /* PSR may write to OTG CRC window control register,
3520 * so close it before starting secure_display.
3522 amdgpu_dm_psr_disable(acrtc->dm_irq_params.stream);
3524 spin_lock_irq(&adev_to_drm(adev)->event_lock);
3526 acrtc->dm_irq_params.window_param.activated = true;
3527 acrtc->dm_irq_params.window_param.update_win = true;
3528 acrtc->dm_irq_params.window_param.skip_frame_cnt = 0;
3530 spin_unlock_irq(&adev_to_drm(adev)->event_lock);
3531 mutex_unlock(&adev->dm.dc_lock);
3538 * Get crc window update flag
3540 static int crc_win_update_get(void *data, u64 *val)
3546 DEFINE_DEBUGFS_ATTRIBUTE(crc_win_update_fops, crc_win_update_get,
3547 crc_win_update_set, "%llu\n");
3549 void crtc_debugfs_init(struct drm_crtc *crtc)
3551 #ifdef CONFIG_DRM_AMD_SECURE_DISPLAY
3552 struct dentry *dir = debugfs_lookup("crc", crtc->debugfs_entry);
3557 debugfs_create_file_unsafe("crc_win_x_start", 0644, dir, crtc,
3558 &crc_win_x_start_fops);
3559 debugfs_create_file_unsafe("crc_win_y_start", 0644, dir, crtc,
3560 &crc_win_y_start_fops);
3561 debugfs_create_file_unsafe("crc_win_x_end", 0644, dir, crtc,
3562 &crc_win_x_end_fops);
3563 debugfs_create_file_unsafe("crc_win_y_end", 0644, dir, crtc,
3564 &crc_win_y_end_fops);
3565 debugfs_create_file_unsafe("crc_win_update", 0644, dir, crtc,
3566 &crc_win_update_fops);
3569 debugfs_create_file("amdgpu_current_bpc", 0644, crtc->debugfs_entry,
3570 crtc, &amdgpu_current_bpc_fops);
3571 debugfs_create_file("amdgpu_current_colorspace", 0644, crtc->debugfs_entry,
3572 crtc, &amdgpu_current_colorspace_fops);
3576 * Writes DTN log state to the user supplied buffer.
3577 * Example usage: cat /sys/kernel/debug/dri/0/amdgpu_dm_dtn_log
3579 static ssize_t dtn_log_read(
3585 struct amdgpu_device *adev = file_inode(f)->i_private;
3586 struct dc *dc = adev->dm.dc;
3587 struct dc_log_buffer_ctx log_ctx = { 0 };
3593 if (!dc->hwss.log_hw_state)
3596 dc->hwss.log_hw_state(dc, &log_ctx);
3598 if (*pos < log_ctx.pos) {
3599 size_t to_copy = log_ctx.pos - *pos;
3601 to_copy = min(to_copy, size);
3603 if (!copy_to_user(buf, log_ctx.buf + *pos, to_copy)) {
3615 * Writes DTN log state to dmesg when triggered via a write.
3616 * Example usage: echo 1 > /sys/kernel/debug/dri/0/amdgpu_dm_dtn_log
3618 static ssize_t dtn_log_write(
3620 const char __user *buf,
3624 struct amdgpu_device *adev = file_inode(f)->i_private;
3625 struct dc *dc = adev->dm.dc;
3627 /* Write triggers log output via dmesg. */
3631 if (dc->hwss.log_hw_state)
3632 dc->hwss.log_hw_state(dc, NULL);
3637 static int mst_topo_show(struct seq_file *m, void *unused)
3639 struct amdgpu_device *adev = (struct amdgpu_device *)m->private;
3640 struct drm_device *dev = adev_to_drm(adev);
3641 struct drm_connector *connector;
3642 struct drm_connector_list_iter conn_iter;
3643 struct amdgpu_dm_connector *aconnector;
3645 drm_connector_list_iter_begin(dev, &conn_iter);
3646 drm_for_each_connector_iter(connector, &conn_iter) {
3647 if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort)
3650 aconnector = to_amdgpu_dm_connector(connector);
3652 /* Ensure we're only dumping the topology of a root mst node */
3653 if (!aconnector->mst_mgr.mst_state)
3656 seq_printf(m, "\nMST topology for connector %d\n", aconnector->connector_id);
3657 drm_dp_mst_dump_topology(m, &aconnector->mst_mgr);
3659 drm_connector_list_iter_end(&conn_iter);
3665 * Sets trigger hpd for MST topologies.
3666 * All connected connectors will be rediscovered and re started as needed if val of 1 is sent.
3667 * All topologies will be disconnected if val of 0 is set .
3668 * Usage to enable topologies: echo 1 > /sys/kernel/debug/dri/0/amdgpu_dm_trigger_hpd_mst
3669 * Usage to disable topologies: echo 0 > /sys/kernel/debug/dri/0/amdgpu_dm_trigger_hpd_mst
3671 static int trigger_hpd_mst_set(void *data, u64 val)
3673 struct amdgpu_device *adev = data;
3674 struct drm_device *dev = adev_to_drm(adev);
3675 struct drm_connector_list_iter iter;
3676 struct amdgpu_dm_connector *aconnector;
3677 struct drm_connector *connector;
3678 struct dc_link *link = NULL;
3681 drm_connector_list_iter_begin(dev, &iter);
3682 drm_for_each_connector_iter(connector, &iter) {
3683 aconnector = to_amdgpu_dm_connector(connector);
3684 if (aconnector->dc_link->type == dc_connection_mst_branch &&
3685 aconnector->mst_mgr.aux) {
3686 mutex_lock(&adev->dm.dc_lock);
3687 dc_link_detect(aconnector->dc_link, DETECT_REASON_HPD);
3688 mutex_unlock(&adev->dm.dc_lock);
3690 drm_dp_mst_topology_mgr_set_mst(&aconnector->mst_mgr, true);
3693 } else if (val == 0) {
3694 drm_connector_list_iter_begin(dev, &iter);
3695 drm_for_each_connector_iter(connector, &iter) {
3696 aconnector = to_amdgpu_dm_connector(connector);
3697 if (!aconnector->dc_link)
3700 if (!aconnector->mst_root)
3703 link = aconnector->dc_link;
3704 dc_link_dp_receiver_power_ctrl(link, false);
3705 drm_dp_mst_topology_mgr_set_mst(&aconnector->mst_root->mst_mgr, false);
3706 link->mst_stream_alloc_table.stream_count = 0;
3707 memset(link->mst_stream_alloc_table.stream_allocations, 0,
3708 sizeof(link->mst_stream_alloc_table.stream_allocations));
3713 drm_kms_helper_hotplug_event(dev);
3719 * The interface doesn't need get function, so it will return the
3721 * Usage: cat /sys/kernel/debug/dri/0/amdgpu_dm_trigger_hpd_mst
3723 static int trigger_hpd_mst_get(void *data, u64 *val)
3729 DEFINE_DEBUGFS_ATTRIBUTE(trigger_hpd_mst_ops, trigger_hpd_mst_get,
3730 trigger_hpd_mst_set, "%llu\n");
3734 * Sets the force_timing_sync debug option from the given string.
3735 * All connected displays will be force synchronized immediately.
3736 * Usage: echo 1 > /sys/kernel/debug/dri/0/amdgpu_dm_force_timing_sync
3738 static int force_timing_sync_set(void *data, u64 val)
3740 struct amdgpu_device *adev = data;
3742 adev->dm.force_timing_sync = (bool)val;
3744 amdgpu_dm_trigger_timing_sync(adev_to_drm(adev));
3750 * Gets the force_timing_sync debug option value into the given buffer.
3751 * Usage: cat /sys/kernel/debug/dri/0/amdgpu_dm_force_timing_sync
3753 static int force_timing_sync_get(void *data, u64 *val)
3755 struct amdgpu_device *adev = data;
3757 *val = adev->dm.force_timing_sync;
3762 DEFINE_DEBUGFS_ATTRIBUTE(force_timing_sync_ops, force_timing_sync_get,
3763 force_timing_sync_set, "%llu\n");
3767 * Disables all HPD and HPD RX interrupt handling in the
3768 * driver when set to 1. Default is 0.
3770 static int disable_hpd_set(void *data, u64 val)
3772 struct amdgpu_device *adev = data;
3774 adev->dm.disable_hpd_irq = (bool)val;
3781 * Returns 1 if HPD and HPRX interrupt handling is disabled,
3784 static int disable_hpd_get(void *data, u64 *val)
3786 struct amdgpu_device *adev = data;
3788 *val = adev->dm.disable_hpd_irq;
3793 DEFINE_DEBUGFS_ATTRIBUTE(disable_hpd_ops, disable_hpd_get,
3794 disable_hpd_set, "%llu\n");
3797 * Prints hardware capabilities. These are used for IGT testing.
3799 static int capabilities_show(struct seq_file *m, void *unused)
3801 struct amdgpu_device *adev = (struct amdgpu_device *)m->private;
3802 struct dc *dc = adev->dm.dc;
3803 bool mall_supported = dc->caps.mall_size_total;
3804 bool subvp_supported = dc->caps.subvp_fw_processing_delay_us;
3805 unsigned int mall_in_use = false;
3806 unsigned int subvp_in_use = false;
3808 struct hubbub *hubbub = dc->res_pool->hubbub;
3810 if (hubbub->funcs->get_mall_en)
3811 hubbub->funcs->get_mall_en(hubbub, &mall_in_use);
3813 if (dc->cap_funcs.get_subvp_en)
3814 subvp_in_use = dc->cap_funcs.get_subvp_en(dc, dc->current_state);
3816 seq_printf(m, "mall supported: %s, enabled: %s\n",
3817 mall_supported ? "yes" : "no", mall_in_use ? "yes" : "no");
3818 seq_printf(m, "sub-viewport supported: %s, enabled: %s\n",
3819 subvp_supported ? "yes" : "no", subvp_in_use ? "yes" : "no");
3824 DEFINE_SHOW_ATTRIBUTE(capabilities);
3827 * Temporary w/a to force sst sequence in M42D DP2 mst receiver
3828 * Example usage: echo 1 > /sys/kernel/debug/dri/0/amdgpu_dm_dp_set_mst_en_for_sst
3830 static int dp_force_sst_set(void *data, u64 val)
3832 struct amdgpu_device *adev = data;
3834 adev->dm.dc->debug.set_mst_en_for_sst = val;
3839 static int dp_force_sst_get(void *data, u64 *val)
3841 struct amdgpu_device *adev = data;
3843 *val = adev->dm.dc->debug.set_mst_en_for_sst;
3847 DEFINE_DEBUGFS_ATTRIBUTE(dp_set_mst_en_for_sst_ops, dp_force_sst_get,
3848 dp_force_sst_set, "%llu\n");
3851 * Force DP2 sequence without VESA certified cable.
3852 * Example usage: echo 1 > /sys/kernel/debug/dri/0/amdgpu_dm_dp_ignore_cable_id
3854 static int dp_ignore_cable_id_set(void *data, u64 val)
3856 struct amdgpu_device *adev = data;
3858 adev->dm.dc->debug.ignore_cable_id = val;
3863 static int dp_ignore_cable_id_get(void *data, u64 *val)
3865 struct amdgpu_device *adev = data;
3867 *val = adev->dm.dc->debug.ignore_cable_id;
3871 DEFINE_DEBUGFS_ATTRIBUTE(dp_ignore_cable_id_ops, dp_ignore_cable_id_get,
3872 dp_ignore_cable_id_set, "%llu\n");
3875 * Sets the DC visual confirm debug option from the given string.
3876 * Example usage: echo 1 > /sys/kernel/debug/dri/0/amdgpu_visual_confirm
3878 static int visual_confirm_set(void *data, u64 val)
3880 struct amdgpu_device *adev = data;
3882 adev->dm.dc->debug.visual_confirm = (enum visual_confirm)val;
3888 * Reads the DC visual confirm debug option value into the given buffer.
3889 * Example usage: cat /sys/kernel/debug/dri/0/amdgpu_dm_visual_confirm
3891 static int visual_confirm_get(void *data, u64 *val)
3893 struct amdgpu_device *adev = data;
3895 *val = adev->dm.dc->debug.visual_confirm;
3900 DEFINE_SHOW_ATTRIBUTE(mst_topo);
3901 DEFINE_DEBUGFS_ATTRIBUTE(visual_confirm_fops, visual_confirm_get,
3902 visual_confirm_set, "%llu\n");
3906 * Sets the DC skip_detection_link_training debug option from the given string.
3907 * Example usage: echo 1 > /sys/kernel/debug/dri/0/amdgpu_skip_detection_link_training
3909 static int skip_detection_link_training_set(void *data, u64 val)
3911 struct amdgpu_device *adev = data;
3914 adev->dm.dc->debug.skip_detection_link_training = false;
3916 adev->dm.dc->debug.skip_detection_link_training = true;
3922 * Reads the DC skip_detection_link_training debug option value into the given buffer.
3923 * Example usage: cat /sys/kernel/debug/dri/0/amdgpu_dm_skip_detection_link_training
3925 static int skip_detection_link_training_get(void *data, u64 *val)
3927 struct amdgpu_device *adev = data;
3929 *val = adev->dm.dc->debug.skip_detection_link_training;
3934 DEFINE_DEBUGFS_ATTRIBUTE(skip_detection_link_training_fops,
3935 skip_detection_link_training_get,
3936 skip_detection_link_training_set, "%llu\n");
3939 * Dumps the DCC_EN bit for each pipe.
3940 * Example usage: cat /sys/kernel/debug/dri/0/amdgpu_dm_dcc_en
3942 static ssize_t dcc_en_bits_read(
3948 struct amdgpu_device *adev = file_inode(f)->i_private;
3949 struct dc *dc = adev->dm.dc;
3950 char *rd_buf = NULL;
3951 const uint32_t rd_buf_size = 32;
3952 uint32_t result = 0;
3954 int num_pipes = dc->res_pool->pipe_count;
3958 dcc_en_bits = kcalloc(num_pipes, sizeof(int), GFP_KERNEL);
3962 if (!dc->hwss.get_dcc_en_bits) {
3967 dc->hwss.get_dcc_en_bits(dc, dcc_en_bits);
3969 rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
3975 for (i = 0; i < num_pipes; i++)
3976 offset += snprintf(rd_buf + offset, rd_buf_size - offset,
3977 "%d ", dcc_en_bits[i]);
3978 rd_buf[strlen(rd_buf)] = '\n';
3983 if (*pos >= rd_buf_size)
3985 r = put_user(*(rd_buf + result), buf);
3988 return r; /* r = -EFAULT */
4000 void dtn_debugfs_init(struct amdgpu_device *adev)
4002 static const struct file_operations dtn_log_fops = {
4003 .owner = THIS_MODULE,
4004 .read = dtn_log_read,
4005 .write = dtn_log_write,
4006 .llseek = default_llseek
4008 static const struct file_operations dcc_en_bits_fops = {
4009 .owner = THIS_MODULE,
4010 .read = dcc_en_bits_read,
4011 .llseek = default_llseek
4014 struct drm_minor *minor = adev_to_drm(adev)->primary;
4015 struct dentry *root = minor->debugfs_root;
4017 debugfs_create_file("amdgpu_mst_topology", 0444, root,
4018 adev, &mst_topo_fops);
4019 debugfs_create_file("amdgpu_dm_capabilities", 0444, root,
4020 adev, &capabilities_fops);
4021 debugfs_create_file("amdgpu_dm_dtn_log", 0644, root, adev,
4023 debugfs_create_file("amdgpu_dm_dp_set_mst_en_for_sst", 0644, root, adev,
4024 &dp_set_mst_en_for_sst_ops);
4025 debugfs_create_file("amdgpu_dm_dp_ignore_cable_id", 0644, root, adev,
4026 &dp_ignore_cable_id_ops);
4028 debugfs_create_file_unsafe("amdgpu_dm_visual_confirm", 0644, root, adev,
4029 &visual_confirm_fops);
4031 debugfs_create_file_unsafe("amdgpu_dm_skip_detection_link_training", 0644, root, adev,
4032 &skip_detection_link_training_fops);
4034 debugfs_create_file_unsafe("amdgpu_dm_dmub_tracebuffer", 0644, root,
4035 adev, &dmub_tracebuffer_fops);
4037 debugfs_create_file_unsafe("amdgpu_dm_dmub_fw_state", 0644, root,
4038 adev, &dmub_fw_state_fops);
4040 debugfs_create_file_unsafe("amdgpu_dm_force_timing_sync", 0644, root,
4041 adev, &force_timing_sync_ops);
4043 debugfs_create_file_unsafe("amdgpu_dm_dmub_trace_mask", 0644, root,
4044 adev, &dmub_trace_mask_fops);
4046 debugfs_create_file_unsafe("amdgpu_dm_dmcub_trace_event_en", 0644, root,
4047 adev, &dmcub_trace_event_state_fops);
4049 debugfs_create_file_unsafe("amdgpu_dm_trigger_hpd_mst", 0644, root,
4050 adev, &trigger_hpd_mst_ops);
4052 debugfs_create_file_unsafe("amdgpu_dm_dcc_en", 0644, root, adev,
4055 debugfs_create_file_unsafe("amdgpu_dm_disable_hpd", 0644, root, adev,