]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/commitdiff
drivers: camera: Fix Mipi Calibration sequence
authorDavid Bang <dbang@nvidia.com>
Mon, 18 Dec 2017 17:54:12 +0000 (12:54 -0500)
committermobile promotions <svcmobile_promotions@nvidia.com>
Wed, 20 Dec 2017 02:16:51 +0000 (18:16 -0800)
MIPI calibration can happen irrespective of
sensor state by keeping CSI CIL in reset
state. This change adds calibration to complete
when the CSI is powered ON and based on the sensor
settings. By this approach the mipi lanes are
calibrated and are ready as soon as sensor is
turned ON.

Bug 200324656

Change-Id: Id2cd6336395d3a0f0b2637207eb4fdfe6edc3d63
Signed-off-by: David Bang <dbang@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1560331
Reviewed-on: https://git-master.nvidia.com/r/1620523
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bhanu Murthy V <bmurthyv@nvidia.com>
Reviewed-by: Jihoon Bang <jbang@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
drivers/media/platform/tegra/camera/csi/csi.c
drivers/media/platform/tegra/camera/csi/csi.h

index f2bcff1eb08642f05e3207dabe15cddf229fb963..febccc2f8fafdab79967d416f94d2c165c36d474 100644 (file)
@@ -85,15 +85,11 @@ static int tegra_csi_power(struct tegra_csi_device *csi,
        int err = 0;
 
        if (enable) {
-               tegra_mipi_bias_pad_enable();
                err = csi->fops->csi_power_on(csi);
                if (!err)
                        atomic_inc(&csi->power_ref);
-               if (!chan->pg_mode)
-                       csi->fops->mipical(chan);
        } else {
                err = csi->fops->csi_power_off(csi);
-               tegra_mipi_bias_pad_disable();
                if (!err)
                        atomic_dec(&csi->power_ref);
        }
@@ -817,6 +813,33 @@ void tpg_csi_media_controller_cleanup(struct tegra_csi_device *csi)
        csi->tpg_start = NULL;
 }
 EXPORT_SYMBOL(tpg_csi_media_controller_cleanup);
+
+int tegra_csi_mipi_calibrate(struct tegra_csi_device *csi,
+                               bool on)
+{
+       struct tegra_csi_channel *chan;
+
+       if (!on) {
+               tegra_mipi_bias_pad_disable();
+               return 0;
+       }
+
+       tegra_mipi_bias_pad_enable();
+       list_for_each_entry(chan, &csi->csi_chans, list) {
+               int ret = 0;
+
+               if (chan->pg_mode)
+                       continue;
+
+               ret = csi->fops->mipical(chan);
+               if (ret)
+                       dev_err(csi->dev,
+                               "calibration failed with %d error\n", ret);
+       }
+
+       return 0;
+}
+
 int tegra_csi_media_controller_init(struct tegra_csi_device *csi,
                                    struct platform_device *pdev)
 {
index a7c313f65d421f0dece69f89f5109172f143aed6..4611a99d6cdb0c04769dbbf578157c7eeeb9487d 100644 (file)
@@ -151,6 +151,8 @@ void tegra_csi_stop_streaming(struct tegra_csi_channel *chan,
                                enum tegra_csi_port_num port_num);
 void tegra_csi_error_recover(struct tegra_csi_channel *chan,
                                enum tegra_csi_port_num port_num);
+int tegra_csi_mipi_calibrate(struct tegra_csi_device *csi,
+                               bool on);
 int tegra_csi_init(struct tegra_csi_device *csi,
                struct platform_device *pdev);
 int tegra_csi_media_controller_init(struct tegra_csi_device *csi,