2 *************************************************************************
3 * Rockchip driver for CIF ISP 1.0
4 * (Based on Intel driver for sofiaxxx)
6 * Copyright (C) 2015 Intel Mobile Communications GmbH
7 * Copyright (C) 2016 Fuzhou Rockchip Electronics Co., Ltd.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *************************************************************************
17 #ifndef _CIF_ISP10_ISP_H
18 #define _CIF_ISP10_ISP_H
20 #include <media/v4l2-common.h>
21 #include <media/videobuf-core.h>
22 #include <media/rk-isp10-ioctl.h>
23 #include <media/v4l2-controls_rockchip.h>
28 enum cif_isp10_pix_fmt;
30 enum cif_isp10_pix_fmt_quantization {
31 CIF_ISP10_QUANTIZATION_DEFAULT = 0,
32 CIF_ISP10_QUANTIZATION_FULL_RANGE = 1,
33 CIF_ISP10_QUANTIZATION_LIM_RANGE = 2
36 struct cif_isp10_isp_other_cfgs {
37 struct cifisp_isp_other_cfg *last_or_new;
38 struct cifisp_isp_other_cfg *curr;
39 struct cifisp_isp_other_cfg cfgs[2];
40 unsigned int module_updates;
43 struct cif_isp10_isp_meas_cfgs {
44 struct cifisp_isp_meas_cfg *last_or_new;
45 struct cifisp_isp_meas_cfg *curr;
46 struct cifisp_isp_meas_cfg cfgs[2];
47 unsigned int module_updates;
50 struct cif_isp10_isp_meas_stats {
51 unsigned int g_frame_id;
52 struct cifisp_stat_buffer stat;
55 struct cif_isp10_isp_dev {
57 * Purpose of mutex is to protect and serialize use
58 * of isp data structure and CIF API calls.
61 /* Current ISP parameters */
62 spinlock_t config_lock;
63 struct cif_isp10_isp_other_cfgs other_cfgs;
64 struct cif_isp10_isp_meas_cfgs meas_cfgs;
65 struct cif_isp10_isp_meas_stats meas_stats;
67 bool cif_ism_cropping;
69 enum cif_isp10_pix_fmt_quantization quantization;
71 /* input resolution needed for LSC param check */
72 unsigned int input_width;
73 unsigned int input_height;
74 unsigned int active_lsc_width;
75 unsigned int active_lsc_height;
77 /* ISP statistics related */
79 /* ISP statistics related */
81 struct videobuf_queue vbq_stat;
82 struct list_head stat;
83 void __iomem *base_addr; /* registers base address */
86 unsigned int v_blanking_us;
88 unsigned int frame_id;
89 unsigned int frame_id_setexp;
90 unsigned int active_meas;
92 struct timeval vs_t; /* updated each frame */
93 struct timeval fi_t; /* updated each frame */
94 struct workqueue_struct *readout_wq;
99 enum cif_isp10_isp_readout_cmd {
100 CIF_ISP10_ISP_READOUT_MEAS = 0,
101 CIF_ISP10_ISP_READOUT_META = 1,
104 struct cif_isp10_isp_readout_work {
105 struct work_struct work;
106 struct cif_isp10_isp_dev *isp_dev;
108 unsigned int frame_id;
109 enum cif_isp10_isp_readout_cmd readout;
110 struct videobuf_buffer *vb;
111 unsigned int stream_id;
114 int register_cifisp_device(
115 struct cif_isp10_isp_dev *isp_dev,
116 struct video_device *vdev_cifisp,
117 struct v4l2_device *v4l2_dev,
118 void __iomem *cif_reg_baseaddress);
119 void unregister_cifisp_device(struct video_device *vdev_cifisp);
120 void cifisp_configure_isp(
121 struct cif_isp10_isp_dev *isp_dev,
122 enum cif_isp10_pix_fmt in_pix_fmt,
123 enum cif_isp10_pix_fmt_quantization quantization);
124 void cifisp_disable_isp(struct cif_isp10_isp_dev *isp_dev);
125 int cifisp_isp_isr(struct cif_isp10_isp_dev *isp_dev, u32 isp_mis);
126 void cifisp_v_start(struct cif_isp10_isp_dev *isp_dev,
127 const struct timeval *timestamp);
128 void cifisp_frame_in(
129 struct cif_isp10_isp_dev *isp_dev,
130 const struct timeval *fi_t);
131 void cifisp_isp_readout_work(struct work_struct *work);