1 /* 2 * Rockchip isp1 driver 3 * 4 * Copyright (C) 2017 Rockchip Electronics Co., Ltd. 5 * 6 * This software is available to you under a choice of one of two 7 * licenses. You may choose to be licensed under the terms of the GNU 8 * General Public License (GPL) Version 2, available from the file 9 * COPYING in the main directory of this source tree, or the 10 * OpenIB.org BSD license below: 11 * 12 * Redistribution and use in source and binary forms, with or 13 * without modification, are permitted provided that the following 14 * conditions are met: 15 * 16 * - Redistributions of source code must retain the above 17 * copyright notice, this list of conditions and the following 18 * disclaimer. 19 * 20 * - Redistributions in binary form must reproduce the above 21 * copyright notice, this list of conditions and the following 22 * disclaimer in the documentation and/or other materials 23 * provided with the distribution. 24 * 25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32 * SOFTWARE. 33 */ 34 35 #ifndef _RKISP1_ISP_STATS_H 36 #define _RKISP1_ISP_STATS_H 37 38 #include <linux/rk-isp1-config.h> 39 #include <linux/interrupt.h> 40 #include <linux/kfifo.h> 41 #include "common.h" 42 43 #define RKISP1_READOUT_WORK_SIZE \ 44 (8 * sizeof(struct rkisp1_isp_readout_work)) 45 46 struct rkisp1_isp_stats_vdev; 47 48 enum rkisp1_isp_readout_cmd { 49 RKISP1_ISP_READOUT_MEAS, 50 RKISP1_ISP_READOUT_META, 51 }; 52 53 struct rkisp1_isp_readout_work { 54 unsigned int frame_id; 55 unsigned int isp_ris; 56 enum rkisp1_isp_readout_cmd readout; 57 unsigned long long timestamp; 58 }; 59 60 struct rkisp1_stats_ops { 61 void (*get_awb_meas)(struct rkisp1_isp_stats_vdev *stats_vdev, 62 struct rkisp1_stat_buffer *pbuf); 63 void (*get_aec_meas)(struct rkisp1_isp_stats_vdev *stats_vdev, 64 struct rkisp1_stat_buffer *pbuf); 65 void (*get_afc_meas)(struct rkisp1_isp_stats_vdev *stats_vdev, 66 struct rkisp1_stat_buffer *pbuf); 67 void (*get_hst_meas)(struct rkisp1_isp_stats_vdev *stats_vdev, 68 struct rkisp1_stat_buffer *pbuf); 69 void (*get_bls_meas)(struct rkisp1_isp_stats_vdev *stats_vdev, 70 struct rkisp1_stat_buffer *pbuf); 71 void (*get_emb_data)(struct rkisp1_isp_stats_vdev *stats_vdev, 72 struct rkisp1_stat_buffer *pbuf); 73 }; 74 75 struct rkisp1_stats_config { 76 const int ae_mean_max; 77 const int hist_bin_n_max; 78 }; 79 80 /* 81 * struct rkisp1_isp_stats_vdev - ISP Statistics device 82 * 83 * @irq_lock: buffer queue lock 84 * @stat: stats buffer list 85 * @readout_wq: workqueue for statistics information read 86 */ 87 struct rkisp1_isp_stats_vdev { 88 struct rkisp1_vdev_node vnode; 89 struct rkisp1_device *dev; 90 91 spinlock_t irq_lock; 92 struct list_head stat; 93 struct v4l2_format vdev_fmt; 94 bool streamon; 95 96 spinlock_t rd_lock; 97 struct kfifo rd_kfifo; 98 struct tasklet_struct rd_tasklet; 99 100 struct rkisp1_stats_ops *ops; 101 struct rkisp1_stats_config *config; 102 }; 103 104 int rkisp1_stats_isr(struct rkisp1_isp_stats_vdev *stats_vdev, u32 isp_ris); 105 106 int rkisp1_register_stats_vdev(struct rkisp1_isp_stats_vdev *stats_vdev, 107 struct v4l2_device *v4l2_dev, 108 struct rkisp1_device *dev); 109 110 void rkisp1_unregister_stats_vdev(struct rkisp1_isp_stats_vdev *stats_vdev); 111 112 #endif /* _RKISP1_ISP_STATS_H */ 113