xref: /OK3568_Linux_fs/kernel/drivers/media/platform/rockchip/isp1/isp_params.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
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_H
36 #define _RKISP1_ISP_H
37 
38 #include <linux/rk-isp1-config.h>
39 #include <linux/rk-preisp.h>
40 #include "common.h"
41 
42 struct rkisp1_isp_params_vdev;
43 struct rkisp1_isp_params_ops {
44 	void (*dpcc_config)(struct rkisp1_isp_params_vdev *params_vdev,
45 			    const struct cifisp_dpcc_config *arg);
46 	void (*bls_config)(struct rkisp1_isp_params_vdev *params_vdev,
47 			   const struct cifisp_bls_config *arg);
48 	void (*lsc_config)(struct rkisp1_isp_params_vdev *params_vdev,
49 			   const struct cifisp_lsc_config *arg);
50 	void (*lsc_matrix_config)(struct rkisp1_isp_params_vdev *params_vdev,
51 				  const struct cifisp_lsc_config *pconfig);
52 	void (*flt_config)(struct rkisp1_isp_params_vdev *params_vdev,
53 			   const struct cifisp_flt_config *arg);
54 	void (*bdm_config)(struct rkisp1_isp_params_vdev *params_vdev,
55 			   const struct cifisp_bdm_config *arg);
56 	void (*sdg_config)(struct rkisp1_isp_params_vdev *params_vdev,
57 			   const struct cifisp_sdg_config *arg);
58 	void (*goc_config)(struct rkisp1_isp_params_vdev *params_vdev,
59 			   const struct cifisp_goc_config *arg);
60 	void (*ctk_config)(struct rkisp1_isp_params_vdev *params_vdev,
61 			   const struct cifisp_ctk_config *arg);
62 	void (*ctk_enable)(struct rkisp1_isp_params_vdev *params_vdev,
63 			   bool en);
64 	void (*awb_meas_config)(struct rkisp1_isp_params_vdev *params_vdev,
65 				const struct cifisp_awb_meas_config *arg);
66 	void (*awb_meas_enable)(struct rkisp1_isp_params_vdev *params_vdev,
67 				const struct cifisp_awb_meas_config *arg,
68 				bool en);
69 	void (*awb_gain_config)(struct rkisp1_isp_params_vdev *params_vdev,
70 				const struct cifisp_awb_gain_config *arg);
71 	void (*aec_config)(struct rkisp1_isp_params_vdev *params_vdev,
72 			   const struct cifisp_aec_config *arg);
73 	void (*cproc_config)(struct rkisp1_isp_params_vdev *params_vdev,
74 			     const struct cifisp_cproc_config *arg);
75 	void (*hst_config)(struct rkisp1_isp_params_vdev *params_vdev,
76 			   const struct cifisp_hst_config *arg);
77 	void (*hst_enable)(struct rkisp1_isp_params_vdev *params_vdev,
78 			   const struct cifisp_hst_config *arg, bool en);
79 	void (*afm_config)(struct rkisp1_isp_params_vdev *params_vdev,
80 			   const struct cifisp_afc_config *arg);
81 	void (*ie_config)(struct rkisp1_isp_params_vdev *params_vdev,
82 			  const struct cifisp_ie_config *arg);
83 	void (*ie_enable)(struct rkisp1_isp_params_vdev *params_vdev,
84 			  bool en);
85 	void (*csm_config)(struct rkisp1_isp_params_vdev *params_vdev,
86 			   bool full_range);
87 	void (*dpf_config)(struct rkisp1_isp_params_vdev *params_vdev,
88 			   const struct cifisp_dpf_config *arg);
89 	void (*dpf_strength_config)(struct rkisp1_isp_params_vdev *params_vdev,
90 				    const struct cifisp_dpf_strength_config *arg);
91 	void (*wdr_config)(struct rkisp1_isp_params_vdev *params_vdev,
92 			   const struct cifisp_wdr_config *arg);
93 	void (*wdr_enable)(struct rkisp1_isp_params_vdev *params_vdev,
94 			  bool en);
95 	void (*demosaiclp_config)(struct rkisp1_isp_params_vdev *params_vdev,
96 				  const struct cifisp_demosaiclp_config *arg);
97 	void (*demosaiclp_enable)(struct rkisp1_isp_params_vdev *params_vdev,
98 				  bool en);
99 	void (*rkiesharp_config)(struct rkisp1_isp_params_vdev *params_vdev,
100 				 const struct cifisp_rkiesharp_config *arg);
101 	void (*rkiesharp_enable)(struct rkisp1_isp_params_vdev *params_vdev,
102 				 bool en);
103 };
104 
105 struct rkisp1_isp_params_config {
106 	const int gamma_out_max_samples;
107 	const int hst_weight_grids_size;
108 };
109 
110 /*
111  * struct rkisp1_isp_subdev - ISP input parameters device
112  *
113  * @cur_params: Current ISP parameters
114  * @first_params: the first params should take effect immediately
115  */
116 struct rkisp1_isp_params_vdev {
117 	struct rkisp1_vdev_node vnode;
118 	struct rkisp1_device *dev;
119 
120 	spinlock_t config_lock;
121 	struct list_head params;
122 	struct rkisp1_isp_params_cfg cur_params;
123 	struct v4l2_format vdev_fmt;
124 	bool streamon;
125 	bool first_params;
126 
127 	enum v4l2_quantization quantization;
128 	enum rkisp1_fmt_raw_pat_type raw_type;
129 	u32 in_mbus_code;
130 
131 	struct preisp_hdrae_para_s hdrae_para;
132 
133 	struct rkisp1_isp_params_ops *ops;
134 	struct rkisp1_isp_params_config *config;
135 };
136 
137 /* config params before ISP streaming */
138 void rkisp1_params_configure_isp(struct rkisp1_isp_params_vdev *params_vdev,
139 			  struct ispsd_in_fmt *in_fmt,
140 			  enum v4l2_quantization quantization);
141 void rkisp1_params_disable_isp(struct rkisp1_isp_params_vdev *params_vdev);
142 
143 int rkisp1_register_params_vdev(struct rkisp1_isp_params_vdev *params_vdev,
144 				struct v4l2_device *v4l2_dev,
145 				struct rkisp1_device *dev);
146 
147 void rkisp1_unregister_params_vdev(struct rkisp1_isp_params_vdev *params_vdev);
148 
149 void rkisp1_params_isr(struct rkisp1_isp_params_vdev *params_vdev, u32 isp_mis);
150 
151 #endif /* _RKISP1_ISP_H */
152