1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* Copyright (c) 2019 Rockchip Electronics Co., Ltd. */ 3 4 #ifndef _RKCIF_LUMA_H 5 #define _RKCIF_LUMA_H 6 7 #include <linux/rkisp1-config.h> 8 #include <linux/interrupt.h> 9 #include <linux/kfifo.h> 10 #include "dev.h" 11 12 #define RKCIF_LUMA_READOUT_WORK_SIZE \ 13 (9 * sizeof(struct rkcif_luma_readout_work)) 14 #define RKCIF_LUMA_YSTAT_ISR_NUM 1 15 #define RKCIF_RAW_MAX 3 16 17 struct rkcif_luma_vdev; 18 struct cif_input_fmt; 19 20 enum rkcif_luma_readout_cmd { 21 RKCIF_READOUT_LUMA, 22 }; 23 24 enum rkcif_luma_frm_mode { 25 RKCIF_LUMA_ONEFRM, 26 RKCIF_LUMA_TWOFRM, 27 RKCIF_LUMA_THREEFRM, 28 }; 29 30 struct rkcif_luma_readout_work { 31 enum rkcif_luma_readout_cmd readout; 32 unsigned long long timestamp; 33 unsigned int meas_type; 34 unsigned int frame_id; 35 struct rkisp_mipi_luma luma[RKCIF_RAW_MAX]; 36 }; 37 38 struct rkcif_luma_node { 39 struct vb2_queue buf_queue; 40 /* vfd lock */ 41 struct mutex vlock; 42 struct video_device vdev; 43 struct media_pad pad; 44 }; 45 46 /* 47 * struct rkcif_luma_vdev - CIF Statistics device 48 * 49 * @irq_lock: buffer queue lock 50 * @stat: stats buffer list 51 * @readout_wq: workqueue for statistics information read 52 */ 53 struct rkcif_luma_vdev { 54 struct rkcif_luma_node vnode; 55 struct rkcif_device *cifdev; 56 bool enable; 57 58 spinlock_t irq_lock; /* tasklet queue lock */ 59 struct list_head stat; 60 struct v4l2_format vdev_fmt; 61 bool streamon; 62 63 spinlock_t rd_lock; /* buffer queue lock */ 64 struct kfifo rd_kfifo; 65 struct tasklet_struct rd_tasklet; 66 67 bool ystat_rdflg[ISP2X_MIPI_RAW_MAX]; 68 struct rkcif_luma_readout_work work; 69 }; 70 71 void rkcif_start_luma(struct rkcif_luma_vdev *luma_vdev, const struct cif_input_fmt *cif_fmt_in); 72 73 void rkcif_stop_luma(struct rkcif_luma_vdev *luma_vdev); 74 75 void rkcif_luma_isr(struct rkcif_luma_vdev *luma_vdev, int isp_stat, u32 frame_id); 76 77 int rkcif_register_luma_vdev(struct rkcif_luma_vdev *luma_vdev, 78 struct v4l2_device *v4l2_dev, 79 struct rkcif_device *dev); 80 81 void rkcif_unregister_luma_vdev(struct rkcif_luma_vdev *luma_vdev); 82 83 #endif /* _RKCIF_LUMA_H */ 84