xref: /OK3568_Linux_fs/kernel/drivers/media/platform/rockchip/ispp/stats.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (c) 2019 Fuzhou Rockchip Electronics Co., Ltd. */
3 
4 #ifndef _RKISPP_STATS_H
5 #define _RKISPP_STATS_H
6 
7 #include <linux/rk-ispp-config.h>
8 #include <linux/interrupt.h>
9 #include <linux/kfifo.h>
10 #include "common.h"
11 
12 #define RKISPP_STATS_READOUT_WORK_SIZE	\
13 	(9 * sizeof(struct rkispp_stats_readout_work))
14 
15 struct rkispp_stats_vdev;
16 
17 enum rkispp_stats_readout_cmd {
18 	RKISPP_READOUT_STATS,
19 };
20 
21 enum rkispp_statsvdev_id {
22 	STATS_VDEV_TNR = 0,
23 	STATS_VDEV_NR,
24 	STATS_VDEV_MAX
25 };
26 
27 struct rkispp_stats_readout_work {
28 	enum rkispp_stats_readout_cmd readout;
29 	unsigned long long timestamp;
30 	unsigned int meas_type;
31 	unsigned int frame_id;
32 };
33 
34 /*
35  * struct rkispp_stats_vdev - ISPP Statistics device
36  *
37  * @irq_lock: buffer queue lock
38  * @stat: stats buffer list
39  * @readout_wq: workqueue for statistics information read
40  */
41 struct rkispp_stats_vdev {
42 	struct rkispp_vdev_node vnode;
43 	struct rkispp_device *dev;
44 	enum rkispp_statsvdev_id vdev_id;
45 
46 	spinlock_t irq_lock;
47 	struct list_head stat;
48 	struct rkispp_buffer *curr_buf;
49 	struct v4l2_format vdev_fmt;
50 	u32 frame_id;
51 	bool streamon;
52 };
53 
54 void rkispp_stats_isr(struct rkispp_stats_vdev *stats_vdev);
55 
56 int rkispp_register_stats_vdevs(struct rkispp_device *dev);
57 
58 void rkispp_unregister_stats_vdevs(struct rkispp_device *dev);
59 
60 #endif /* _RKISPP_STATS_H */
61