1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2012 Texas Instruments Inc
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation version 2.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
15 * Manjunath Hadli <manjunath.hadli@ti.com>
16 * Prabhakar Lad <prabhakar.lad@ti.com>
19 #ifndef _DAVINCI_VPFE_DM365_ISIF_H
20 #define _DAVINCI_VPFE_DM365_ISIF_H
22 #include <linux/platform_device.h>
26 #include <media/davinci/vpfe_types.h>
27 #include <media/v4l2-ctrls.h>
28 #include <media/v4l2-device.h>
30 #include "davinci_vpfe_user.h"
31 #include "dm365_isif_regs.h"
32 #include "vpfe_video.h"
34 #define ISIF_CULLING_HCAPT_ODD 0xff
35 #define ISIF_CULLING_HCAPT_EVEN 0xff
36 #define ISIF_CULLING_VCAPT 0xff
38 #define ISIF_CADU_BITS 0x07ff
39 #define ISIF_CADL_BITS 0x0ffff
43 ISIF_PIXFMT_YCBCR_16BIT = 1,
44 ISIF_PIXFMT_YCBCR_8BIT = 2,
48 ISIF_FRMFMT_PROGRESSIVE = 0,
49 ISIF_FRMFMT_INTERLACED = 1,
52 /* PIXEL ORDER IN MEMORY from LSB to MSB */
53 /* only applicable for 8-bit input mode */
55 ISIF_PIXORDER_YCBYCR = 0,
56 ISIF_PIXORDER_CBYCRY = 1,
60 ISIF_BUFTYPE_FLD_INTERLEAVED = 0,
61 ISIF_BUFTYPE_FLD_SEPARATED = 1,
64 struct isif_ycbcr_config {
65 /* v4l2 pixel format */
66 unsigned long v4l2_pix_fmt;
67 /* isif pixel format */
68 enum isif_pixfmt pix_fmt;
69 /* isif frame format */
70 enum isif_frmfmt frm_fmt;
71 /* isif crop window */
74 enum vpfe_pin_pol fid_pol;
75 /* interface VD polarity */
76 enum vpfe_pin_pol vd_pol;
77 /* interface HD polarity */
78 enum vpfe_pin_pol hd_pol;
79 /* isif pix order. Only used for ycbcr capture */
80 enum isif_pixorder pix_order;
81 /* isif buffer type. Only used for ycbcr capture */
82 enum isif_buftype buf_type;
85 enum isif_cfa_pattern {
86 ISIF_CFA_PAT_MOSAIC = 0,
87 ISIF_CFA_PAT_STRIPE = 1,
111 struct isif_params_raw {
112 /* v4l2 pixel format */
113 unsigned long v4l2_pix_fmt;
114 /* isif pixel format */
115 enum isif_pixfmt pix_fmt;
116 /* isif frame format */
117 enum isif_frmfmt frm_fmt;
119 struct v4l2_rect win;
121 enum vpfe_pin_pol fid_pol;
122 /* interface VD polarity */
123 enum vpfe_pin_pol vd_pol;
124 /* interface HD polarity */
125 enum vpfe_pin_pol hd_pol;
126 /* buffer type. Applicable for interlaced mode */
127 enum isif_buftype buf_type;
129 enum isif_cfa_pattern cfa_pat;
130 /* Data MSB position */
131 enum isif_data_msb data_msb;
132 /* Enable horizontal flip */
133 unsigned char horz_flip_en;
134 /* Enable image invert vertically */
135 unsigned char image_invert_en;
136 unsigned char dpcm_predictor;
137 struct vpfe_isif_raw_config config_params;
140 enum isif_data_pack {
146 struct isif_gain_values {
147 unsigned int cr_gain;
148 unsigned int cgr_gain;
149 unsigned int cgb_gain;
150 unsigned int cb_gain;
154 struct isif_oper_config {
155 struct isif_ycbcr_config ycbcr;
156 struct isif_params_raw bayer;
157 enum isif_data_pack data_pack;
158 struct isif_gain_values isif_gain_params;
159 void __iomem *base_addr;
160 void __iomem *linear_tbl0_addr;
161 void __iomem *linear_tbl1_addr;
164 #define ISIF_PAD_SINK 0
165 #define ISIF_PAD_SOURCE 1
167 #define ISIF_PADS_NUM 2
169 enum isif_input_entity {
171 ISIF_INPUT_PARALLEL = 1,
174 #define ISIF_OUTPUT_NONE (0)
175 #define ISIF_OUTPUT_MEMORY (1 << 0)
176 #define ISIF_OUTPUT_IPIPEIF (1 << 1)
178 struct vpfe_isif_device {
179 struct v4l2_subdev subdev;
180 struct media_pad pads[ISIF_PADS_NUM];
181 struct v4l2_mbus_framefmt formats[ISIF_PADS_NUM];
182 enum isif_input_entity input;
184 struct v4l2_ctrl_handler ctrls;
185 struct v4l2_rect crop;
186 struct isif_oper_config isif_cfg;
187 struct vpfe_video_device video_out;
190 enum v4l2_field vpfe_isif_get_fid(struct vpfe_device *vpfe_dev);
191 void vpfe_isif_unregister_entities(struct vpfe_isif_device *isif);
192 int vpfe_isif_register_entities(struct vpfe_isif_device *isif,
193 struct v4l2_device *dev);
194 int vpfe_isif_init(struct vpfe_isif_device *isif, struct platform_device *pdev);
195 void vpfe_isif_cleanup(struct vpfe_isif_device *vpfe_isif,
196 struct platform_device *pdev);
197 void vpfe_isif_vidint1_isr(struct vpfe_isif_device *isif);
198 void vpfe_isif_buffer_isr(struct vpfe_isif_device *isif);
200 #endif /* _DAVINCI_VPFE_DM365_ISIF_H */