]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
media: video: tegra: AD5820: fix i2c_wr byte order
authorCharlie Huang <chahuang@nvidia.com>
Fri, 9 Dec 2011 22:49:21 +0000 (14:49 -0800)
committerDan Willemsen <dwillemsen@nvidia.com>
Sat, 14 Sep 2013 08:03:43 +0000 (01:03 -0700)
The byte order in the reg_write call was swapped.
Also updates the mode truth table so focuser can choose one
to work on.
Corrects the position range and set the settle time dependents
on the transition mode.

bug 909072

Change-Id: I91fffbe4810b86883f934b08a4fdbc3284efd652
Signed-off-by: Charlie Huang <chahuang@nvidia.com>
Reviewed-on: http://git-master/r/69279
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Gary Zhang <garyz@nvidia.com>
Reviewed-by: Naren Bhat <nbhat@nvidia.com>
Reviewed-by: Erik Lilliebjerg <elilliebjerg@nvidia.com>
Reviewed-by: Jon Mayo <jmayo@nvidia.com>
Rebase-Id: R1944bafa368c918da17c9e7e1b160d8e3a456b83

drivers/media/video/tegra/ad5820.c

index 906a732200341831a72e3e01ccade9d40a2e1a18..f5169e6a59f929c25b88003a822079240b4bfb24 100644 (file)
 
 #include <media/ad5820.h>
 
-#define POS_LOW (144)
-#define POS_HIGH (520)
-#define SETTLETIME_MS 100
+/* Focuser single step & full scale transition time truth table
+ * in the format of:
+ *   index     mode            single step transition  full scale transition
+ *     0       0                       0                       0
+ *     1       1                       50uS                    51.2mS
+ *     2       1                       100uS                   102.3mS
+ *     3       1                       200uS                   204.6mS
+ *     4       1                       400uS                   409.2mS
+ *     5       1                       800uS                   818.4mS
+ *     6       1                       1600uS                  1636.8mS
+ *     7       1                       3200uS                  3273.6mS
+ *     8       0                       0                       0
+ *     9       2                       50uS                    1.1mS
+ *     A       2                       100uS                   2.2mS
+ *     B       2                       200uS                   4.4mS
+ *     C       2                       400uS                   8.8mS
+ *     D       2                       800uS                   17.6mS
+ *     E       2                       1600uS                  35.2mS
+ *     F       2                       3200uS                  70.4mS
+ */
+
+/* pick up the mode index setting and its settle time from the above table */
+#define AD5820_TRANSITION_MODE 0x0B
+#define SETTLETIME_MS 5
+
+#define POS_LOW (0)
+#define POS_HIGH (1023)
 #define FOCAL_LENGTH (4.507f)
 #define FNUMBER (2.8f)
 #define FPOS_COUNT 1024
 
-#define AD5820_MAX_RETRIES (3)
-
 struct ad5820_info {
        struct i2c_client *i2c_client;
        struct regulator *regulator;
        struct ad5820_config config;
 };
 
-static int ad5820_write(struct i2c_client *client, u16 value)
+static int ad5820_write(struct i2c_client *client, u32 value)
 {
        int count;
        struct i2c_msg msg[1];
        unsigned char data[2];
-       int retry = 0;
 
        if (!client->adapter)
                return -ENODEV;
 
-       data[1] = (u8) ((value >> 4) & 0x3F);
-       data[0] = (u8) ((value & 0xF) << 4);
+       data[0] = (u8) ((value >> 4) & 0x3F);
+       data[1] = (u8) ((value & 0xF) << 4) | AD5820_TRANSITION_MODE;
 
        msg[0].addr = client->addr;
        msg[0].flags = 0;
        msg[0].len = ARRAY_SIZE(data);
        msg[0].buf = data;
 
-       do {
-               count = i2c_transfer(client->adapter, msg, ARRAY_SIZE(msg));
-               if (count == ARRAY_SIZE(msg))
-                       return 0;
-               retry++;
-               pr_err("ad5820: i2c transfer failed, retrying %x\n",
-                      value);
-               msleep(3);
-       } while (retry <= AD5820_MAX_RETRIES);
+       count = i2c_transfer(client->adapter, msg, ARRAY_SIZE(msg));
+       if (count == ARRAY_SIZE(msg))
+               return 0;
+
        return -EIO;
 }