From patchwork Thu Feb 19 03:00:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Todd Previte X-Patchwork-Id: 5849751 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 920059F36A for ; Thu, 19 Feb 2015 03:01:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9FBBE2021F for ; Thu, 19 Feb 2015 03:01:00 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id B706F201F4 for ; Thu, 19 Feb 2015 03:00:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2F6056E413; Wed, 18 Feb 2015 19:00:59 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pa0-f42.google.com (mail-pa0-f42.google.com [209.85.220.42]) by gabe.freedesktop.org (Postfix) with ESMTP id 2F00D6E2BE for ; Wed, 18 Feb 2015 19:00:58 -0800 (PST) Received: by pablf10 with SMTP id lf10so5977521pab.12 for ; Wed, 18 Feb 2015 19:00:58 -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=gbWXZgl4Yu5qFqu5/EhLQPgH22F+OwNU0GbYX0t/HZY=; b=ZmTMtF6oih3eOXXoAezPRJQ/8hZGK50+d+xs0BxzDcRi4eV8W5uYRCqdn3FfnV44/L ODMjsU8BzvOK9z6oNSuJcLaMKyrWh+1u/WBN6w06ySjgpPMmbeE/TmEqPSDx/F9yKnfR w02S2529DH+ZEDg/Rdjw2RiqkIvj11anIk6yLUhCyjS8kWkPIygyX9Hkl3DubVPx0Cub AK8uWC5z71lopSdqz2o6mmmtqt2grFcOJJ4lrkd0PtCAtvAURtqzplFdaFAe0XsVet+3 6JrMqRPrRg8tk2kM4Lt6JF9l4e9hd1VQjJ56FcBmdXy1YnJYJxSoYq1v+05TfYxTmy2y ar1w== X-Received: by 10.66.140.39 with SMTP id rd7mr3778891pab.25.1424314858010; Wed, 18 Feb 2015 19:00:58 -0800 (PST) Received: from localhost.localdomain (ip70-162-72-208.ph.ph.cox.net. [70.162.72.208]) by mx.google.com with ESMTPSA id je2sm21953646pbd.44.2015.02.18.19.00.56 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Feb 2015 19:00:57 -0800 (PST) From: Todd Previte To: intel-gfx@lists.freedesktop.org Date: Wed, 18 Feb 2015 20:00:37 -0700 Message-Id: <1424314837-32434-10-git-send-email-tprevite@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1424314837-32434-1-git-send-email-tprevite@gmail.com> References: <1424314837-32434-1-git-send-email-tprevite@gmail.com> Subject: [Intel-gfx] [PATCH 9/9] drm/i915: Add debugfs write and test param parsing functions 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. V2: - N/A V3: - Removed use of dp_connector_is_valid() - Replaced with DRM connector check to match other functions - Updated the dp_parse_test_ctl function to use the new enums instead of #defines 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 | 105 ++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index 45c0fde..e180813 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c @@ -4073,6 +4073,46 @@ static int dp_parse_config(char *input_buffer, return status; } +static int dp_parse_test_ctl(char *input_buffer, + ssize_t buffer_size, + struct intel_dp *intel_dp) +{ + char *ctrl_lines[DP_CTRL_PARAM_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 = dp_tokenize_config(input_buffer, ctrl_lines); + if (line_count != DP_CTRL_PARAM_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 i915_displayport_config_ctl_show(struct seq_file *m, void *data) { struct drm_device *dev = m->private; @@ -4180,6 +4220,70 @@ static const struct file_operations i915_displayport_config_ctl_fops = { .write = i915_displayport_config_ctl_write }; +static ssize_t i915_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 list_head *connector_list; + struct intel_dp *intel_dp; + + m = file->private_data; + if (!m) { + status = -ENODEV; + return status; + } + dev = m->private; + + if (!dev) { + status = -ENODEV; + return status; + } + connector_list = &dev->mode_config.connector_list; + + 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, connector_list, head) { + + if (connector->connector_type != + DRM_MODE_CONNECTOR_DisplayPort) + continue; + + if (connector->connector_type == + DRM_MODE_CONNECTOR_DisplayPort && + connector->status == connector_status_connected) { + intel_dp = enc_to_intel_dp(connector->encoder); + status = dp_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 int i915_displayport_test_ctl_show(struct seq_file *m, void *data) { struct drm_device *dev = m->private; @@ -4232,6 +4336,7 @@ static int i915_displayport_test_ctl_open(struct inode *inode, static const struct file_operations i915_dp_test_ctl_fops = { .owner = THIS_MODULE, .open = i915_displayport_test_ctl_open, + .write = i915_displayport_test_ctl_write, .read = seq_read, .llseek = seq_lseek, .release = single_release,