Pratap Nirujogi | 6e75991 | 2018-01-17 17:51:17 +0530 | [diff] [blame^] | 1 | /* 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 | |
| 18 | void 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); |
| 21 | int 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); |
| 24 | void msm_isp_stats_stream_update(struct vfe_device *vfe_dev); |
| 25 | int msm_isp_cfg_stats_stream(struct vfe_device *vfe_dev, void *arg); |
| 26 | int msm_isp_update_stats_stream(struct vfe_device *vfe_dev, void *arg); |
| 27 | int msm_isp_release_stats_stream(struct vfe_device *vfe_dev, void *arg); |
| 28 | int msm_isp_request_stats_stream(struct vfe_device *vfe_dev, void *arg); |
| 29 | void msm_isp_stats_disable(struct vfe_device *vfe_dev); |
| 30 | int msm_isp_stats_reset(struct vfe_device *vfe_dev); |
| 31 | int msm_isp_stats_restart(struct vfe_device *vfe_dev); |
| 32 | void msm_isp_release_all_stats_stream(struct vfe_device *vfe_dev); |
| 33 | void msm_isp_process_stats_reg_upd_epoch_irq(struct vfe_device *vfe_dev, |
| 34 | enum msm_isp_comp_irq_types irq); |
| 35 | void msm_isp_stop_all_stats_stream(struct vfe_device *vfe_dev); |
| 36 | |
| 37 | static 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 | |
| 49 | static 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 | |
| 64 | static 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 | |
| 76 | static 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__ */ |