blob: 9d5ae8cf7f4c7ce1e7cb1a3134e7215480086213 [file] [log] [blame]
Pratap Nirujogi6e759912018-01-17 17:51:17 +05301/* Copyright (c) 2013-2016, 2018, The Linux Foundation. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12#ifndef __MSM_ISP_STATS_UTIL_H__
13#define __MSM_ISP_STATS_UTIL_H__
14
15#include "msm_isp.h"
16#define STATS_IDX(idx) (idx & 0xFF)
17
18void msm_isp_process_stats_irq(struct vfe_device *vfe_dev,
19 uint32_t irq_status0, uint32_t irq_status1,
20 struct msm_isp_timestamp *ts);
21int msm_isp_stats_create_stream(struct vfe_device *vfe_dev,
22 struct msm_vfe_stats_stream_request_cmd *stream_req_cmd,
23 struct msm_vfe_stats_stream *stream_info);
24void msm_isp_stats_stream_update(struct vfe_device *vfe_dev);
25int msm_isp_cfg_stats_stream(struct vfe_device *vfe_dev, void *arg);
26int msm_isp_update_stats_stream(struct vfe_device *vfe_dev, void *arg);
27int msm_isp_release_stats_stream(struct vfe_device *vfe_dev, void *arg);
28int msm_isp_request_stats_stream(struct vfe_device *vfe_dev, void *arg);
29void msm_isp_stats_disable(struct vfe_device *vfe_dev);
30int msm_isp_stats_reset(struct vfe_device *vfe_dev);
31int msm_isp_stats_restart(struct vfe_device *vfe_dev);
32void msm_isp_release_all_stats_stream(struct vfe_device *vfe_dev);
33void msm_isp_process_stats_reg_upd_epoch_irq(struct vfe_device *vfe_dev,
34 enum msm_isp_comp_irq_types irq);
35void msm_isp_stop_all_stats_stream(struct vfe_device *vfe_dev);
36
37static inline int msm_isp_get_vfe_idx_for_stats_stream_user(
38 struct vfe_device *vfe_dev,
39 struct msm_vfe_stats_stream *stream_info)
40{
41 int vfe_idx;
42
43 for (vfe_idx = 0; vfe_idx < stream_info->num_isp; vfe_idx++)
44 if (stream_info->vfe_dev[vfe_idx] == vfe_dev)
45 return vfe_idx;
46 return -ENOTTY;
47}
48
49static inline int msm_isp_get_vfe_idx_for_stats_stream(
50 struct vfe_device *vfe_dev,
51 struct msm_vfe_stats_stream *stream_info)
52{
53 int vfe_idx = msm_isp_get_vfe_idx_for_stats_stream_user(vfe_dev,
54 stream_info);
55
56 if (vfe_idx < 0) {
57 WARN(1, "%s vfe index missing for stream %d vfe %d\n",
58 __func__, stream_info->stats_type, vfe_dev->pdev->id);
59 vfe_idx = 0;
60 }
61 return vfe_idx;
62}
63
64static inline struct msm_vfe_stats_stream *
65 msm_isp_get_stats_stream_common_data(
66 struct vfe_device *vfe_dev,
67 enum msm_isp_stats_type idx)
68{
69 if (vfe_dev->is_split)
70 return &vfe_dev->common_data->stats_streams[idx];
71 else
72 return &vfe_dev->common_data->stats_streams[idx +
73 MSM_ISP_STATS_MAX * vfe_dev->pdev->id];
74}
75
76static inline struct msm_vfe_stats_stream *
77 msm_isp_get_stats_stream(struct dual_vfe_resource *dual_vfe_res,
78 int vfe_id,
79 enum msm_isp_stats_type idx)
80{
81 return msm_isp_get_stats_stream_common_data(
82 dual_vfe_res->vfe_dev[vfe_id], idx);
83}
84#endif /* __MSM_ISP_STATS_UTIL_H__ */