From patchwork Thu May 29 15:57:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Wood X-Patchwork-Id: 4266051 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EA3DFBEEA7 for ; Thu, 29 May 2014 15:57:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F26CA20353 for ; Thu, 29 May 2014 15:57:52 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 02C7F202F8 for ; Thu, 29 May 2014 15:57:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 988F46E9DC; Thu, 29 May 2014 08:57:51 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wg0-f50.google.com (mail-wg0-f50.google.com [74.125.82.50]) by gabe.freedesktop.org (Postfix) with ESMTP id 39C706E9DA for ; Thu, 29 May 2014 08:57:49 -0700 (PDT) Received: by mail-wg0-f50.google.com with SMTP id x12so638225wgg.9 for ; Thu, 29 May 2014 08:57:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=O+vhAEB0uZUPROu1vY+2UA6amGEYZu6Yc4SR840PGyI=; b=SXqaq6W6d/olOLuDa1zwG7VKgltb7ZGJJ2UzFCZf/SRBI1RenKJgvEGlTQ8aRW+SXB SJ5at/ycFV8Mlvz1szmBvrmy0lVe3BYh2cYzXfOH/oP/FNQU5uKpZlB/q8GJrP2oRAxV BMNMDPCH/j5rerMS8rqIK77fJg8hTYLc+UMZmoi49BhXXEjWF02dUi6+FX8ekjSSS0gm CGmuAmN8pKo6teLVJnttCySEauzcyW2hvUY9zKxYi4YJg7OPlBPmr7R3MHaUNoyZr39G TaN2FsDehiuHeOG/nbYHuY/3mx/3M5f7qzqgoMCvYrNiiklShdEb7FmU2/55iOLLSQ0J 4rKg== X-Gm-Message-State: ALoCoQkHxb0RFbo2PhPy5i4C2hgXdz+R5wJKcRf08Hd37Zpqg7MD2W3u3ThN836za0E+qzc1Bwkh X-Received: by 10.194.216.40 with SMTP id on8mr11993021wjc.66.1401379068453; Thu, 29 May 2014 08:57:48 -0700 (PDT) Received: from pistachio.icx.intel.com ([83.217.123.106]) by mx.google.com with ESMTPSA id ej2sm2702468wjd.21.2014.05.29.08.57.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 May 2014 08:57:47 -0700 (PDT) From: Thomas Wood To: dri-devel@lists.freedesktop.org Date: Thu, 29 May 2014 16:57:42 +0100 Message-Id: <1401379063-15375-3-git-send-email-thomas.wood@intel.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1401379063-15375-1-git-send-email-thomas.wood@intel.com> References: <1401379063-15375-1-git-send-email-thomas.wood@intel.com> Cc: intel-gfx@lists.freedesktop.org Subject: [Intel-gfx] [PATCH 2/3] drm/debugfs: add a "force" file per connector X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 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.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 Add a file to debugfs for each connector to enable modification of the "force" connector attribute. This allows connectors to be enabled or disabled for testing and debugging purposes. Signed-off-by: Thomas Wood --- drivers/gpu/drm/drm_crtc.c | 17 ++++++- drivers/gpu/drm/drm_debugfs.c | 101 ++++++++++++++++++++++++++++++++++++++++++ include/drm/drmP.h | 11 +++++ include/drm/drm_crtc.h | 2 + 4 files changed, 130 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 998663c..59a2784 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -841,6 +841,8 @@ int drm_connector_init(struct drm_device *dev, drm_object_attach_property(&connector->base, dev->mode_config.dpms_property, 0); + connector->debugfs_entry = NULL; + out_put: if (ret) drm_mode_object_put(dev, &connector->base); @@ -891,7 +893,19 @@ EXPORT_SYMBOL(drm_connector_cleanup); */ int drm_connector_register(struct drm_connector *connector) { - return drm_sysfs_connector_add(connector); + int ret; + + ret = drm_sysfs_connector_add(connector); + if (ret != 0) + return ret; + + ret = drm_debugfs_connector_add(connector); + if (ret != 0) { + drm_sysfs_connector_remove(connector); + return ret; + } + + return 0; } EXPORT_SYMBOL(drm_connector_register); @@ -904,6 +918,7 @@ EXPORT_SYMBOL(drm_connector_register); void drm_connector_unregister(struct drm_connector *connector) { drm_sysfs_connector_remove(connector); + drm_debugfs_connector_remove(connector); } EXPORT_SYMBOL(drm_connector_unregister); diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c index b4b51d4..b57b614 100644 --- a/drivers/gpu/drm/drm_debugfs.c +++ b/drivers/gpu/drm/drm_debugfs.c @@ -237,5 +237,106 @@ int drm_debugfs_cleanup(struct drm_minor *minor) return 0; } +static int connector_show(struct seq_file *m, void *data) +{ + struct drm_connector *connector = m->private; + const char *status; + + switch (connector->force) { + case DRM_FORCE_ON: + status = "on\n"; + break; + + case DRM_FORCE_ON_DIGITAL: + status = "digital\n"; + break; + + case DRM_FORCE_OFF: + status = "off\n"; + break; + + case DRM_FORCE_UNSPECIFIED: + status = "unspecified\n"; + break; + + default: + return 0; + } + + seq_puts(m, status); + + return 0; +} + +static int connector_open(struct inode *inode, struct file *file) +{ + struct drm_connector *dev = inode->i_private; + + return single_open(file, connector_show, dev); +} + +static ssize_t connector_write(struct file *file, const char __user *ubuf, + size_t len, loff_t *offp) +{ + struct seq_file *m = file->private_data; + struct drm_connector *connector = m->private; + + if (strncmp(ubuf, "on", len) == 0) + connector->force = DRM_FORCE_ON; + else if (strncmp(ubuf, "digital", len) == 0) + connector->force = DRM_FORCE_ON_DIGITAL; + else if (strncmp(ubuf, "off", len) == 0) + connector->force = DRM_FORCE_OFF; + else if (strncmp(ubuf, "unspecified", len) == 0) + connector->force = DRM_FORCE_UNSPECIFIED; + else + return -EINVAL; + + return len; +} + +static const struct file_operations drm_connector_fops = { + .owner = THIS_MODULE, + .open = connector_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, + .write = connector_write +}; + +int drm_debugfs_connector_add(struct drm_connector *connector) +{ + struct drm_minor *minor = connector->dev->primary; + struct dentry *root, *ent; + + if (!minor->debugfs_root) + return -1; + + root = debugfs_create_dir(drm_get_connector_name(connector), + minor->debugfs_root); + if (!root) + return -ENOMEM; + + connector->debugfs_entry = root; + + /* force */ + ent = debugfs_create_file("force", S_IRUGO, root, connector, + &drm_connector_fops); + if (!ent) + return -ENOMEM; + + return 0; +} + +void drm_debugfs_connector_remove(struct drm_connector *connector) +{ + if (!connector->debugfs_entry) + return; + + debugfs_remove_recursive(connector->debugfs_entry); + + connector->debugfs_entry = NULL; +} + #endif /* CONFIG_DEBUG_FS */ diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 76ccaab..c6c85f7 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -1425,6 +1425,8 @@ extern int drm_debugfs_create_files(const struct drm_info_list *files, extern int drm_debugfs_remove_files(const struct drm_info_list *files, int count, struct drm_minor *minor); extern int drm_debugfs_cleanup(struct drm_minor *minor); +extern int drm_debugfs_connector_add(struct drm_connector *connector); +extern void drm_debugfs_connector_remove(struct drm_connector *connector); #else static inline int drm_debugfs_init(struct drm_minor *minor, int minor_id, struct dentry *root) @@ -1449,6 +1451,15 @@ static inline int drm_debugfs_cleanup(struct drm_minor *minor) { return 0; } + +static inline int drm_debugfs_connector_add(struct drm_connector *connector) +{ + return 0; +} +static inline void drm_debugfs_connector_remove(struct drm_connector *connector) +{ +} + #endif /* Info file support */ diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 51e6255..f04f4b9 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -525,6 +525,8 @@ struct drm_connector { int audio_latency[2]; int null_edid_counter; /* needed to workaround some HW bugs where we get all 0s */ unsigned bad_edid_counter; + + struct dentry *debugfs_entry; }; /**