Merge tag 'amd-drm-next-5.20-2022-07-14' of https://gitlab.freedesktop.org/agd5f...
[linux-2.6-microblaze.git] / drivers / gpu / drm / amd / display / amdgpu_dm / amdgpu_dm_debugfs.c
index 49bdcbf..a1f40d0 100644 (file)
@@ -871,28 +871,18 @@ static int psr_capability_show(struct seq_file *m, void *data)
 }
 
 /*
- * Returns the current and maximum output bpc for the connector.
- * Example usage: cat /sys/kernel/debug/dri/0/DP-1/output_bpc
+ * Returns the current bpc for the crtc.
+ * Example usage: cat /sys/kernel/debug/dri/0/crtc-0/amdgpu_current_bpc
  */
-static int output_bpc_show(struct seq_file *m, void *data)
+static int amdgpu_current_bpc_show(struct seq_file *m, void *data)
 {
-       struct drm_connector *connector = m->private;
-       struct drm_device *dev = connector->dev;
-       struct drm_crtc *crtc = NULL;
+       struct drm_crtc *crtc = m->private;
+       struct drm_device *dev = crtc->dev;
        struct dm_crtc_state *dm_crtc_state = NULL;
        int res = -ENODEV;
        unsigned int bpc;
 
        mutex_lock(&dev->mode_config.mutex);
-       drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
-
-       if (connector->state == NULL)
-               goto unlock;
-
-       crtc = connector->state->crtc;
-       if (crtc == NULL)
-               goto unlock;
-
        drm_modeset_lock(&crtc->mutex, NULL);
        if (crtc->state == NULL)
                goto unlock;
@@ -922,18 +912,15 @@ static int output_bpc_show(struct seq_file *m, void *data)
        }
 
        seq_printf(m, "Current: %u\n", bpc);
-       seq_printf(m, "Maximum: %u\n", connector->display_info.bpc);
        res = 0;
 
 unlock:
-       if (crtc)
-               drm_modeset_unlock(&crtc->mutex);
-
-       drm_modeset_unlock(&dev->mode_config.connection_mutex);
+       drm_modeset_unlock(&crtc->mutex);
        mutex_unlock(&dev->mode_config.mutex);
 
        return res;
 }
+DEFINE_SHOW_ATTRIBUTE(amdgpu_current_bpc);
 
 /*
  * Example usage:
@@ -2545,7 +2532,6 @@ static int target_backlight_show(struct seq_file *m, void *unused)
 DEFINE_SHOW_ATTRIBUTE(dp_dsc_fec_support);
 DEFINE_SHOW_ATTRIBUTE(dmub_fw_state);
 DEFINE_SHOW_ATTRIBUTE(dmub_tracebuffer);
-DEFINE_SHOW_ATTRIBUTE(output_bpc);
 DEFINE_SHOW_ATTRIBUTE(dp_lttpr_status);
 #ifdef CONFIG_DRM_AMD_DC_HDCP
 DEFINE_SHOW_ATTRIBUTE(hdcp_sink_capability);
@@ -2792,7 +2778,6 @@ static const struct {
        const struct file_operations *fops;
 } connector_debugfs_entries[] = {
                {"force_yuv420_output", &force_yuv420_output_fops},
-               {"output_bpc", &output_bpc_fops},
                {"trigger_hotplug", &trigger_hotplug_debugfs_fops},
                {"internal_display", &internal_display_fops}
 };
@@ -3176,9 +3161,10 @@ static int crc_win_update_get(void *data, u64 *val)
 
 DEFINE_DEBUGFS_ATTRIBUTE(crc_win_update_fops, crc_win_update_get,
                         crc_win_update_set, "%llu\n");
-
+#endif
 void crtc_debugfs_init(struct drm_crtc *crtc)
 {
+#ifdef CONFIG_DRM_AMD_SECURE_DISPLAY
        struct dentry *dir = debugfs_lookup("crc", crtc->debugfs_entry);
 
        if (!dir)
@@ -3194,9 +3180,11 @@ void crtc_debugfs_init(struct drm_crtc *crtc)
                                   &crc_win_y_end_fops);
        debugfs_create_file_unsafe("crc_win_update", 0644, dir, crtc,
                                   &crc_win_update_fops);
-
-}
 #endif
+       debugfs_create_file("amdgpu_current_bpc", 0644, crtc->debugfs_entry,
+                           crtc, &amdgpu_current_bpc_fops);
+}
+
 /*
  * Writes DTN log state to the user supplied buffer.
  * Example usage: cat /sys/kernel/debug/dri/0/amdgpu_dm_dtn_log