public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Thomas Wood <thomas.wood@intel.com>
To: dri-devel@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org
Subject: [PATCH] drm/sysfs: expose the "force" connector attribute
Date: Mon, 19 May 2014 14:37:00 +0100	[thread overview]
Message-ID: <1400506620-12509-1-git-send-email-thomas.wood@intel.com> (raw)

Signed-off-by: Thomas Wood <thomas.wood@intel.com>
---
 drivers/gpu/drm/drm_sysfs.c | 49 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index c22c309..257816e 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -338,11 +338,60 @@ static ssize_t select_subconnector_show(struct device *device,
 			drm_get_dvi_i_select_name((int)subconnector));
 }
 
+static ssize_t force_show(struct device *device,
+			  struct device_attribute *attr,
+			  char *buf)
+{
+	struct drm_connector *connector = to_drm_connector(device);
+	char *status;
+
+	switch (connector->force) {
+	case DRM_FORCE_ON:
+		status = "on";
+		break;
+
+	case DRM_FORCE_ON_DIGITAL:
+		status = "digital";
+		break;
+
+	case DRM_FORCE_OFF:
+		status = "off";
+		break;
+
+	case DRM_FORCE_UNSPECIFIED:
+		status = "unspecified";
+		break;
+
+	default:
+		return 0;
+	}
+
+	return snprintf(buf, PAGE_SIZE, "%s\n", status);
+}
+
+ssize_t force_store(struct device *device, struct device_attribute *attr,
+		    const char *buf, size_t count)
+{
+	struct drm_connector *connector = to_drm_connector(device);
+
+	if (strcmp(buf, "on") == 0)
+		connector->force = DRM_FORCE_ON;
+	else if (strcmp(buf, "digital") == 0)
+		connector->force = DRM_FORCE_ON_DIGITAL;
+	else if (strcmp(buf, "off") == 0)
+		connector->force = DRM_FORCE_OFF;
+	else if (strcmp(buf, "unspecified") == 0)
+		connector->force = DRM_FORCE_UNSPECIFIED;
+
+	return count;
+}
+
 static struct device_attribute connector_attrs[] = {
 	__ATTR_RO(status),
 	__ATTR_RO(enabled),
 	__ATTR_RO(dpms),
 	__ATTR_RO(modes),
+	__ATTR_RW(force),
 };
 
 /* These attributes are for both DVI-I connectors and all types of tv-out. */
-- 
1.9.0

             reply	other threads:[~2014-05-19 13:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-19 13:37 Thomas Wood [this message]
2014-05-19 14:13 ` [PATCH] drm/sysfs: expose the "force" connector attribute David Herrmann
2014-05-19 14:41   ` Thomas Wood
2014-05-19 14:44     ` David Herrmann
2014-05-19 14:53       ` Daniel Vetter
2014-05-19 16:22         ` David Herrmann
2014-05-19 17:30           ` Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1400506620-12509-1-git-send-email-thomas.wood@intel.com \
    --to=thomas.wood@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox