From f230f0f67bdd137a02230b0ba32cd5ff9075c231 Mon Sep 17 00:00:00 2001 From: Shubhraprakash Das Date: Tue, 22 Nov 2016 15:21:28 -0800 Subject: [PATCH] msm: camera: isp: Stop stats stream properly When the camif input is disabled the stats streams need to be turned off as well. Stop the stats stream by following the correct stop sequence instead of just turning off the stats write masters. CRs-Fixed: 1098562 Change-Id: I4789bf9e837b1c0af7288e26ff02c4068638337a Signed-off-by: Shubhraprakash Das --- .../msm/camera_v2/isp/msm_isp_axi_util.c | 10 ++-- .../msm/camera_v2/isp/msm_isp_stats_util.c | 49 ++++++++++++++----- .../msm/camera_v2/isp/msm_isp_stats_util.h | 1 + 3 files changed, 42 insertions(+), 18 deletions(-) diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util.c b/drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util.c index aa3a0e239d87..ae032c588888 100644 --- a/drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util.c +++ b/drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util.c @@ -13,6 +13,7 @@ #include #include #include "msm_isp_util.h" +#include "msm_isp_stats_util.h" #include "msm_isp_axi_util.h" #include "msm_isp48.h" @@ -2759,12 +2760,11 @@ static void __msm_isp_stop_axi_streams(struct vfe_device *vfe_dev, if (!update_vfes[k]) continue; vfe_dev = update_vfes[k]; - axi_data = &vfe_dev->axi_data; - if (axi_data->src_info[VFE_PIX_0].active == 0) { - vfe_dev->hw_info->vfe_ops.stats_ops.enable_module( - vfe_dev, 0xFF, 0); - } + /* make sure all stats are stopped if camif is stopped */ + if (vfe_dev->axi_data.src_info[VFE_PIX_0].active == 0) + msm_isp_stop_all_stats_stream(vfe_dev); } + for (i = 0; i < num_streams; i++) { stream_info = streams[i]; spin_lock_irqsave(&stream_info->lock, flags); diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp_stats_util.c b/drivers/media/platform/msm/camera_v2/isp/msm_isp_stats_util.c index da4ceb400683..38ce78d941c9 100644 --- a/drivers/media/platform/msm/camera_v2/isp/msm_isp_stats_util.c +++ b/drivers/media/platform/msm/camera_v2/isp/msm_isp_stats_util.c @@ -548,19 +548,52 @@ int msm_isp_release_stats_stream(struct vfe_device *vfe_dev, void *arg) return 0; } +void msm_isp_stop_all_stats_stream(struct vfe_device *vfe_dev) +{ + struct msm_vfe_stats_stream_cfg_cmd stream_cfg_cmd; + struct msm_vfe_stats_stream *stream_info; + int i; + int vfe_idx; + unsigned long flags; + + stream_cfg_cmd.enable = 0; + stream_cfg_cmd.num_streams = 0; + + for (i = 0; i < MSM_ISP_STATS_MAX; i++) { + stream_info = msm_isp_get_stats_stream_common_data(vfe_dev, i); + spin_lock_irqsave(&stream_info->lock, flags); + if (stream_info->state == STATS_AVAILABLE || + stream_info->state == STATS_INACTIVE) { + spin_unlock_irqrestore(&stream_info->lock, flags); + continue; + } + vfe_idx = msm_isp_get_vfe_idx_for_stats_stream_user(vfe_dev, + stream_info); + if (vfe_idx == -ENOTTY) { + spin_unlock_irqrestore(&stream_info->lock, flags); + continue; + } + stream_cfg_cmd.stream_handle[ + stream_cfg_cmd.num_streams] = + stream_info->stream_handle[vfe_idx]; + stream_cfg_cmd.num_streams++; + spin_unlock_irqrestore(&stream_info->lock, flags); + } + if (stream_cfg_cmd.num_streams) + msm_isp_cfg_stats_stream(vfe_dev, &stream_cfg_cmd); +} + void msm_isp_release_all_stats_stream(struct vfe_device *vfe_dev) { struct msm_vfe_stats_stream_release_cmd stream_release_cmd[MSM_ISP_STATS_MAX]; - struct msm_vfe_stats_stream_cfg_cmd stream_cfg_cmd; struct msm_vfe_stats_stream *stream_info; int i; int vfe_idx; int num_stream = 0; unsigned long flags; - stream_cfg_cmd.enable = 0; - stream_cfg_cmd.num_streams = 0; + msm_isp_stop_all_stats_stream(vfe_dev); for (i = 0; i < MSM_ISP_STATS_MAX; i++) { stream_info = msm_isp_get_stats_stream_common_data(vfe_dev, i); @@ -577,18 +610,8 @@ void msm_isp_release_all_stats_stream(struct vfe_device *vfe_dev) } stream_release_cmd[num_stream++].stream_handle = stream_info->stream_handle[vfe_idx]; - if (stream_info->state == STATS_INACTIVE) { - spin_unlock_irqrestore(&stream_info->lock, flags); - continue; - } - stream_cfg_cmd.stream_handle[ - stream_cfg_cmd.num_streams] = - stream_info->stream_handle[vfe_idx]; - stream_cfg_cmd.num_streams++; spin_unlock_irqrestore(&stream_info->lock, flags); } - if (stream_cfg_cmd.num_streams) - msm_isp_cfg_stats_stream(vfe_dev, &stream_cfg_cmd); for (i = 0; i < num_stream; i++) msm_isp_release_stats_stream(vfe_dev, &stream_release_cmd[i]); diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp_stats_util.h b/drivers/media/platform/msm/camera_v2/isp/msm_isp_stats_util.h index e9728f33fae1..2e3a24dd1f0d 100644 --- a/drivers/media/platform/msm/camera_v2/isp/msm_isp_stats_util.h +++ b/drivers/media/platform/msm/camera_v2/isp/msm_isp_stats_util.h @@ -29,6 +29,7 @@ int msm_isp_stats_restart(struct vfe_device *vfe_dev); void msm_isp_release_all_stats_stream(struct vfe_device *vfe_dev); void msm_isp_process_stats_reg_upd_epoch_irq(struct vfe_device *vfe_dev, enum msm_isp_comp_irq_types irq); +void msm_isp_stop_all_stats_stream(struct vfe_device *vfe_dev); static inline int msm_isp_get_vfe_idx_for_stats_stream_user( struct vfe_device *vfe_dev,