]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
video: tegra: camera: set latency allowance value
authorJihoon Bang <jbang@nvidia.com>
Sat, 15 Jun 2013 01:19:15 +0000 (18:19 -0700)
committerDan Willemsen <dwillemsen@nvidia.com>
Sat, 14 Sep 2013 20:31:23 +0000 (13:31 -0700)
Set VI latency allowance based on VI clock frequency.
It used to be fixed value regardless of VI clock frequency.

Bug 1305215

Change-Id: Iabda5221f40b44ff31ebf8d6ca08a281b8f6f127
Reviewed-on: http://git-master/r/239090
(cherry picked from commit 102b7ba52b5ffcadf226c4908796063743f989ea)
Signed-off-by: Jihoon Bang <jbang@nvidia.com>
Reviewed-on: http://git-master/r/248041
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Krishna Reddy <vdumpa@nvidia.com>
drivers/video/tegra/camera/camera_clk.c
drivers/video/tegra/camera/camera_clk.h

index bb4c9511f3a9f636ffb9362239dcb88382d2274b..1584bf62ce1c8c5ac3d60889d4628c1d1e9e5c46 100644 (file)
  *
  */
 
+#include <mach/latency_allowance.h>
 #include "camera_clk.h"
 #include "camera_emc.h"
 
+#define BPP_YUV422 16UL
+#define BPP_YUV420_Y 8UL
+#define BPP_YUV420_U 2UL
+#define BPP_YUV420_V 2UL
+
 int tegra_camera_enable_clk(struct tegra_camera *camera)
 {
        int i;
@@ -38,7 +44,7 @@ int tegra_camera_disable_clk(struct tegra_camera *camera)
 }
 
 int tegra_camera_init_clk(struct tegra_camera *camera,
-               struct clock_data *clock_init)
+       struct clock_data *clock_init)
 {
        int i;
        for (i = 0; i < CAMERA_CLK_MAX; i++) {
@@ -212,6 +218,7 @@ int tegra_camera_clk_set_rate(struct tegra_camera *camera)
                        tegra_clk_cfg_ex(camera->clock[CAMERA_PLL_D2_CLK].clk,
                                                TEGRA_CLK_PLLD_DSI_OUT_ENB, 0);
                }
+               tegra_camera_set_latency_allowance(camera, parent_div_rate_pre);
 #endif
        }
 
@@ -243,3 +250,28 @@ unsigned int tegra_camera_get_max_bw(struct tegra_camera *camera)
 
        return (unsigned int)max_bw;
 }
+
+int tegra_camera_set_latency_allowance(struct tegra_camera *camera,
+       unsigned long vi_freq)
+{
+       /*
+        * Assumption is that preview port has YUV422 and video port has
+        * YUV420. Preview port may have Bayer format which has 10 bit per
+        * pixel. Even if preview port has Bayer format, setting latency
+        * allowance with YUV422 format should be OK because BPP of YUV422 is
+        * higher than BPP of Bayer.
+        * When this function gets called, video format is not programmed yet.
+        * That's why we have to assume video format here rather than reading
+        * them from registers.
+        */
+       tegra_set_latency_allowance(TEGRA_LA_VI_WSB,
+               ((vi_freq / 1000000UL) * BPP_YUV422) / 8UL);
+       tegra_set_latency_allowance(TEGRA_LA_VI_WU,
+               ((vi_freq / 1000000UL) * BPP_YUV420_U) / 8UL);
+       tegra_set_latency_allowance(TEGRA_LA_VI_WV,
+               ((vi_freq / 1000000UL) * BPP_YUV420_V) / 8UL);
+       tegra_set_latency_allowance(TEGRA_LA_VI_WY,
+               ((vi_freq / 1000000UL) * BPP_YUV420_Y) / 8UL);
+
+       return 0;
+}
index 76ad363447de835164488e1b8d0076064888fb6b..257d22fe5aad51249aa742f35343fe6544cb80b4 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * drivers/video/tegra/camera/camera_clk.h
  *
- * Copyright (C) 2013 Nvidia Corp
+ * Copyright (c) 2013, NVIDIA CORPORATION.  All rights reserved.
  *
  * This software is licensed under the terms of the GNU General Public
  * License version 2, as published by the Free Software Foundation, and
@@ -22,7 +22,8 @@ int tegra_camera_enable_clk(struct tegra_camera *camera);
 int tegra_camera_disable_clk(struct tegra_camera *camera);
 int tegra_camera_clk_set_rate(struct tegra_camera *camera);
 int tegra_camera_init_clk(struct tegra_camera *camera,
-               struct clock_data *clock_init);
+       struct clock_data *clock_init);
 unsigned int tegra_camera_get_max_bw(struct tegra_camera *camera);
-
+int tegra_camera_set_latency_allowance(struct tegra_camera *camera,
+       unsigned long vi_freq);
 #endif