OSDN Git Service

drm/amd/display: PSR panel capability debugfs
authorMikita Lipski <mikita.lipski@amd.com>
Thu, 18 Nov 2021 13:34:41 +0000 (08:34 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 1 Dec 2021 21:06:19 +0000 (16:06 -0500)
[why]
Adding a debugfs to show PSR capability of the panel and the driver.
To use:
  cat /sys/kernel/debug/dri/0/eDP-X/psr_capability
Expected output:
 Sink support: no/yes
 Driver support: no/yes

[how]
Adding psr_capability to eDP connectors.

Reviewed-by: Nicholas Kazlauskas <Nicholas.Kazlauskas@amd.com>
Acked-by: Bhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
Signed-off-by: Mikita Lipski <mikita.lipski@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c

index 9d43ecb..d7f8883 100644 (file)
@@ -824,6 +824,48 @@ static int dmub_fw_state_show(struct seq_file *m, void *data)
        return seq_write(m, state_base, state_size);
 }
 
+/* psr_capability_show() - show eDP panel PSR capability
+ *
+ * The read function: sink_psr_capability_show
+ * Shows if sink has PSR capability or not.
+ * If yes - the PSR version is appended
+ *
+ *     cat /sys/kernel/debug/dri/0/eDP-X/psr_capability
+ *
+ * Expected output:
+ * "Sink support: no\n" - if panel doesn't support PSR
+ * "Sink support: yes [0x01]\n" - if panel supports PSR1
+ * "Driver support: no\n" - if driver doesn't support PSR
+ * "Driver support: yes [0x01]\n" - if driver supports PSR1
+ */
+static int psr_capability_show(struct seq_file *m, void *data)
+{
+       struct drm_connector *connector = m->private;
+       struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);
+       struct dc_link *link = aconnector->dc_link;
+
+       if (!link)
+               return -ENODEV;
+
+       if (link->type == dc_connection_none)
+               return -ENODEV;
+
+       if (!(link->connector_signal & SIGNAL_TYPE_EDP))
+               return -ENODEV;
+
+       seq_printf(m, "Sink support: %s", yesno(link->dpcd_caps.psr_caps.psr_version != 0));
+       if (link->dpcd_caps.psr_caps.psr_version)
+               seq_printf(m, " [0x%02x]", link->dpcd_caps.psr_caps.psr_version);
+       seq_puts(m, "\n");
+
+       seq_printf(m, "Driver support: %s", yesno(link->psr_settings.psr_feature_enabled));
+       if (link->psr_settings.psr_version)
+               seq_printf(m, " [0x%02x]", link->psr_settings.psr_version);
+       seq_puts(m, "\n");
+
+       return 0;
+}
+
 /*
  * Returns the current and maximum output bpc for the connector.
  * Example usage: cat /sys/kernel/debug/dri/0/DP-1/output_bpc
@@ -2467,6 +2509,7 @@ DEFINE_SHOW_ATTRIBUTE(dp_lttpr_status);
 DEFINE_SHOW_ATTRIBUTE(hdcp_sink_capability);
 #endif
 DEFINE_SHOW_ATTRIBUTE(internal_display);
+DEFINE_SHOW_ATTRIBUTE(psr_capability);
 
 static const struct file_operations dp_dsc_clock_en_debugfs_fops = {
        .owner = THIS_MODULE,
@@ -2726,6 +2769,7 @@ void connector_debugfs_init(struct amdgpu_dm_connector *connector)
                }
        }
        if (connector->base.connector_type == DRM_MODE_CONNECTOR_eDP) {
+               debugfs_create_file_unsafe("psr_capability", 0444, dir, connector, &psr_capability_fops);
                debugfs_create_file_unsafe("psr_state", 0444, dir, connector, &psr_fops);
                debugfs_create_file("amdgpu_current_backlight_pwm", 0444, dir, connector,
                                    &current_backlight_fops);