From patchwork Wed Dec 10 23:53:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Todd Previte X-Patchwork-Id: 5473421 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 152339F1D4 for ; Wed, 10 Dec 2014 23:54:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3A5FD20172 for ; Wed, 10 Dec 2014 23:54:30 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 43B7C2016C for ; Wed, 10 Dec 2014 23:54:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BF7B76E711; Wed, 10 Dec 2014 15:54:28 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pa0-f45.google.com (mail-pa0-f45.google.com [209.85.220.45]) by gabe.freedesktop.org (Postfix) with ESMTP id E1CA17A03F for ; Wed, 10 Dec 2014 15:54:26 -0800 (PST) Received: by mail-pa0-f45.google.com with SMTP id lf10so3193604pab.18 for ; Wed, 10 Dec 2014 15:54:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VE9wZtW4C9i2hNsi+YpeB+zjiVDL6M5GH7CgBxb77Yw=; b=MaLfSHxZ4p6GDVXhr5t6hVJPpeZKybahZfoKmNebr+x9gDK0N6DStPOC0WzRiwxqM8 tIU7UyXq0m+bv+AU12aPoXcGhZ3RD7lCF3VT5HfaHbxlHT6sZUpqCfvVgjSRE4Yzz2vB A1B3cqf3mO+ndQWBfl7zjE9ICz4Pozt+Kbr34fMgQagvLMTF0uVz8vOWt0idfk3Dc/W6 WjvTuOBuA5x6pfq9lZ/V3/lzZQh5ekFLJLuQHmeEwehzZP3e/IulAZYTTSQo56p39ZqZ nzQAkF0fLpEh9+hVZkPVqnkK+WBr9R4Q/2eKQc0rNdWOG3av3UeYZZEqPX/cGSe6l14Q VrrQ== X-Received: by 10.68.196.231 with SMTP id ip7mr11873519pbc.94.1418255666809; Wed, 10 Dec 2014 15:54:26 -0800 (PST) Received: from localhost.localdomain (ip68-3-234-27.ph.ph.cox.net. [68.3.234.27]) by mx.google.com with ESMTPSA id gy10sm5164958pbd.67.2014.12.10.15.54.24 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Dec 2014 15:54:25 -0800 (PST) From: Todd Previte To: intel-gfx@lists.freedesktop.org Date: Wed, 10 Dec 2014 16:53:17 -0700 Message-Id: <1418255597-4716-18-git-send-email-tprevite@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1418255597-4716-1-git-send-email-tprevite@gmail.com> References: <1418255597-4716-1-git-send-email-tprevite@gmail.com> Subject: [Intel-gfx] [PATCH 17/17] drm/i915: Add debugfs write and test param parsing function for DP test control X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Tested-By: PRC QA PRTS (Patch Regression Test System Contact: shuang.he@intel.com) --- drivers/gpu/drm/i915/i915_debugfs.c | 103 ++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) 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,