diff mbox

[17/17] drm/i915: Add debugfs write and test param parsing function for DP test control

Message ID 1418255597-4716-18-git-send-email-tprevite@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Todd Previte Dec. 10, 2014, 11:53 p.m. UTC
Adds and implements the 'write' function for the debugfs i915_dp_test_ctrl file.
Also adds in the required parsing function to read in the data from the file
once the user app has written its data to it.

Signed-off-by: Todd Previte <tprevite@gmail.com>
---
 drivers/gpu/drm/i915/i915_debugfs.c | 103 ++++++++++++++++++++++++++++++++++++
 1 file changed, 103 insertions(+)

Comments

Shuang He Dec. 16, 2014, 7:13 a.m. UTC | #1
Tested-By: PRC QA PRTS (Patch Regression Test System Contact: shuang.he@intel.com)
-------------------------------------Summary-------------------------------------
Platform          Delta          drm-intel-nightly          Series Applied
PNV                                  364/364              364/364
ILK              +5                 360/366              365/366
SNB                                  448/450              448/450
IVB                 -1              497/498              496/498
BYT                                  289/289              289/289
HSW                                  563/564              563/564
BDW                                  417/417              417/417
-------------------------------------Detailed-------------------------------------
Platform  Test                                drm-intel-nightly          Series Applied
 ILK  igt_drv_suspend_fence-restore-untiled      DMESG_WARN(1, M26)PASS(7, M37M26)      PASS(1, M37)
 ILK  igt_kms_flip_bcs-flip-vs-modeset-interruptible      DMESG_WARN(1, M26)PASS(7, M37M26)      PASS(1, M37)
 ILK  igt_kms_flip_busy-flip-interruptible      DMESG_WARN(2, M26)PASS(6, M37M26)      PASS(1, M37)
 ILK  igt_kms_flip_flip-vs-rmfb-interruptible      DMESG_WARN(1, M26)PASS(7, M37M26)      PASS(1, M37)
 ILK  igt_kms_flip_rcs-flip-vs-dpms      DMESG_WARN(1, M26)PASS(6, M37M26)      PASS(1, M37)
*IVB  igt_kms_cursor_crc_cursor-64x64-sliding      FAIL(1, M21)PASS(1, M34)      DMESG_WARN(1, M21)
Note: You need to pay more attention to line start with '*'
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index d2cd684..091d62b 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -4063,6 +4063,46 @@  static const struct file_operations i915_displayport_config_ctl_fops = {
 	.write = displayport_config_ctl_write
 };
 
+static int displayport_parse_test_ctl(char *input_buffer,
+				      ssize_t buffer_size,
+				      struct intel_dp *intel_dp)
+{
+	char *ctrl_lines[DP_TEST_CTRL_LINE_COUNT];
+	int line_count;
+	int test_data;
+	int active;
+	int response;
+	char *conn_name; /* Connector name in the file */
+	char *dp_name;	 /* Connector name in the intel_dp struct */
+
+	if (!input_buffer)
+		return -EIO;
+
+	line_count = tokenize_dp_config(input_buffer, ctrl_lines);
+	if (line_count != DP_TEST_CTRL_LINE_COUNT)
+		return -EIO;
+
+	conn_name = ctrl_lines[DP_CTRL_PARAM_CONNECTOR];
+	dp_name = intel_dp->attached_connector->base.name;
+
+	if (strncmp(conn_name, dp_name, strlen(dp_name)) == 0) {
+		kstrtol(ctrl_lines[DP_CTRL_PARAM_TEST_DATA],
+			16,
+			(long *)&test_data);
+		kstrtol(ctrl_lines[DP_CTRL_PARAM_TEST_ACTIVE],
+			16,
+			(long *)&active);
+		kstrtol(ctrl_lines[DP_CTRL_PARAM_TEST_RESPONSE],
+			16,
+			(long *)&response);
+	} else {
+		DRM_DEBUG_DRIVER("Connector names don't match\n");
+		return -EIO;
+	}
+
+	return 0;
+}
+
 static int displayport_test_ctl_show(struct seq_file *m, void *data)
 {
 	struct drm_device *dev = m->private;
@@ -4109,9 +4149,72 @@  static int displayport_test_ctl_open(struct inode *inode,
 	return single_open(file, displayport_test_ctl_show, dev);
 }
 
+static ssize_t displayport_test_ctl_write(struct file *file,
+					    const char __user *ubuf,
+					    size_t len, loff_t *offp)
+{
+	char *input_buffer;
+	int status = 0;
+	struct seq_file *m;
+	struct drm_device *dev;
+	struct drm_connector *connector;
+	struct intel_encoder *intel_encoder;
+	struct intel_connector *intel_connector;
+	struct intel_dp *intel_dp;
+
+	m = file->private_data;
+	if (!m) {
+		status = -ENODEV;
+		return status;
+	}
+	dev = m->private;
+
+	if (!dev) {
+		status = -ENODEV;
+		return status;
+	}
+
+	if (len == 0)
+		return 0;
+
+	input_buffer = kmalloc(len + 1, GFP_KERNEL);
+	if (!input_buffer)
+		return -ENOMEM;
+
+	if (copy_from_user(input_buffer, ubuf, len)) {
+		status = -EFAULT;
+		goto out;
+	}
+
+	input_buffer[len] = '\0';
+	DRM_DEBUG_DRIVER("Copied %d bytes from user\n", (unsigned int)len);
+
+	list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
+		intel_connector = to_intel_connector(connector);
+		intel_encoder = intel_connector->encoder;
+		if (dp_connector_is_valid(connector, 0)) {
+			intel_dp = enc_to_intel_dp(&intel_encoder->base);
+			status = displayport_parse_test_ctl(input_buffer,
+							    len,
+							    intel_dp);
+			if (status < 0)
+				goto out;
+		}
+	}
+out:
+	kfree(input_buffer);
+	if (status < 0)
+		return status;
+
+	*offp += len;
+	return len;
+
+}
+
 static const struct file_operations i915_dp_test_ctl_fops = {
 	.owner = THIS_MODULE,
 	.open = displayport_test_ctl_open,
+	.write = displayport_test_ctl_write,
 	.read = seq_read,
 	.llseek = seq_lseek,
 	.release = single_release,