video: tegra: camera: Change max_lane_speed to u64
Sudhir Vyas [Tue, 15 Sep 2015 13:27:01 +0000 (18:27 +0530)]
* Fix u32 range overflow.
When max_lane_speed multiplied to other u32 CSI
caps params, the output does not fit to u32 range.

* Correct lane-speed defines' base.

Bug 200133567

Change-Id: I9f40d7c747b217f072ac7a876f46153d1dec392b
Signed-off-by: Sudhir Vyas <svyas@nvidia.com>
Reviewed-on: http://git-master/r/799412
(cherry picked from commit 911dfa298ae20b0c65a3daebdef1a0828c3e4aa3)
Reviewed-on: http://git-master/r/820663
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Charles Kong <charlesk@nvidia.com>
Reviewed-by: David Schalig <dschalig@nvidia.com>
Tested-by: David Schalig <dschalig@nvidia.com>
Reviewed-by: Joshua Widen <jwiden@nvidia.com>
Tested-by: Joshua Widen <jwiden@nvidia.com>
Reviewed-by: Jihoon Bang <jbang@nvidia.com>
Reviewed-by: Todd Poynter <tpoynter@nvidia.com>

drivers/video/tegra/camera/tegra_camera_platform.c

index 26897d1..0531068 100644 (file)
@@ -28,8 +28,8 @@
 /* Peak BPP for any of the YUV/Bayer formats */
 #define CAMERA_PEAK_BPP 2
 
-#define LANE_SPEED_1_GBPS 0x40000000
-#define LANE_SPEED_1_5_GBPS 0x60000000
+#define LANE_SPEED_1_GBPS 1000000000
+#define LANE_SPEED_1_5_GBPS 1500000000
 
 static const struct of_device_id tegra_camera_of_ids[] = {
        { .compatible = "nvidia, tegra-camera-platform" },
@@ -43,7 +43,7 @@ static int tegra_camera_isomgr_register(struct tegra_camera_info *info)
 #if defined(CONFIG_TEGRA_ISOMGR)
        u32 num_csi_lanes;
        u32 max_num_streams;
-       u32 max_lane_speed;
+       u64 max_lane_speed;
        u32 min_bits_per_pixel;
 
        dev_dbg(info->dev, "%s++\n", __func__);
@@ -84,6 +84,13 @@ static int tegra_camera_isomgr_register(struct tegra_camera_info *info)
         */
        info->max_bw = (((num_csi_lanes * max_lane_speed * max_num_streams) /
                                min_bits_per_pixel) * CAMERA_PEAK_BPP) / 1000;
+       if (!info->max_bw) {
+               dev_err(info->dev, "%s: BW must be non-zero\n", __func__);
+               return -EINVAL;
+       }
+
+       dev_info(info->dev, "%s camera's max_iso_bw %llu\n",
+                               __func__, info->max_bw);
 
        /* Register with max possible BW for CAMERA usecases.*/
        info->isomgr_handle = tegra_isomgr_register(
@@ -92,7 +99,7 @@ static int tegra_camera_isomgr_register(struct tegra_camera_info *info)
                                        NULL,   /* tegra_isomgr_renegotiate */
                                        NULL);  /* *priv */
 
-       if (!info->isomgr_handle) {
+       if (IS_ERR(info->isomgr_handle)) {
                dev_err(info->dev,
                        "%s: unable to register to isomgr\n",
                                __func__);
@@ -342,7 +349,8 @@ static int tegra_camera_probe(struct platform_device *pdev)
 
        ret = misc_register(&tegra_camera_misc);
        if (ret) {
-               dev_err(tegra_camera_misc.this_device, "register failed for %s\n",
+               dev_err(tegra_camera_misc.this_device,
+                       "register failed for %s\n",
                        tegra_camera_misc.name);
                return ret;
        }
@@ -355,6 +363,8 @@ static int tegra_camera_probe(struct platform_device *pdev)
                return -ENOMEM;
        }
 
+       memset(info, 0, sizeof(*info));
+
        strcpy(info->devname, tegra_camera_misc.name);
        info->dev = tegra_camera_misc.this_device;