1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#ifndef AM437X_VPFE_H
22#define AM437X_VPFE_H
23
24#include <linux/am437x-vpfe.h>
25#include <linux/clk.h>
26#include <linux/device.h>
27#include <linux/io.h>
28#include <linux/i2c.h>
29#include <linux/videodev2.h>
30
31#include <media/v4l2-dev.h>
32#include <media/v4l2-device.h>
33#include <media/v4l2-ioctl.h>
34#include <media/videobuf2-v4l2.h>
35#include <media/videobuf2-dma-contig.h>
36
37#include "am437x-vpfe_regs.h"
38
39enum vpfe_pin_pol {
40 VPFE_PINPOL_POSITIVE = 0,
41 VPFE_PINPOL_NEGATIVE,
42};
43
44enum vpfe_hw_if_type {
45
46 VPFE_RAW_BAYER = 0,
47
48 VPFE_BT656,
49
50 VPFE_BT656_10BIT,
51
52 VPFE_YCBCR_SYNC_8,
53
54 VPFE_YCBCR_SYNC_16,
55};
56
57
58struct vpfe_hw_if_param {
59 enum vpfe_hw_if_type if_type;
60 enum vpfe_pin_pol hdpol;
61 enum vpfe_pin_pol vdpol;
62 unsigned int bus_width;
63};
64
65#define VPFE_MAX_SUBDEV 1
66#define VPFE_MAX_INPUTS 1
67
68struct vpfe_pixel_format {
69 struct v4l2_fmtdesc fmtdesc;
70
71 int bpp;
72};
73
74struct vpfe_std_info {
75 int active_pixels;
76 int active_lines;
77
78 int frame_format;
79};
80
81struct vpfe_route {
82 u32 input;
83 u32 output;
84};
85
86struct vpfe_subdev_info {
87
88 int grp_id;
89
90 struct v4l2_input inputs[VPFE_MAX_INPUTS];
91
92 struct vpfe_route *routes;
93
94 int can_route;
95
96 struct vpfe_hw_if_param vpfe_param;
97 struct v4l2_subdev *sd;
98};
99
100struct vpfe_config {
101
102 struct vpfe_subdev_info sub_devs[VPFE_MAX_SUBDEV];
103
104 struct v4l2_async_subdev *asd[VPFE_MAX_SUBDEV];
105};
106
107struct vpfe_cap_buffer {
108 struct vb2_v4l2_buffer vb;
109 struct list_head list;
110};
111
112enum ccdc_pixfmt {
113 CCDC_PIXFMT_RAW = 0,
114 CCDC_PIXFMT_YCBCR_16BIT,
115 CCDC_PIXFMT_YCBCR_8BIT,
116};
117
118enum ccdc_frmfmt {
119 CCDC_FRMFMT_PROGRESSIVE = 0,
120 CCDC_FRMFMT_INTERLACED,
121};
122
123
124
125enum ccdc_pixorder {
126 CCDC_PIXORDER_YCBYCR,
127 CCDC_PIXORDER_CBYCRY,
128};
129
130enum ccdc_buftype {
131 CCDC_BUFTYPE_FLD_INTERLEAVED,
132 CCDC_BUFTYPE_FLD_SEPARATED
133};
134
135
136
137static inline u8 ccdc_gamma_width_max_bit(enum vpfe_ccdc_gamma_width width)
138{
139 return 15 - width;
140}
141
142
143static inline u8 ccdc_data_size_max_bit(enum vpfe_ccdc_data_size sz)
144{
145 return sz == VPFE_CCDC_DATA_8BITS ? 7 : 15 - sz;
146}
147
148
149struct ccdc_params_raw {
150
151 enum ccdc_pixfmt pix_fmt;
152
153 enum ccdc_frmfmt frm_fmt;
154 struct v4l2_rect win;
155
156 unsigned int bytesperpixel;
157
158
159
160 unsigned int bytesperline;
161
162 enum vpfe_pin_pol fid_pol;
163
164 enum vpfe_pin_pol vd_pol;
165
166 enum vpfe_pin_pol hd_pol;
167
168 enum ccdc_buftype buf_type;
169
170
171
172
173 unsigned char image_invert_enable;
174
175 struct vpfe_ccdc_config_params_raw config_params;
176};
177
178struct ccdc_params_ycbcr {
179
180 enum ccdc_pixfmt pix_fmt;
181
182 enum ccdc_frmfmt frm_fmt;
183 struct v4l2_rect win;
184
185 unsigned int bytesperpixel;
186
187
188
189 unsigned int bytesperline;
190
191 enum vpfe_pin_pol fid_pol;
192
193 enum vpfe_pin_pol vd_pol;
194
195 enum vpfe_pin_pol hd_pol;
196
197 int bt656_enable;
198
199 enum ccdc_pixorder pix_order;
200
201 enum ccdc_buftype buf_type;
202};
203
204
205
206
207struct ccdc_config {
208
209 enum vpfe_hw_if_type if_type;
210
211 struct ccdc_params_raw bayer;
212
213 struct ccdc_params_ycbcr ycbcr;
214
215 void __iomem *base_addr;
216};
217
218struct vpfe_ccdc {
219 struct ccdc_config ccdc_cfg;
220 u32 ccdc_ctx[VPFE_REG_END / sizeof(u32)];
221};
222
223struct vpfe_device {
224
225
226 struct video_device video_dev;
227
228 struct v4l2_subdev **sd;
229
230 struct vpfe_config *cfg;
231
232 struct v4l2_device v4l2_dev;
233
234 struct device *pdev;
235
236 struct v4l2_async_notifier notifier;
237
238 unsigned field;
239 unsigned sequence;
240
241 struct vpfe_hw_if_param vpfe_if_params;
242
243 struct vpfe_subdev_info *current_subdev;
244
245 int current_input;
246
247 struct vpfe_std_info std_info;
248
249 int std_index;
250
251 unsigned int irq;
252
253 struct vpfe_cap_buffer *cur_frm;
254
255 struct vpfe_cap_buffer *next_frm;
256
257 struct v4l2_format fmt;
258
259 unsigned int bpp;
260
261
262
263
264 struct v4l2_rect crop;
265
266 struct vb2_queue buffer_queue;
267
268 struct vb2_alloc_ctx *alloc_ctx;
269
270 struct list_head dma_queue;
271
272 spinlock_t dma_queue_lock;
273
274 struct mutex lock;
275
276
277
278
279 u32 field_off;
280 struct vpfe_ccdc ccdc;
281};
282
283#endif
284