2 * Copyright (C) 2012 Texas Instruments Inc
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation version 2.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Manjunath Hadli <manjunath.hadli@ti.com>
19 * Prabhakar Lad <prabhakar.lad@ti.com>
22 #ifndef _DAVINCI_VPFE_DM365_IPIPE_H
23 #define _DAVINCI_VPFE_DM365_IPIPE_H
25 #include <linux/platform_device.h>
27 #include <media/v4l2-ctrls.h>
28 #include <media/v4l2-subdev.h>
30 #include "davinci_vpfe_user.h"
31 #include "vpfe_video.h"
33 #define CEIL(a, b) (((a) + (b-1)) / (b))
35 enum ipipe_noise_filter {
40 /* Used for driver storage */
41 struct ipipe_otfdpc_2_0 {
42 /* 0 - disable, 1 - enable */
44 /* defect detection method */
45 enum vpfe_ipipe_otfdpc_det_meth det_method;
46 /* Algorithm used. Applicable only when IPIPE_DPC_OTF_MIN_MAX2 is
49 enum vpfe_ipipe_otfdpc_alg alg;
50 struct vpfe_ipipe_otfdpc_2_0_cfg otfdpc_2_0;
53 struct ipipe_otfdpc_3_0 {
54 /* 0 - disable, 1 - enable */
56 /* defect detection method */
57 enum vpfe_ipipe_otfdpc_det_meth det_method;
58 /* Algorithm used. Applicable only when IPIPE_DPC_OTF_MIN_MAX2 is
61 enum vpfe_ipipe_otfdpc_alg alg;
62 struct vpfe_ipipe_otfdpc_3_0_cfg otfdpc_3_0;
65 /* Structure for configuring Luminance Adjustment module */
66 struct ipipe_lum_adj {
67 /* Brightness adjustments */
68 unsigned char brightness;
69 /* contrast adjustments */
70 unsigned char contrast;
78 struct ipipe_module_params {
80 struct vpfe_ipipe_input_config input_config;
81 struct vpfe_ipipe_lutdpc lutdpc;
82 struct vpfe_ipipe_otfdpc otfdpc;
83 struct vpfe_ipipe_nf nf1;
84 struct vpfe_ipipe_nf nf2;
85 struct vpfe_ipipe_gic gic;
86 struct vpfe_ipipe_wb wbal;
87 struct vpfe_ipipe_cfa cfa;
88 struct vpfe_ipipe_rgb2rgb rgb2rgb1;
89 struct vpfe_ipipe_rgb2rgb rgb2rgb2;
90 struct vpfe_ipipe_gamma gamma;
91 struct vpfe_ipipe_3d_lut lut;
92 struct vpfe_ipipe_rgb2yuv rgb2yuv;
93 struct vpfe_ipipe_gbce gbce;
94 struct vpfe_ipipe_yuv422_conv yuv422_conv;
95 struct vpfe_ipipe_yee yee;
96 struct vpfe_ipipe_car car;
97 struct vpfe_ipipe_cgs cgs;
98 struct ipipe_lum_adj lum_adj;
101 #define IPIPE_PAD_SINK 0
102 #define IPIPE_PAD_SOURCE 1
104 #define IPIPE_PADS_NUM 2
106 #define IPIPE_OUTPUT_NONE 0
107 #define IPIPE_OUTPUT_RESIZER (1 << 0)
109 enum ipipe_input_entity {
110 IPIPE_INPUT_NONE = 0,
111 IPIPE_INPUT_MEMORY = 1,
112 IPIPE_INPUT_CCDC = 2,
116 struct vpfe_ipipe_device {
117 struct v4l2_subdev subdev;
118 struct media_pad pads[IPIPE_PADS_NUM];
119 struct v4l2_mbus_framefmt formats[IPIPE_PADS_NUM];
120 enum ipipe_input_entity input;
122 struct v4l2_ctrl_handler ctrls;
123 void __iomem *base_addr;
124 void __iomem *isp5_base_addr;
125 struct ipipe_module_params config;
128 struct ipipe_module_if {
129 unsigned int param_offset;
130 unsigned int param_size;
131 unsigned int config_offset;
132 int (*set)(struct vpfe_ipipe_device *ipipe, void *param);
133 int (*get)(struct vpfe_ipipe_device *ipipe, void *param);
137 enum ipipe_data_paths {
139 /* Bayer RAW input to YCbCr output */
141 /* Bayer Raw to Bayer output */
143 /* Bayer Raw to Boxcar output */
145 /* YUV Raw to YUV Raw output */
148 #define IPIPE_COLPTN_R_Ye 0x0
149 #define IPIPE_COLPTN_Gr_Cy 0x1
150 #define IPIPE_COLPTN_Gb_G 0x2
151 #define IPIPE_COLPTN_B_Mg 0x3
153 #define COLPAT_EE_SHIFT 0
154 #define COLPAT_EO_SHIFT 2
155 #define COLPAT_OE_SHIFT 4
156 #define COLPAT_OO_SHIFT 6
158 #define ipipe_sgrbg_pattern \
159 (IPIPE_COLPTN_Gr_Cy << COLPAT_EE_SHIFT | \
160 IPIPE_COLPTN_R_Ye << COLPAT_EO_SHIFT | \
161 IPIPE_COLPTN_B_Mg << COLPAT_OE_SHIFT | \
162 IPIPE_COLPTN_Gb_G << COLPAT_OO_SHIFT)
164 #define ipipe_srggb_pattern \
165 (IPIPE_COLPTN_R_Ye << COLPAT_EE_SHIFT | \
166 IPIPE_COLPTN_Gr_Cy << COLPAT_EO_SHIFT | \
167 IPIPE_COLPTN_Gb_G << COLPAT_OE_SHIFT | \
168 IPIPE_COLPTN_B_Mg << COLPAT_OO_SHIFT)
170 int vpfe_ipipe_register_entities(struct vpfe_ipipe_device *ipipe,
171 struct v4l2_device *v4l2_dev);
172 int vpfe_ipipe_init(struct vpfe_ipipe_device *ipipe,
173 struct platform_device *pdev);
174 void vpfe_ipipe_unregister_entities(struct vpfe_ipipe_device *ipipe);
175 void vpfe_ipipe_cleanup(struct vpfe_ipipe_device *ipipe,
176 struct platform_device *pdev);
177 void vpfe_ipipe_enable(struct vpfe_device *vpfe_dev, int en);
179 #endif /* _DAVINCI_VPFE_DM365_IPIPE_H */