Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915/dsc: Add debugfs entry to validate DSC output formats

DSC_Output_Format_Sink_Support entry is added to i915_dsc_fec_support_show
to depict if sink supports DSC output formats (RGB/YCbCr420/YCbCr444).
Also, new debugfs entry is created to enforce output format. This is
required because of our driver policy. For ex. if a mode is supported
in both RGB and YCbCr420 output formats by the sink, our policy is to
try RGB first and fall back to YCbCr420, if mode cannot be shown
using RGB. So, to test other output formats like YCbCr420 or YCbCr444,
we need a debugfs entry (force_dsc_output_format) to force this
output format.

v2: -Func name changed to intel_output_format_name() (Jani N)
-Return forced o/p format from intel_dp_output_format() (Jani N)
v3: -output_format_str[] to remain static (Jani N)

Signed-off-by: Swati Sharma <swati2.sharma@intel.com>
Reviewed-by: Uma Shankar <uma.shankar@intel.com>
Signed-off-by: Uma Shankar <uma.shankar@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230309062855.393087-8-suraj.kandpal@intel.com

authored by

Swati Sharma and committed by
Uma Shankar
d4d17377 16e7a0db

+87 -2
+2 -2
drivers/gpu/drm/i915/display/intel_crtc_state_dump.c
··· 123 123 [INTEL_OUTPUT_FORMAT_YCBCR444] = "YCBCR4:4:4", 124 124 }; 125 125 126 - static const char *output_formats(enum intel_output_format format) 126 + const char *intel_output_format_name(enum intel_output_format format) 127 127 { 128 128 if (format >= ARRAY_SIZE(output_format_str)) 129 129 return "invalid"; ··· 181 181 "active: %s, output_types: %s (0x%x), output format: %s\n", 182 182 str_yes_no(pipe_config->hw.active), 183 183 buf, pipe_config->output_types, 184 - output_formats(pipe_config->output_format)); 184 + intel_output_format_name(pipe_config->output_format)); 185 185 186 186 drm_dbg_kms(&i915->drm, 187 187 "cpu_transcoder: %s, pipe bpp: %i, dithering: %i\n",
+2
drivers/gpu/drm/i915/display/intel_crtc_state_dump.h
··· 8 8 9 9 struct intel_crtc_state; 10 10 struct intel_atomic_state; 11 + enum intel_output_format; 11 12 12 13 void intel_crtc_state_dump(const struct intel_crtc_state *crtc_state, 13 14 struct intel_atomic_state *state, 14 15 const char *context); 16 + const char *intel_output_format_name(enum intel_output_format format); 15 17 16 18 #endif /* __INTEL_CRTC_STATE_H__ */
+78
drivers/gpu/drm/i915/display/intel_display_debugfs.c
··· 13 13 #include "i915_irq.h" 14 14 #include "i915_reg.h" 15 15 #include "intel_de.h" 16 + #include "intel_crtc_state_dump.h" 16 17 #include "intel_display_debugfs.h" 17 18 #include "intel_display_power.h" 18 19 #include "intel_display_power_well.h" ··· 1235 1234 str_yes_no(crtc_state->dsc.compression_enable)); 1236 1235 seq_printf(m, "DSC_Sink_Support: %s\n", 1237 1236 str_yes_no(drm_dp_sink_supports_dsc(intel_dp->dsc_dpcd))); 1237 + seq_printf(m, "DSC_Output_Format_Sink_Support: RGB: %s YCBCR420: %s YCBCR444: %s\n", 1238 + str_yes_no(drm_dp_dsc_sink_supports_format(intel_dp->dsc_dpcd, 1239 + DP_DSC_RGB)), 1240 + str_yes_no(drm_dp_dsc_sink_supports_format(intel_dp->dsc_dpcd, 1241 + DP_DSC_YCbCr420_Native)), 1242 + str_yes_no(drm_dp_dsc_sink_supports_format(intel_dp->dsc_dpcd, 1243 + DP_DSC_YCbCr444))); 1238 1244 seq_printf(m, "Force_DSC_Enable: %s\n", 1239 1245 str_yes_no(intel_dp->force_dsc_en)); 1240 1246 if (!intel_dp_is_edp(intel_dp)) ··· 1367 1359 .write = i915_dsc_bpc_write 1368 1360 }; 1369 1361 1362 + static int i915_dsc_output_format_show(struct seq_file *m, void *data) 1363 + { 1364 + struct drm_connector *connector = m->private; 1365 + struct drm_device *dev = connector->dev; 1366 + struct drm_crtc *crtc; 1367 + struct intel_crtc_state *crtc_state; 1368 + struct intel_encoder *encoder = intel_attached_encoder(to_intel_connector(connector)); 1369 + int ret; 1370 + 1371 + if (!encoder) 1372 + return -ENODEV; 1373 + 1374 + ret = drm_modeset_lock_single_interruptible(&dev->mode_config.connection_mutex); 1375 + if (ret) 1376 + return ret; 1377 + 1378 + crtc = connector->state->crtc; 1379 + if (connector->status != connector_status_connected || !crtc) { 1380 + ret = -ENODEV; 1381 + goto out; 1382 + } 1383 + 1384 + crtc_state = to_intel_crtc_state(crtc->state); 1385 + seq_printf(m, "DSC_Output_Format: %s\n", 1386 + intel_output_format_name(crtc_state->output_format)); 1387 + 1388 + out: drm_modeset_unlock(&dev->mode_config.connection_mutex); 1389 + 1390 + return ret; 1391 + } 1392 + 1393 + static ssize_t i915_dsc_output_format_write(struct file *file, 1394 + const char __user *ubuf, 1395 + size_t len, loff_t *offp) 1396 + { 1397 + struct drm_connector *connector = 1398 + ((struct seq_file *)file->private_data)->private; 1399 + struct intel_encoder *encoder = intel_attached_encoder(to_intel_connector(connector)); 1400 + struct intel_dp *intel_dp = enc_to_intel_dp(encoder); 1401 + int dsc_output_format = 0; 1402 + int ret; 1403 + 1404 + ret = kstrtoint_from_user(ubuf, len, 0, &dsc_output_format); 1405 + if (ret < 0) 1406 + return ret; 1407 + 1408 + intel_dp->force_dsc_output_format = dsc_output_format; 1409 + *offp += len; 1410 + 1411 + return len; 1412 + } 1413 + 1414 + static int i915_dsc_output_format_open(struct inode *inode, 1415 + struct file *file) 1416 + { 1417 + return single_open(file, i915_dsc_output_format_show, inode->i_private); 1418 + } 1419 + 1420 + static const struct file_operations i915_dsc_output_format_fops = { 1421 + .owner = THIS_MODULE, 1422 + .open = i915_dsc_output_format_open, 1423 + .read = seq_read, 1424 + .llseek = seq_lseek, 1425 + .release = single_release, 1426 + .write = i915_dsc_output_format_write 1427 + }; 1428 + 1370 1429 /* 1371 1430 * Returns the Current CRTC's bpc. 1372 1431 * Example usage: cat /sys/kernel/debug/dri/0/crtc-0/i915_current_bpc ··· 1508 1433 1509 1434 debugfs_create_file("i915_dsc_bpc", 0644, root, 1510 1435 connector, &i915_dsc_bpc_fops); 1436 + 1437 + debugfs_create_file("i915_dsc_output_format", 0644, root, 1438 + connector, &i915_dsc_output_format_fops); 1511 1439 } 1512 1440 1513 1441 if (connector->connector_type == DRM_MODE_CONNECTOR_DSI ||
+1
drivers/gpu/drm/i915/display/intel_display_types.h
··· 1741 1741 1742 1742 /* Display stream compression testing */ 1743 1743 bool force_dsc_en; 1744 + int force_dsc_output_format; 1744 1745 int force_dsc_bpc; 1745 1746 1746 1747 bool hobl_failed;
+4
drivers/gpu/drm/i915/display/intel_dp.c
··· 76 76 #include "intel_tc.h" 77 77 #include "intel_vdsc.h" 78 78 #include "intel_vrr.h" 79 + #include "intel_crtc_state_dump.h" 79 80 80 81 /* DP DSC throughput values used for slice count calculations KPixels/s */ 81 82 #define DP_DSC_PEAK_PIXEL_RATE 2720000 ··· 833 832 bool ycbcr_420_output) 834 833 { 835 834 struct intel_dp *intel_dp = intel_attached_dp(connector); 835 + 836 + if (intel_dp->force_dsc_output_format) 837 + return intel_dp->force_dsc_output_format; 836 838 837 839 if (!connector->base.ycbcr_420_allowed || !ycbcr_420_output) 838 840 return INTEL_OUTPUT_FORMAT_RGB;