video: tegra: edid: Verify checksum of edid
Mike J. Chen [Tue, 1 Oct 2013 01:36:19 +0000 (18:36 -0700)]
We've seen invalid edid reads and should retry instead
of using it.

Change-Id: I7d74a41f702be02464c7f43904805142153d4da0
Signed-off-by: Mike J. Chen <mjchen@google.com>
Signed-off-by: Jon Mayo <jmayo@nvidia.com>
Reviewed-on: http://git-master/r/301312
Reviewed-by: Xue Dong <xdong@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit

drivers/video/tegra/dc/edid.c

index a56b6ac..1a9b764 100644 (file)
@@ -148,6 +148,8 @@ int tegra_edid_read_block(struct tegra_edid *edid, int block, u8 *data)
        u8 block_buf[] = {block >> 1};
        u8 cmd_buf[] = {(block & 0x1) * 128};
        int status;
+       u8 checksum = 0;
+       u8 i;
        struct i2c_msg msg[] = {
                {
                        .addr = 0x30,
@@ -186,6 +188,13 @@ int tegra_edid_read_block(struct tegra_edid *edid, int block, u8 *data)
        if (status != msg_len)
                return -EIO;
 
+       for (i = 0; i < 128; i++)
+               checksum += data[i];
+       if (checksum != 0) {
+               pr_err("%s: checksum failed\n", __func__);
+               return -EIO;
+       }
+
        return 0;
 }
 
@@ -468,7 +477,7 @@ int tegra_edid_get_monspecs(struct tegra_edid *edid, struct fb_monspecs *specs)
        for (i = 1; i <= extension_blocks; i++) {
                ret = tegra_edid_read_block(edid, i, data + i * 128);
                if (ret < 0)
-                       break;
+                       goto fail;
 
                if (data[i * 128] == 0x2) {
                        fb_edid_add_monspecs(data + i * 128, specs);