]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - drivers/staging/media/davinci_vpfe/dm365_isif.h
Merge tag 'please-pull-fixmcelog' of git://git.kernel.org/pub/scm/linux/kernel/git...
[mirror_ubuntu-bionic-kernel.git] / drivers / staging / media / davinci_vpfe / dm365_isif.h
CommitLineData
6a630533
MH
1/*
2 * Copyright (C) 2012 Texas Instruments Inc
3 *
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.
7 *
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.
12 *
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
16 *
17 * Contributors:
18 * Manjunath Hadli <manjunath.hadli@ti.com>
19 * Prabhakar Lad <prabhakar.lad@ti.com>
20 */
21
22#ifndef _DAVINCI_VPFE_DM365_ISIF_H
23#define _DAVINCI_VPFE_DM365_ISIF_H
24
25#include <linux/platform_device.h>
26
27#include <mach/mux.h>
28
29#include <media/davinci/vpfe_types.h>
30#include <media/v4l2-ctrls.h>
31#include <media/v4l2-device.h>
32
33#include "davinci_vpfe_user.h"
34#include "dm365_isif_regs.h"
35#include "vpfe_video.h"
36
37#define ISIF_CULLING_HCAPT_ODD 0xff
38#define ISIF_CULLING_HCAPT_EVEN 0xff
39#define ISIF_CULLING_VCAPT 0xff
40
41#define ISIF_CADU_BITS 0x07ff
42#define ISIF_CADL_BITS 0x0ffff
43
44enum isif_pixfmt {
45 ISIF_PIXFMT_RAW = 0,
46 ISIF_PIXFMT_YCBCR_16BIT = 1,
47 ISIF_PIXFMT_YCBCR_8BIT = 2,
48};
49
50enum isif_frmfmt {
51 ISIF_FRMFMT_PROGRESSIVE = 0,
52 ISIF_FRMFMT_INTERLACED = 1,
53};
54
55/* PIXEL ORDER IN MEMORY from LSB to MSB */
56/* only applicable for 8-bit input mode */
57enum isif_pixorder {
58 ISIF_PIXORDER_YCBYCR = 0,
59 ISIF_PIXORDER_CBYCRY = 1,
60};
61
62enum isif_buftype {
63 ISIF_BUFTYPE_FLD_INTERLEAVED = 0,
64 ISIF_BUFTYPE_FLD_SEPARATED = 1,
65};
66
67struct 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 */
75 struct v4l2_rect win;
76 /* field polarity */
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;
86};
87
88enum isif_cfa_pattern {
89 ISIF_CFA_PAT_MOSAIC = 0,
90 ISIF_CFA_PAT_STRIPE = 1,
91};
92
93enum isif_data_msb {
94 /* MSB b15 */
95 ISIF_BIT_MSB_15 = 0,
96 /* MSB b14 */
97 ISIF_BIT_MSB_14 = 1,
98 /* MSB b13 */
99 ISIF_BIT_MSB_13 = 2,
100 /* MSB b12 */
101 ISIF_BIT_MSB_12 = 3,
102 /* MSB b11 */
103 ISIF_BIT_MSB_11 = 4,
104 /* MSB b10 */
105 ISIF_BIT_MSB_10 = 5,
106 /* MSB b9 */
107 ISIF_BIT_MSB_9 = 6,
108 /* MSB b8 */
109 ISIF_BIT_MSB_8 = 7,
110 /* MSB b7 */
111 ISIF_BIT_MSB_7 = 8,
112};
113
114struct 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;
121 /* video window */
122 struct v4l2_rect win;
123 /* field polarity */
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;
131 /* cfa pattern */
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;
141};
142
143enum isif_data_pack {
144 ISIF_PACK_16BIT = 0,
145 ISIF_PACK_12BIT = 1,
146 ISIF_PACK_8BIT = 2,
147};
148
149struct isif_gain_values {
150 unsigned int cr_gain;
151 unsigned int cgr_gain;
152 unsigned int cgb_gain;
153 unsigned int cb_gain;
154 unsigned int offset;
155};
156
157struct 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;
2129e17e
TP
162 void __iomem *base_addr;
163 void __iomem *linear_tbl0_addr;
164 void __iomem *linear_tbl1_addr;
6a630533
MH
165};
166
167#define ISIF_PAD_SINK 0
168#define ISIF_PAD_SOURCE 1
169
170#define ISIF_PADS_NUM 2
171
172enum isif_input_entity {
173 ISIF_INPUT_NONE = 0,
174 ISIF_INPUT_PARALLEL = 1,
175};
176
177#define ISIF_OUTPUT_NONE (0)
178#define ISIF_OUTPUT_MEMORY (1 << 0)
179#define ISIF_OUTPUT_IPIPEIF (1 << 1)
180
181struct 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;
186 unsigned int output;
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;
191};
192
193enum v4l2_field vpfe_isif_get_fid(struct vpfe_device *vpfe_dev);
194void vpfe_isif_unregister_entities(struct vpfe_isif_device *isif);
195int vpfe_isif_register_entities(struct vpfe_isif_device *isif,
196 struct v4l2_device *dev);
197int vpfe_isif_init(struct vpfe_isif_device *isif, struct platform_device *pdev);
198void vpfe_isif_cleanup(struct vpfe_isif_device *vpfe_isif,
199 struct platform_device *pdev);
200void vpfe_isif_vidint1_isr(struct vpfe_isif_device *isif);
201void vpfe_isif_buffer_isr(struct vpfe_isif_device *isif);
202
203#endif /* _DAVINCI_VPFE_DM365_ISIF_H */