]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
media: platform: tegra: Dual ov5693 support
authorFrank Chen <frankc@nvidia.com>
Sat, 8 Mar 2014 00:50:56 +0000 (16:50 -0800)
committerMitch Luban <mluban@nvidia.com>
Wed, 19 Mar 2014 23:56:17 +0000 (16:56 -0700)
Update OV5693 driver to support multiple
OV5693 in the same system.

Bug 1465726

Change-Id: Ic23ddbaf80068142e8354f313b76c17a9b2a3b7f
Signed-off-by: Frank Chen <frankc@nvidia.com>
Reviewed-on: http://git-master/r/379242
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Philip Breczinski <pbreczinski@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: David Schalig <dschalig@nvidia.com>
Tested-by: David Schalig <dschalig@nvidia.com>
Reviewed-by: Mitch Luban <mluban@nvidia.com>
drivers/media/platform/tegra/ov5693.c
include/media/nvc_image.h
include/media/ov5693.h

index 2b25c9d840ea47d13808206a31464fc746e0315a..8d9d5e1c6a380aa67729d7fe4d37ebded4393c2d 100644 (file)
@@ -2762,7 +2762,6 @@ static void ov5693_regulator_get(struct ov5693_info *info,
                dev_err(&info->i2c_client->dev, "%s %s ERR: %d\n",
                        __func__, vreg_name, (int)reg);
                err = PTR_ERR(reg);
-               reg = NULL;
        } else {
                dev_dbg(&info->i2c_client->dev, "%s: %s\n",
                        __func__, vreg_name);
@@ -2777,11 +2776,12 @@ static void ov5693_pm_init(struct ov5693_info *info)
 
        ov5693_gpio_init(info);
 
-       ov5693_regulator_get(info, &pw->dvdd, "dvdd");
+       ov5693_regulator_get(info, &pw->avdd, info->pdata->regulators.avdd);
 
-       ov5693_regulator_get(info, &pw->avdd, "avdd_ov5693");
+       ov5693_regulator_get(info, &pw->dvdd, info->pdata->regulators.dvdd);
+
+       ov5693_regulator_get(info, &pw->dovdd, info->pdata->regulators.dovdd);
 
-       ov5693_regulator_get(info, &pw->dovdd, "dovdd");
        info->power_on = false;
 }
 
@@ -3031,6 +3031,32 @@ static long ov5693_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
        int err;
 
        switch (_IOC_NR(cmd)) {
+       case _IOC_NR(OV5693_IOCTL_SET_POWER):
+       {
+               u32 powerlevel = (u32) arg;
+
+               if (!info->pdata)
+                       break;
+               if (powerlevel > NVC_PWR_ON) {
+                       dev_err(&info->i2c_client->dev,
+                               "%s:Invalid power level.\n",
+                       __func__);
+                       return -EFAULT;
+               }
+
+               err = ov5693_pm_wr(info, powerlevel);
+               return err;
+       }
+       case _IOC_NR(OV5693_IOCTL_GET_CAPS):
+               if (copy_to_user((void __user *)arg,
+                                info->pdata->cap,
+                                sizeof(struct nvc_imager_cap))) {
+                       dev_err(&info->i2c_client->dev,
+                               "%s copy_to_user err line %d\n",
+                               __func__, __LINE__);
+                       return -EFAULT;
+               }
+               return 0;
        case _IOC_NR(OV5693_IOCTL_SET_MODE):
        {
                struct ov5693_mode mode;
@@ -3147,6 +3173,9 @@ static long ov5693_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
        case _IOC_NR(OV5693_IOCTL_GET_EEPROM_DATA):
                {
+                       if (!info->pdata->has_eeprom)
+                               return -EFAULT;
+
                        ov5693_read_eeprom(info,
                                0,
                                OV5693_EEPROM_SIZE,
@@ -3165,6 +3194,10 @@ static long ov5693_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
        case _IOC_NR(OV5693_IOCTL_SET_EEPROM_DATA):
                {
                        int i;
+
+                       if (!info->pdata->has_eeprom)
+                               return -EFAULT;
+
                        if (copy_from_user(info->eeprom_buf,
                                (const void __user *)arg, OV5693_EEPROM_SIZE)) {
                                dev_err(&info->i2c_client->dev,
@@ -3219,7 +3252,7 @@ static int ov5693_open(struct inode *inode, struct file *file)
        return err;
 }
 
-int ov5693_release(struct inode *inode, struct file *file)
+static int ov5693_release(struct inode *inode, struct file *file)
 {
        struct ov5693_info *info = file->private_data;
 
@@ -3253,7 +3286,8 @@ static int ov5693_remove(struct i2c_client *client)
        dev_dbg(&info->i2c_client->dev, "%s\n", __func__);
        misc_deregister(&info->miscdev);
        sysedp_free_consumer(info->sysedpc);
-       ov5693_eeprom_device_release(info);
+       if (info->pdata->has_eeprom)
+               ov5693_eeprom_device_release(info);
        ov5693_del(info);
        return 0;
 }
@@ -3445,11 +3479,13 @@ static int ov5693_probe(
                return err;
        }
 
-       err = ov5693_eeprom_device_init(info);
-       if (err) {
-               dev_err(&client->dev,
+       if (info->pdata->has_eeprom) {
+               err = ov5693_eeprom_device_init(info);
+               if (err) {
+                       dev_err(&client->dev,
                        "Failed to allocate eeprom register map: %d\n", err);
-               return err;
+                       return err;
+               }
        }
 
        mclk_name = info->pdata->mclk_name ?
@@ -3463,8 +3499,8 @@ static int ov5693_probe(
 
        i2c_set_clientdata(client, info);
        ov5693_pm_init(info);
-       if (!info->regulators.avdd || !info->regulators.dovdd)
-               return -EFAULT;
+       if (IS_ERR(info->regulators.avdd) || IS_ERR(info->regulators.dovdd))
+                       return -EFAULT;
 
        info->sysedpc = sysedp_create_consumer("ov5693", "ov5693");
 
@@ -3506,6 +3542,7 @@ static int ov5693_probe(
 
 static const struct i2c_device_id ov5693_id[] = {
        { "ov5693", 0 },
+       { "ov5693.1", 0 },
        { },
 };
 
index aa56a4103a551f44182f3a70a38fe9bbf09cd2bf..c9f1286d1db898b8894b4b959b2c38a73c0359c4 100644 (file)
@@ -1,4 +1,5 @@
-/* Copyright (C) 2012 NVIDIA Corporation.
+/*
+ * Copyright (c) 2013-2014, NVIDIA CORPORATION.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -205,7 +206,7 @@ struct nvc_imager_cap {
        __u32 cap_version;
        __u8 flash_control_enabled;
        __u8 adjustable_flash_timing;
-       __u8 align4;
+       __u8 is_hdr;
        __u8 align5;
 } __packed;
 
index 60f06ddddcac80632def8ba562334364d61eb264..877365d6cebd3f577bf4963d1ab6465b225ca11a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (c) 2013-2014, NVIDIA CORPORATION.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -41,6 +41,8 @@
                                                struct ov5693_cal_data)
 #define OV5693_IOCTL_GET_EEPROM_DATA        _IOR('o', 20, __u8 *)
 #define OV5693_IOCTL_SET_EEPROM_DATA        _IOW('o', 21, __u8 *)
+#define OV5693_IOCTL_GET_CAPS               _IOR('o', 22, struct nvc_imager_cap)
+#define OV5693_IOCTL_SET_POWER              _IOW('o', 23, __u32)
 
 #define OV5693_INVALID_COARSE_TIME  -1
 
@@ -113,6 +115,12 @@ struct ov5693_power_rail {
        struct regulator *dovdd;
 };
 
+struct ov5693_regulators {
+       char *avdd;
+       char *dvdd;
+       char *dovdd;
+};
+
 struct ov5693_platform_data {
        unsigned cfg;
        unsigned num;
@@ -129,6 +137,9 @@ struct ov5693_platform_data {
        int (*power_on)(struct ov5693_power_rail *);
        int (*power_off)(struct ov5693_power_rail *);
        const char *mclk_name;
+       struct nvc_imager_cap *cap;
+       struct ov5693_regulators regulators;
+       bool has_eeprom;
 };
 
 #endif  /* __OV5693_H__ */