Skip to content

Commit fd45b65

Browse files
Harry Wentlandalexdeucher
authored andcommitted
drm/amd/display: Add debugfs for testing output colorspace
In order to IGT test colorspace we'll want to print the currently enabled colorspace on a stream. We add a new debugfs to do so, using the same scheme as current bpc reporting. This might also come in handy when debugging display issues. v4: - Fix function doc comment - Fix sRGB debug print Signed-off-by: Harry Wentland <harry.wentland@amd.com> Reviewed-by: Joshua Ashton <joshua@froggi.es> Cc: Pekka Paalanen <ppaalanen@gmail.com> Cc: Sebastian Wick <sebastian.wick@redhat.com> Cc: Vitaly.Prosyak@amd.com Cc: Joshua Ashton <joshua@froggi.es> Cc: Simon Ser <contact@emersion.fr> Cc: Melissa Wen <mwen@igalia.com> Cc: dri-devel@lists.freedesktop.org Cc: amd-gfx@lists.freedesktop.org Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent bd49f19 commit fd45b65

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,61 @@ static int amdgpu_current_bpc_show(struct seq_file *m, void *data)
906906
}
907907
DEFINE_SHOW_ATTRIBUTE(amdgpu_current_bpc);
908908

909+
/*
910+
* Returns the current colorspace for the crtc.
911+
* Example usage: cat /sys/kernel/debug/dri/0/crtc-0/amdgpu_current_colorspace
912+
*/
913+
static int amdgpu_current_colorspace_show(struct seq_file *m, void *data)
914+
{
915+
struct drm_crtc *crtc = m->private;
916+
struct drm_device *dev = crtc->dev;
917+
struct dm_crtc_state *dm_crtc_state = NULL;
918+
int res = -ENODEV;
919+
920+
mutex_lock(&dev->mode_config.mutex);
921+
drm_modeset_lock(&crtc->mutex, NULL);
922+
if (crtc->state == NULL)
923+
goto unlock;
924+
925+
dm_crtc_state = to_dm_crtc_state(crtc->state);
926+
if (dm_crtc_state->stream == NULL)
927+
goto unlock;
928+
929+
switch (dm_crtc_state->stream->output_color_space) {
930+
case COLOR_SPACE_SRGB:
931+
seq_printf(m, "sRGB");
932+
break;
933+
case COLOR_SPACE_YCBCR601:
934+
case COLOR_SPACE_YCBCR601_LIMITED:
935+
seq_printf(m, "BT601_YCC");
936+
break;
937+
case COLOR_SPACE_YCBCR709:
938+
case COLOR_SPACE_YCBCR709_LIMITED:
939+
seq_printf(m, "BT709_YCC");
940+
break;
941+
case COLOR_SPACE_ADOBERGB:
942+
seq_printf(m, "opRGB");
943+
break;
944+
case COLOR_SPACE_2020_RGB_FULLRANGE:
945+
seq_printf(m, "BT2020_RGB");
946+
break;
947+
case COLOR_SPACE_2020_YCBCR:
948+
seq_printf(m, "BT2020_YCC");
949+
break;
950+
default:
951+
goto unlock;
952+
}
953+
res = 0;
954+
955+
unlock:
956+
drm_modeset_unlock(&crtc->mutex);
957+
mutex_unlock(&dev->mode_config.mutex);
958+
959+
return res;
960+
}
961+
DEFINE_SHOW_ATTRIBUTE(amdgpu_current_colorspace);
962+
963+
909964
/*
910965
* Example usage:
911966
* Disable dsc passthrough, i.e.,: have dsc decoding at converver, not external RX
@@ -3139,6 +3194,8 @@ void crtc_debugfs_init(struct drm_crtc *crtc)
31393194
#endif
31403195
debugfs_create_file("amdgpu_current_bpc", 0644, crtc->debugfs_entry,
31413196
crtc, &amdgpu_current_bpc_fops);
3197+
debugfs_create_file("amdgpu_current_colorspace", 0644, crtc->debugfs_entry,
3198+
crtc, &amdgpu_current_colorspace_fops);
31423199
}
31433200

31443201
/*

0 commit comments

Comments
 (0)