[PATCH 16/17] drm/i915: Add new debugfs file for Displaypor compliance test control

Todd Previte
2014-12-10T23:54:25Z

Adds a new file for controlling Displayport compliance testing via the debugfs
interface. Adds two functions, 'open' and 'show', as well as the file operations
structure to support reading the file from userspace. The new file is called
'i915_dp_test_ctl' and contains 4 fields:
- Connector name
- Test data
- Test active flag
- Test response
These four fields are used to control communication and operation between the
userspace application and the kernel during compliance testing. A new variable
is also added to the intel_dp struct to hold the response code from the user
application. This response code is then sent to the sink device upon completion
of the test.

Signed-off-by: Todd Previte <tprevite@gmail.com>
---
drivers/gpu/drm/i915/i915_debugfs.c | 66 ++++++++++++++++++++++++++++++++++++-
drivers/gpu/drm/i915/intel_drv.h | 1 +
2 files changed, 66 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 846b2fb..d2cd684 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -54,6 +54,7 @@ static const char *yesno(int v)

#define DP_PARAMETER_COUNT 8
#define MAX_DP_CONFIG_LINE_COUNT 64
+#define DP_TEST_CTRL_LINE_COUNT 4

enum dp_config_param {
DP_CONFIG_PARAM_INVALID = -1,
@@ -67,6 +68,14 @@ enum dp_config_param {
DP_CONFIG_PARAM_BPP
};

+enum dp_ctrl_param {
+ DP_CTRL_PARAM_INVALID = -1,
+ DP_CTRL_PARAM_CONNECTOR = 0,
+ DP_CTRL_PARAM_TEST_DATA = 1,
+ DP_CTRL_PARAM_TEST_ACTIVE = 2,
+ DP_CTRL_PARAM_TEST_RESPONSE = 3
+};
+
struct dp_config {
enum dp_config_param type;
unsigned long value;
@@ -4054,6 +4063,60 @@ static const struct file_operations i915_displayport_config_ctl_fops = {
.write = displayport_config_ctl_write
};

+static int displayport_test_ctl_show(struct seq_file *m, void *data)
+{
+ struct drm_device *dev = m->private;
+ struct drm_connector *connector;
+ struct intel_encoder *intel_encoder;
+ struct intel_connector *intel_connector;
+ struct intel_dp *intel_dp;
+
+ if (!dev)
+ return -ENODEV;
+
+ list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
+ intel_connector = to_intel_connector(connector);
+ intel_encoder = intel_connector->encoder;
+
+ seq_printf(m, DP_CONF_STR_CONNECTOR,
+ intel_connector->base.name);
+
+ if (dp_connector_is_valid(connector, 1)) {
+ intel_encoder = intel_connector->encoder;
+ intel_dp = enc_to_intel_dp(&intel_encoder->base);
+ /* Compliance test data informs userspace about current
+ request
+ */
+ seq_printf(m, "Test Data : %08lx\n",
+ intel_dp->compliance_test_data);
+ seq_printf(m, "Test Active: %02x\n",
+ intel_dp->compliance_testing_active);
+ seq_printf(m, "Test Response: %02lx\n",
+ intel_dp->compliance_test_response);
+ } else {
+ seq_puts(m, "disconnected\n");
+ }
+ }
+
+ return 0;
+}
+
+static int displayport_test_ctl_open(struct inode *inode,
+ struct file *file)
+{
+ struct drm_device *dev = inode->i_private;
+
+ return single_open(file, displayport_test_ctl_show, dev);
+}
+
+static const struct file_operations i915_dp_test_ctl_fops = {
+ .owner = THIS_MODULE,
+ .open = displayport_test_ctl_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
static void wm_latency_show(struct seq_file *m, const uint16_t wm[8])
{
struct drm_device *dev = m->private;
@@ -4806,7 +4869,8 @@ static const struct i915_debugfs_files {
{"i915_spr_wm_latency", &i915_spr_wm_latency_fops},
{"i915_cur_wm_latency", &i915_cur_wm_latency_fops},
{"i915_fbc_false_color", &i915_fbc_fc_fops},
- {"i915_displayport_config_ctl", &i915_displayport_config_ctl_fops}
+ {"i915_displayport_config_ctl", &i915_displayport_config_ctl_fops},
+ {"i915_dp_test_ctl", &i915_dp_test_ctl_fops}
};

void intel_display_crc_init(struct drm_device *dev)
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 5a8b1d6..eff3a14 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -653,6 +653,7 @@ struct intel_dp {
/* Displayport compliance testing */
unsigned long compliance_test_data;
bool compliance_testing_active;
+ unsigned long compliance_test_response;
struct intel_dp_link_config compliance_config;
struct intel_dp_link_config saved_config;

--
1.9.1