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_ISIF_H
23 #define _DAVINCI_VPFE_DM365_ISIF_H
25 #include <linux/platform_device.h>
29 #include <media/davinci/vpfe_types.h>
30 #include <media/v4l2-ctrls.h>
31 #include <media/v4l2-device.h>
33 #include "davinci_vpfe_user.h"
34 #include "dm365_isif_regs.h"
35 #include "vpfe_video.h"
37 #define ISIF_CULLING_HCAPT_ODD 0xff
38 #define ISIF_CULLING_HCAPT_EVEN 0xff
39 #define ISIF_CULLING_VCAPT 0xff
41 #define ISIF_CADU_BITS 0x07ff
42 #define ISIF_CADL_BITS 0x0ffff
46 ISIF_PIXFMT_YCBCR_16BIT = 1,
47 ISIF_PIXFMT_YCBCR_8BIT = 2,
51 ISIF_FRMFMT_PROGRESSIVE = 0,
52 ISIF_FRMFMT_INTERLACED = 1,
55 /* PIXEL ORDER IN MEMORY from LSB to MSB */
56 /* only applicable for 8-bit input mode */
58 ISIF_PIXORDER_YCBYCR = 0,
59 ISIF_PIXORDER_CBYCRY = 1,
63 ISIF_BUFTYPE_FLD_INTERLEAVED = 0,
64 ISIF_BUFTYPE_FLD_SEPARATED = 1,
67 struct isif_ycbcr_config {
68 /* v4l2 pixel format */
69 unsigned long v4l2_pix_fmt;
70 /* isif pixel format */
71 enum isif_pixfmt pix_fmt;
72 /* isif frame format */
73 enum isif_frmfmt frm_fmt;
74 /* isif crop window */
77 enum vpfe_pin_pol fid_pol;
78 /* interface VD polarity */
79 enum vpfe_pin_pol vd_pol;
80 /* interface HD polarity */
81 enum vpfe_pin_pol hd_pol;
82 /* isif pix order. Only used for ycbcr capture */
83 enum isif_pixorder pix_order;
84 /* isif buffer type. Only used for ycbcr capture */
85 enum isif_buftype buf_type;
88 enum isif_cfa_pattern {
89 ISIF_CFA_PAT_MOSAIC = 0,
90 ISIF_CFA_PAT_STRIPE = 1,
114 struct isif_params_raw {
115 /* v4l2 pixel format */
116 unsigned long v4l2_pix_fmt;
117 /* isif pixel format */
118 enum isif_pixfmt pix_fmt;
119 /* isif frame format */
120 enum isif_frmfmt frm_fmt;
122 struct v4l2_rect win;
124 enum vpfe_pin_pol fid_pol;
125 /* interface VD polarity */
126 enum vpfe_pin_pol vd_pol;
127 /* interface HD polarity */
128 enum vpfe_pin_pol hd_pol;
129 /* buffer type. Applicable for interlaced mode */
130 enum isif_buftype buf_type;
132 enum isif_cfa_pattern cfa_pat;
133 /* Data MSB position */
134 enum isif_data_msb data_msb;
135 /* Enable horizontal flip */
136 unsigned char horz_flip_en;
137 /* Enable image invert vertically */
138 unsigned char image_invert_en;
139 unsigned char dpcm_predictor;
140 struct vpfe_isif_raw_config config_params;
143 enum isif_data_pack {
149 struct isif_gain_values {
150 unsigned int cr_gain;
151 unsigned int cgr_gain;
152 unsigned int cgb_gain;
153 unsigned int cb_gain;
157 struct isif_oper_config {
158 struct isif_ycbcr_config ycbcr;
159 struct isif_params_raw bayer;
160 enum isif_data_pack data_pack;
161 struct isif_gain_values isif_gain_params;
162 void __iomem *base_addr;
163 void __iomem *linear_tbl0_addr;
164 void __iomem *linear_tbl1_addr;
167 #define ISIF_PAD_SINK 0
168 #define ISIF_PAD_SOURCE 1
170 #define ISIF_PADS_NUM 2
172 enum isif_input_entity {
174 ISIF_INPUT_PARALLEL = 1,
177 #define ISIF_OUTPUT_NONE (0)
178 #define ISIF_OUTPUT_MEMORY (1 << 0)
179 #define ISIF_OUTPUT_IPIPEIF (1 << 1)
181 struct vpfe_isif_device {
182 struct v4l2_subdev subdev;
183 struct media_pad pads[ISIF_PADS_NUM];
184 struct v4l2_mbus_framefmt formats[ISIF_PADS_NUM];
185 enum isif_input_entity input;
187 struct v4l2_ctrl_handler ctrls;
188 struct v4l2_rect crop;
189 struct isif_oper_config isif_cfg;
190 struct vpfe_video_device video_out;
193 enum v4l2_field vpfe_isif_get_fid(struct vpfe_device *vpfe_dev);
194 void vpfe_isif_unregister_entities(struct vpfe_isif_device *isif);
195 int vpfe_isif_register_entities(struct vpfe_isif_device *isif,
196 struct v4l2_device *dev);
197 int vpfe_isif_init(struct vpfe_isif_device *isif, struct platform_device *pdev);
198 void vpfe_isif_cleanup(struct vpfe_isif_device *vpfe_isif,
199 struct platform_device *pdev);
200 void vpfe_isif_vidint1_isr(struct vpfe_isif_device *isif);
201 void vpfe_isif_buffer_isr(struct vpfe_isif_device *isif);
203 #endif /* _DAVINCI_VPFE_DM365_ISIF_H */