From: Thomas Wood <thomas.wood@intel.com>
To: dri-devel@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org
Subject: [PATCH 3/3] drm/debugfs: add an "edid_override" file per connector
Date: Thu, 29 May 2014 16:57:43 +0100 [thread overview]
Message-ID: <1401379063-15375-4-git-send-email-thomas.wood@intel.com> (raw)
In-Reply-To: <1401379063-15375-1-git-send-email-thomas.wood@intel.com>
Add a file to debugfs for each connector that allows the edid data to be
overridden.
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
---
drivers/gpu/drm/drm_crtc.c | 4 +++
drivers/gpu/drm/drm_debugfs.c | 56 ++++++++++++++++++++++++++++++++++++++
drivers/gpu/drm/drm_probe_helper.c | 9 +++++-
include/drm/drm_crtc.h | 1 +
4 files changed, 69 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 59a2784..8543eac 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -3701,6 +3701,10 @@ int drm_mode_connector_update_edid_property(struct drm_connector *connector,
struct drm_device *dev = connector->dev;
int ret, size;
+ /* ignore requests to set edid when overridden */
+ if (connector->override_edid)
+ return 0;
+
if (connector->edid_blob_ptr)
drm_property_destroy_blob(dev, connector->edid_blob_ptr);
diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index b57b614..2c666ba 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -35,6 +35,7 @@
#include <linux/slab.h>
#include <linux/export.h>
#include <drm/drmP.h>
+#include <drm/drm_edid.h>
#if defined(CONFIG_DEBUG_FS)
@@ -295,6 +296,55 @@ static ssize_t connector_write(struct file *file, const char __user *ubuf,
return len;
}
+static int edid_show(struct seq_file *m, void *data)
+{
+ struct drm_connector *connector = m->private;
+ struct drm_property_blob *edid = connector->edid_blob_ptr;
+
+ if (connector->override_edid && edid)
+ seq_write(m, edid->data, edid->length);
+
+ return 0;
+}
+
+static int edid_open(struct inode *inode, struct file *file)
+{
+ struct drm_connector *dev = inode->i_private;
+
+ return single_open(file, edid_show, dev);
+}
+
+static ssize_t edid_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 (len >= EDID_LENGTH) {
+ drm_mode_connector_update_edid_property(connector,
+ (struct edid *) ubuf);
+ connector->override_edid = true;
+ } else {
+ if (connector->override_edid) {
+ connector->override_edid = false;
+ drm_mode_connector_update_edid_property(connector,
+ NULL);
+ }
+ }
+
+ return len;
+}
+
+static const struct file_operations drm_edid_fops = {
+ .owner = THIS_MODULE,
+ .open = edid_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+ .write = edid_write
+};
+
+
static const struct file_operations drm_connector_fops = {
.owner = THIS_MODULE,
.open = connector_open,
@@ -325,6 +375,12 @@ int drm_debugfs_connector_add(struct drm_connector *connector)
if (!ent)
return -ENOMEM;
+ /* edid */
+ ent = debugfs_create_file("edid_override", S_IRUGO, root, connector,
+ &drm_edid_fops);
+ if (!ent)
+ return -ENOMEM;
+
return 0;
}
diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c
index 79f07f2..1f0dc77 100644
--- a/drivers/gpu/drm/drm_probe_helper.c
+++ b/drivers/gpu/drm/drm_probe_helper.c
@@ -130,7 +130,14 @@ static int drm_helper_probe_single_connector_modes_merge_bits(struct drm_connect
count = drm_load_edid_firmware(connector);
if (count == 0)
#endif
- count = (*connector_funcs->get_modes)(connector);
+ {
+ if (connector->override_edid) {
+ struct edid *edid = (struct edid *) connector->edid_blob_ptr->data;
+
+ count = drm_add_edid_modes(connector, edid);
+ } else
+ count = (*connector_funcs->get_modes)(connector);
+ }
if (count == 0 && connector->status == connector_status_connected)
count = drm_add_modes_noedid(connector, 1024, 768);
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index f04f4b9..11fce43 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -513,6 +513,7 @@ struct drm_connector {
/* forced on connector */
enum drm_connector_force force;
+ bool override_edid;
uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER];
struct drm_encoder *encoder; /* currently active encoder */
--
1.9.0
next prev parent reply other threads:[~2014-05-29 15:57 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-29 15:57 [PATCH 0/3] connector debugfs properties Thomas Wood
2014-05-29 15:57 ` [PATCH 1/3] drm: add register and unregister functions for connectors Thomas Wood
2014-06-10 16:21 ` David Herrmann
2014-06-19 6:57 ` Daniel Vetter
2014-05-29 15:57 ` [PATCH 2/3] drm/debugfs: add a "force" file per connector Thomas Wood
2014-06-10 16:36 ` David Herrmann
2014-06-18 16:52 ` [PATCH v2 0/2] connector debugfs properties Thomas Wood
2014-06-18 16:52 ` [PATCH v2 1/2] drm/debugfs: add a "force" file per connector Thomas Wood
2014-06-18 20:11 ` Alex Deucher
2014-06-18 16:52 ` [PATCH v2 2/2] drm/debugfs: add an "edid_override" " Thomas Wood
2014-06-18 19:37 ` Alex Deucher
2014-06-18 20:08 ` [Intel-gfx] " Daniel Vetter
2014-05-29 15:57 ` Thomas Wood [this message]
2014-06-10 16:58 ` [PATCH 3/3] " David Herrmann
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=1401379063-15375-4-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