edid override: make edid writable in sysfs
Subsystems (2)
PATCH 3/3 edid override: make edid writable in sysfs
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>
---
drivers/gpu/drm/drm_sysfs.c +42 -1
@@ -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 *fireturn 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 connectorstatic struct bin_attribute edid_attr = { .attr.name ="edid" , - .attr.mode =0444 , + .attr.mode =0644 , .size =0 , .read = edid_show, + .write = edid_override, };/**
---