[Patch 3/3] edid override: make edid writable in sysfs
Thorsten Schoel
tschoel at web.de
Tue Apr 24 01:49:49 PDT 2012
From: Thorsten Schoel <tschoel at web.de>
Makes class/drm/[CONNECTOR]/edid writable for adding edid overrides.
Signed-off-by: Thorsten Schoel <tschoel at web.de>
---
diff -Nurp infra/drivers/gpu/drm/drm_sysfs.c sysfs/drivers/gpu/drm/drm_sysfs.c
--- infra/drivers/gpu/drm/drm_sysfs.c 2012-01-12 20:42:45.000000000 +0100
+++ sysfs/drivers/gpu/drm/drm_sysfs.c 2012-01-25 22:13:08.000000000 +0100
@@ -21,6 +21,8 @@
#include "drm_sysfs.h"
#include "drm_core.h"
#include "drmP.h"
+#include "drm_edid.h"
+#include "drm_crtc.h"
#define to_drm_minor(d) container_of(d, struct drm_minor, kdev)
#define to_drm_connector(d) container_of(d, struct drm_connector, kdev)
@@ -228,6 +230,44 @@ static ssize_t edid_show(struct file *fi
return count;
}
+static ssize_t edid_override(struct file *filp, struct kobject *kobj,
+ struct bin_attribute *attr, char *buf, loff_t off,
+ size_t count)
+{
+ struct device *connector_dev = container_of(kobj, struct device, kobj);
+ struct drm_connector *connector = to_drm_connector(connector_dev);
+ char *connector_name;
+ unsigned char *edid_new;
+
+ connector_name = drm_get_connector_name(connector);
+
+ if (!count) {
+ drm_edid_override_remove(connector_name);
+ return 0;
+ }
+
+ /* Only support writing the whole EDID in one piece */
+ if (off)
+ return 0;
+
+ if (count < EDID_LENGTH)
+ return 0;
+ if (count != (buf[0x7e] + 1) * EDID_LENGTH)
+ return 0;
+
+ edid_new = kmalloc(count, GFP_KERNEL);
+ if (!edid_new)
+ return 0;
+
+ memcpy(edid_new, buf, count);
+
+ if (drm_edid_override_set(connector_name, (struct edid *)edid_new) < 0)
+ count = 0;
+
+ kfree(edid_new);
+ return count;
+}
+
static ssize_t modes_show(struct device *device,
struct device_attribute *attr,
char *buf)
@@ -341,9 +381,10 @@ static struct device_attribute connector
static struct bin_attribute edid_attr = {
.attr.name = "edid",
- .attr.mode = 0444,
+ .attr.mode = 0644,
.size = 0,
.read = edid_show,
+ .write = edid_override,
};
/**
---
More information about the dri-devel
mailing list