video: tegra: use longer retries for hdcp
authorJon Mayo <jmayo@nvidia.com>
Wed, 6 Apr 2011 20:15:20 +0000 (13:15 -0700)
committerErik Gilling <konkers@android.com>
Thu, 7 Apr 2011 21:29:33 +0000 (14:29 -0700)
use 3 seconds for i2c/ddc failures on hdcp (15 attempts at 250mS each)

Change-Id: Ia755c9b42d5a0d8467b68c9d334638bcb015eabd
Signed-off-by: Erik Gilling <konkers@android.com>
drivers/video/tegra/dc/nvhdcp.c

index fe8beb97c38ab3e565dd62e75d94f9f7d790e87d..2229c6b93ad30d58d488c2f0ee693bd574c94658 100644 (file)
@@ -116,6 +116,7 @@ static int nvhdcp_i2c_read(struct tegra_nvhdcp *nvhdcp, u8 reg,
                                        size_t len, void *data)
 {
        int status;
+       int retries = 15;
        struct i2c_msg msg[] = {
                {
                        .addr = 0x74 >> 1, /* primary link */
@@ -131,7 +132,16 @@ static int nvhdcp_i2c_read(struct tegra_nvhdcp *nvhdcp, u8 reg,
                },
        };
 
-       status = i2c_transfer(nvhdcp->client->adapter, msg, ARRAY_SIZE(msg));
+       do {
+               if (!nvhdcp_is_plugged(nvhdcp)) {
+                       nvhdcp_err("disconnect during i2c xfer\n");
+                       return -EIO;
+               }
+               status = i2c_transfer(nvhdcp->client->adapter,
+                       msg, ARRAY_SIZE(msg));
+               if (retries > 1)
+                       msleep(250);
+       } while ((status < 0) && retries--);
 
        if (status < 0) {
                nvhdcp_err("i2c xfer error %d\n", status);
@@ -154,11 +164,21 @@ static int nvhdcp_i2c_write(struct tegra_nvhdcp *nvhdcp, u8 reg,
                        .buf = buf,
                },
        };
+       int retries = 15;
 
        buf[0] = reg;
        memcpy(buf + 1, data, len);
 
-       status = i2c_transfer(nvhdcp->client->adapter, msg, ARRAY_SIZE(msg));
+       do {
+               if (!nvhdcp_is_plugged(nvhdcp)) {
+                       nvhdcp_err("disconnect during i2c xfer\n");
+                       return -EIO;
+               }
+               status = i2c_transfer(nvhdcp->client->adapter,
+                       msg, ARRAY_SIZE(msg));
+               if (retries > 1)
+                       msleep(250);
+       } while ((status < 0) && retries--);
 
        if (status < 0) {
                nvhdcp_err("i2c xfer error %d\n", status);
@@ -320,16 +340,7 @@ static inline int get_receiver_ri(struct tegra_nvhdcp *nvhdcp, u16 *r)
 
 static int get_bcaps(struct tegra_nvhdcp *nvhdcp, u8 *b_caps)
 {
-       int e, retries = 4;
-       do {
-               e = nvhdcp_i2c_read8(nvhdcp, 0x40, b_caps);
-               if (!e)
-                       return 0;
-               if (retries > 1)
-                       msleep(100);
-       } while (--retries);
-
-       return -EIO;
+       return nvhdcp_i2c_read8(nvhdcp, 0x40, b_caps);
 }
 
 static int get_ksvfifo(struct tegra_nvhdcp *nvhdcp,