drm/edid: Remove arbitrary EDID extension limit
authorAdam Jackson <ajax@redhat.com>
Mon, 29 Mar 2010 21:43:23 +0000 (21:43 +0000)
committerDave Airlie <airlied@redhat.com>
Tue, 6 Apr 2010 00:40:20 +0000 (10:40 +1000)
Signed-off-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/drm_crtc.c
drivers/gpu/drm/drm_edid.c
drivers/gpu/drm/drm_sysfs.c
drivers/gpu/drm/radeon/radeon_combios.c
include/drm/drm_edid.h

index d91fb8c0b7b31673f43b885e8b0c38b0c1b6ec50..aa24f2f9dc0a5141d749c9e5b6ff9ef490e8fc44 100644 (file)
@@ -33,6 +33,7 @@
 #include "drm.h"
 #include "drmP.h"
 #include "drm_crtc.h"
+#include "drm_edid.h"
 
 struct drm_prop_enum_list {
        int type;
@@ -2349,7 +2350,7 @@ int drm_mode_connector_update_edid_property(struct drm_connector *connector,
                                            struct edid *edid)
 {
        struct drm_device *dev = connector->dev;
-       int ret = 0;
+       int ret = 0, size;
 
        if (connector->edid_blob_ptr)
                drm_property_destroy_blob(dev, connector->edid_blob_ptr);
@@ -2361,7 +2362,9 @@ int drm_mode_connector_update_edid_property(struct drm_connector *connector,
                return ret;
        }
 
-       connector->edid_blob_ptr = drm_property_create_blob(connector->dev, 128, edid);
+       size = EDID_LENGTH * (1 + edid->extensions);
+       connector->edid_blob_ptr = drm_property_create_blob(connector->dev,
+                                                           size, edid);
 
        ret = drm_connector_property_set_value(connector,
                                               dev->mode_config.edid_property,
index 58b67932f04a14d8767cc324878a38965be886df..cf24ecab6a4a957e808c529f0eb134850580d895 100644 (file)
@@ -1325,7 +1325,6 @@ static int add_detailed_info_eedid(struct drm_connector *connector,
        int i, modes = 0;
        char *edid_ext = NULL;
        struct detailed_timing *timing;
-       int edid_ext_num;
        int start_offset, end_offset;
        int timing_level;
 
@@ -1342,19 +1341,15 @@ static int add_detailed_info_eedid(struct drm_connector *connector,
                return 0;
        }
 
-       /* Chose real EDID extension number */
-       edid_ext_num = edid->extensions > DRM_MAX_EDID_EXT_NUM ?
-               DRM_MAX_EDID_EXT_NUM : edid->extensions;
-
        /* Find CEA extension */
-       for (i = 0; i < edid_ext_num; i++) {
+       for (i = 0; i < edid->extensions; i++) {
                edid_ext = (char *)edid + EDID_LENGTH * (i + 1);
                /* This block is CEA extension */
                if (edid_ext[0] == 0x02)
                        break;
        }
 
-       if (i == edid_ext_num) {
+       if (i == edid->extensions) {
                /* if there is no additional timing EDID block, return */
                return 0;
        }
@@ -1393,7 +1388,7 @@ static int add_detailed_info_eedid(struct drm_connector *connector,
 bool drm_detect_hdmi_monitor(struct edid *edid)
 {
        char *edid_ext = NULL;
-       int i, hdmi_id, edid_ext_num;
+       int i, hdmi_id;
        int start_offset, end_offset;
        bool is_hdmi = false;
 
@@ -1401,19 +1396,15 @@ bool drm_detect_hdmi_monitor(struct edid *edid)
        if (edid == NULL || edid->extensions == 0)
                goto end;
 
-       /* Chose real EDID extension number */
-       edid_ext_num = edid->extensions > DRM_MAX_EDID_EXT_NUM ?
-                      DRM_MAX_EDID_EXT_NUM : edid->extensions;
-
        /* Find CEA extension */
-       for (i = 0; i < edid_ext_num; i++) {
+       for (i = 0; i < edid->extensions; i++) {
                edid_ext = (char *)edid + EDID_LENGTH * (i + 1);
                /* This block is CEA extension */
                if (edid_ext[0] == 0x02)
                        break;
        }
 
-       if (i == edid_ext_num)
+       if (i == edid->extensions)
                goto end;
 
        /* Data block offset in CEA extension block */
index 014ce24761b98f60b0ed9f8dead7327d2a26f1cf..7b7c83f6041a8a5cf267cd830e40f81cdbc1c9b7 100644 (file)
@@ -332,7 +332,7 @@ static struct device_attribute connector_attrs_opt1[] = {
 static struct bin_attribute edid_attr = {
        .attr.name = "edid",
        .attr.mode = 0444,
-       .size = 128,
+       .size = 0,
        .read = edid_show,
 };
 
index 2becdeda68a34ae4d94d8102f33d0d87fe6de959..20f38b85c70aa2cdf5b5ff7857ef536c860032a6 100644 (file)
@@ -450,17 +450,17 @@ bool radeon_combios_check_hardcoded_edid(struct radeon_device *rdev)
 {
        int edid_info;
        struct edid *edid;
+       unsigned char *raw;
        edid_info = combios_get_table_offset(rdev->ddev, COMBIOS_HARDCODED_EDID_TABLE);
        if (!edid_info)
                return false;
 
-       edid = kmalloc(EDID_LENGTH * (DRM_MAX_EDID_EXT_NUM + 1),
-                      GFP_KERNEL);
+       raw = rdev->bios + edid_info;
+       edid = kmalloc(EDID_LENGTH * (raw[0x7e] + 1), GFP_KERNEL);
        if (edid == NULL)
                return false;
 
-       memcpy((unsigned char *)edid,
-              (unsigned char *)(rdev->bios + edid_info), EDID_LENGTH);
+       memcpy((unsigned char *)edid, raw, EDID_LENGTH * (raw[0x7e] + 1));
 
        if (!drm_edid_is_valid(edid)) {
                kfree(edid);
index b4209898f11526eb33dd39d53d03b92a6da7e1bb..d33c3e038606c1354d671d90a9d3d776d4e225a7 100644 (file)
@@ -201,7 +201,4 @@ struct edid {
 
 #define EDID_PRODUCT_ID(e) ((e)->prod_code[0] | ((e)->prod_code[1] << 8))
 
-/* define the number of Extension EDID block */
-#define DRM_MAX_EDID_EXT_NUM 4
-
 #endif /* __DRM_EDID_H__ */