blob: 7f70a01c7d5c9aed91c7f261c381352b56583543 [file] [log] [blame]
Kevin Chan1d5fd4a2013-01-11 14:08:14 -08001#ifndef __MSMB_ISP__
2#define __MSMB_ISP__
3
4#include <linux/videodev2.h>
5
6#define MAX_PLANES_PER_STREAM 3
7#define MAX_NUM_STREAM 7
8
9#define ISP_VERSION_40 40
10#define ISP_VERSION_32 32
Mingcheng Zhu503a6f92013-01-06 13:23:24 -080011#define ISP_NATIVE_BUF_BIT 0x10000
Peter Liu11cbc222013-03-13 15:27:24 -070012#define ISP0_BIT 0x20000
13#define ISP1_BIT 0x40000
Mingcheng Zhu503a6f92013-01-06 13:23:24 -080014#define ISP_STATS_STREAM_BIT 0x80000000
Kevin Chan1d5fd4a2013-01-11 14:08:14 -080015
16enum ISP_START_PIXEL_PATTERN {
17 ISP_BAYER_RGRGRG,
18 ISP_BAYER_GRGRGR,
19 ISP_BAYER_BGBGBG,
20 ISP_BAYER_GBGBGB,
21 ISP_YUV_YCbYCr,
22 ISP_YUV_YCrYCb,
23 ISP_YUV_CbYCrY,
24 ISP_YUV_CrYCbY,
25 ISP_PIX_PATTERN_MAX
26};
27
28enum msm_vfe_plane_fmt {
29 Y_PLANE,
30 CB_PLANE,
31 CR_PLANE,
32 CRCB_PLANE,
33 CBCR_PLANE,
34 VFE_PLANE_FMT_MAX
35};
36
37enum msm_vfe_input_src {
38 VFE_PIX_0,
39 VFE_RAW_0,
40 VFE_RAW_1,
41 VFE_RAW_2,
42 VFE_SRC_MAX,
43};
44
45enum msm_vfe_axi_stream_src {
46 PIX_ENCODER,
47 PIX_VIEWFINDER,
48 CAMIF_RAW,
49 IDEAL_RAW,
Kevin Chan80b7b6d2013-01-31 16:08:35 -080050 RDI_INTF_0,
51 RDI_INTF_1,
52 RDI_INTF_2,
Kevin Chan1d5fd4a2013-01-11 14:08:14 -080053 VFE_AXI_SRC_MAX
54};
55
56enum msm_vfe_frame_skip_pattern {
57 NO_SKIP,
58 EVERY_2FRAME,
Kevin Chan1fe7fb72013-02-12 19:33:38 -080059 EVERY_3FRAME,
Kevin Chan1d5fd4a2013-01-11 14:08:14 -080060 EVERY_4FRAME,
Kevin Chan1fe7fb72013-02-12 19:33:38 -080061 EVERY_5FRAME,
62 EVERY_6FRAME,
63 EVERY_7FRAME,
Kevin Chan1d5fd4a2013-01-11 14:08:14 -080064 EVERY_8FRAME,
65 EVERY_16FRAME,
66 EVERY_32FRAME,
67 MAX_SKIP,
68};
69
70enum msm_vfe_camif_input {
71 CAMIF_DISABLED,
72 CAMIF_PAD_REG_INPUT,
73 CAMIF_MIDDI_INPUT,
74 CAMIF_MIPI_INPUT,
75};
76
77struct msm_vfe_camif_cfg {
78 uint32_t lines_per_frame;
79 uint32_t pixels_per_line;
80 uint32_t first_pixel;
81 uint32_t last_pixel;
82 uint32_t first_line;
83 uint32_t last_line;
84 uint32_t epoch_line0;
85 uint32_t epoch_line1;
86 enum msm_vfe_camif_input camif_input;
87};
88
89enum msm_vfe_inputmux {
90 CAMIF,
91 TESTGEN,
92 EXTERNAL_READ,
93};
94
95struct msm_vfe_pix_cfg {
96 struct msm_vfe_camif_cfg camif_cfg;
97 enum msm_vfe_inputmux input_mux;
98 enum ISP_START_PIXEL_PATTERN pixel_pattern;
99};
100
Kevin Chan80b7b6d2013-01-31 16:08:35 -0800101struct msm_vfe_rdi_cfg {
102 uint8_t cid;
103 uint8_t frame_based;
104};
105
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800106struct msm_vfe_input_cfg {
107 union {
108 struct msm_vfe_pix_cfg pix_cfg;
Kevin Chan80b7b6d2013-01-31 16:08:35 -0800109 struct msm_vfe_rdi_cfg rdi_cfg;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800110 } d;
111 enum msm_vfe_input_src input_src;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800112};
113
114struct msm_vfe_axi_plane_cfg {
115 uint32_t output_width; /*Include padding*/
116 uint32_t output_height;
117 uint32_t output_stride;
118 uint32_t output_scan_lines;
119 uint32_t output_plane_format; /*Y/Cb/Cr/CbCr*/
Kevin Chanbaf0a132013-03-05 20:08:23 -0800120 uint32_t plane_addr_offset;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800121 uint8_t csid_src; /*RDI 0-2*/
122 uint8_t rdi_cid;/*CID 1-16*/
123};
124
125struct msm_vfe_axi_stream_request_cmd {
126 uint32_t session_id;
127 uint32_t stream_id;
128 uint32_t output_format;/*Planar/RAW/Misc*/
129 enum msm_vfe_axi_stream_src stream_src; /*CAMIF/IDEAL/RDIs*/
130 struct msm_vfe_axi_plane_cfg plane_cfg[MAX_PLANES_PER_STREAM];
131
132 uint32_t burst_count;
133 uint32_t hfr_mode;
134 uint8_t frame_base;
135
136 uint32_t init_frame_drop; /*MAX 31 Frames*/
137 enum msm_vfe_frame_skip_pattern frame_skip_pattern;
138 uint8_t buf_divert; /* if TRUE no vb2 buf done. */
139 /*Return values*/
140 uint32_t axi_stream_handle;
141};
142
143struct msm_vfe_axi_stream_release_cmd {
144 uint32_t stream_handle;
145};
146
147enum msm_vfe_axi_stream_cmd {
148 STOP_STREAM,
149 START_STREAM,
150};
151
152struct msm_vfe_axi_stream_cfg_cmd {
153 uint8_t num_streams;
154 uint32_t stream_handle[MAX_NUM_STREAM];
155 enum msm_vfe_axi_stream_cmd cmd;
156};
157
Kevin Chan5bebd2e2013-01-30 20:25:05 -0800158enum msm_vfe_axi_stream_update_type {
159 ENABLE_STREAM_BUF_DIVERT,
160 DISABLE_STREAM_BUF_DIVERT,
161 UPDATE_STREAM_FRAMEDROP_PATTERN,
162};
163
164struct msm_vfe_axi_stream_update_cmd {
165 uint32_t stream_handle;
166 enum msm_vfe_axi_stream_update_type update_type;
167 enum msm_vfe_frame_skip_pattern skip_pattern;
168};
169
Kevin Chan3454e2b2013-01-17 19:18:57 -0800170enum msm_vfe_stats_pipeline_policy {
171 STATS_COMP_ALL,
172 STATS_COMP_NONE,
173 MAX_STATS_POLICY,
174};
175
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800176enum msm_isp_stats_type {
177 MSM_ISP_STATS_AEC, /* legacy based AEC */
178 MSM_ISP_STATS_AF, /* legacy based AF */
179 MSM_ISP_STATS_AWB, /* legacy based AWB */
180 MSM_ISP_STATS_RS, /* legacy based RS */
181 MSM_ISP_STATS_CS, /* legacy based CS */
182 MSM_ISP_STATS_IHIST, /* legacy based HIST */
183 MSM_ISP_STATS_SKIN, /* legacy based SKIN */
184 MSM_ISP_STATS_BG, /* Bayer Grids */
185 MSM_ISP_STATS_BF, /* Bayer Focus */
186 MSM_ISP_STATS_BE, /* Bayer Exposure*/
187 MSM_ISP_STATS_BHIST, /* Bayer Hist */
188 MSM_ISP_STATS_MAX /* MAX */
189};
190
191struct msm_vfe_stats_stream_request_cmd {
192 uint32_t session_id;
193 uint32_t stream_id;
194 enum msm_isp_stats_type stats_type;
Mingcheng Zhu503a6f92013-01-06 13:23:24 -0800195 uint32_t framedrop_pattern;
Kevin Chan3454e2b2013-01-17 19:18:57 -0800196 uint32_t irq_subsample_pattern;
Kevin Chance198ee2013-03-14 18:47:18 -0700197 uint32_t buffer_offset;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800198 uint32_t stream_handle;
Kevin Chan3454e2b2013-01-17 19:18:57 -0800199 uint8_t comp_flag;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800200};
Kevin Chan3454e2b2013-01-17 19:18:57 -0800201
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800202struct msm_vfe_stats_stream_release_cmd {
203 uint32_t stream_handle;
204};
205struct msm_vfe_stats_stream_cfg_cmd {
206 uint8_t num_streams;
207 uint32_t stream_handle[MSM_ISP_STATS_MAX];
208 uint8_t enable;
209};
Kevin Chan3454e2b2013-01-17 19:18:57 -0800210
211struct msm_vfe_stats_comp_policy_cfg {
212 enum msm_vfe_stats_pipeline_policy stats_pipeline_policy;
213 uint32_t comp_framedrop_pattern;
214 uint32_t comp_irq_subsample_pattern;
215};
216
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800217enum msm_vfe_reg_cfg_type {
218 VFE_WRITE,
219 VFE_WRITE_MB,
220 VFE_READ,
Kevin Chan7672ef32013-01-21 22:10:53 -0800221 VFE_CFG_MASK,
222 VFE_WRITE_DMI_16BIT,
223 VFE_WRITE_DMI_32BIT,
224 VFE_WRITE_DMI_64BIT,
225 VFE_READ_DMI_16BIT,
226 VFE_READ_DMI_32BIT,
227 VFE_READ_DMI_64BIT,
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800228};
229
230struct msm_vfe_cfg_cmd2 {
231 uint16_t num_cfg;
232 uint16_t cmd_len;
233 void __user *cfg_data;
234 void __user *cfg_cmd;
235};
236
Kevin Chan7672ef32013-01-21 22:10:53 -0800237struct msm_vfe_reg_rw_info {
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800238 uint32_t reg_offset;
Kevin Chan7672ef32013-01-21 22:10:53 -0800239 uint32_t cmd_data_offset;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800240 uint32_t len;
Kevin Chan7672ef32013-01-21 22:10:53 -0800241};
242
243struct msm_vfe_reg_mask_info {
244 uint32_t reg_offset;
245 uint32_t mask;
246 uint32_t val;
247};
248
249struct msm_vfe_reg_dmi_info {
250 uint32_t hi_tbl_offset; /*Optional*/
251 uint32_t lo_tbl_offset; /*Required*/
252 uint32_t len;
253};
254
255struct msm_vfe_reg_cfg_cmd {
256 union {
257 struct msm_vfe_reg_rw_info rw_info;
258 struct msm_vfe_reg_mask_info mask_info;
259 struct msm_vfe_reg_dmi_info dmi_info;
260 } u;
261
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800262 enum msm_vfe_reg_cfg_type cmd_type;
263};
264
Kevin Chanbaf0a132013-03-05 20:08:23 -0800265enum msm_isp_buf_type {
266 ISP_PRIVATE_BUF,
267 ISP_SHARE_BUF,
268 MAX_ISP_BUF_TYPE,
269};
270
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800271struct msm_isp_buf_request {
272 uint32_t session_id;
273 uint32_t stream_id;
274 uint8_t num_buf;
275 uint32_t handle;
Kevin Chanbaf0a132013-03-05 20:08:23 -0800276 enum msm_isp_buf_type buf_type;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800277};
278
279struct msm_isp_qbuf_info {
280 uint32_t handle;
281 int buf_idx;
282 /*Only used for prepare buffer*/
283 struct v4l2_buffer buffer;
Kevin Chan5bebd2e2013-01-30 20:25:05 -0800284 /*Only used for diverted buffer*/
285 uint32_t dirty_buf;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800286};
287
288struct msm_vfe_axi_src_state {
289 enum msm_vfe_input_src input_src;
290 uint32_t src_active;
291};
292
293enum msm_isp_event_idx {
294 ISP_REG_UPDATE = 0,
295 ISP_START_ACK = 1,
296 ISP_STOP_ACK = 2,
297 ISP_IRQ_VIOLATION = 3,
298 ISP_WM_BUS_OVERFLOW = 4,
299 ISP_STATS_OVERFLOW = 5,
300 ISP_CAMIF_ERROR = 6,
Kevin Chan9c74c522013-02-06 22:27:47 -0800301 ISP_SOF = 7,
302 ISP_EOF = 8,
303 ISP_EVENT_MAX = 9
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800304};
305
Kevin Chan9c74c522013-02-06 22:27:47 -0800306#define ISP_EVENT_OFFSET 8
307#define ISP_EVENT_BASE (V4L2_EVENT_PRIVATE_START)
308#define ISP_BUF_EVENT_BASE (ISP_EVENT_BASE + (1 << ISP_EVENT_OFFSET))
309#define ISP_STATS_EVENT_BASE (ISP_EVENT_BASE + (2 << ISP_EVENT_OFFSET))
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800310#define ISP_EVENT_REG_UPDATE (ISP_EVENT_BASE + ISP_REG_UPDATE)
311#define ISP_EVENT_START_ACK (ISP_EVENT_BASE + ISP_START_ACK)
312#define ISP_EVENT_STOP_ACK (ISP_EVENT_BASE + ISP_STOP_ACK)
313#define ISP_EVENT_IRQ_VIOLATION (ISP_EVENT_BASE + ISP_IRQ_VIOLATION)
314#define ISP_EVENT_WM_BUS_OVERFLOW (ISP_EVENT_BASE + ISP_WM_BUS_OVERFLOW)
315#define ISP_EVENT_STATS_OVERFLOW (ISP_EVENT_BASE + ISP_STATS_OVERFLOW)
316#define ISP_EVENT_CAMIF_ERROR (ISP_EVENT_BASE + ISP_CAMIF_ERROR)
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800317#define ISP_EVENT_SOF (ISP_EVENT_BASE + ISP_SOF)
318#define ISP_EVENT_EOF (ISP_EVENT_BASE + ISP_EOF)
Kevin Chan9c74c522013-02-06 22:27:47 -0800319#define ISP_EVENT_BUF_DIVERT (ISP_BUF_EVENT_BASE)
320#define ISP_EVENT_STATS_NOTIFY (ISP_STATS_EVENT_BASE)
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800321
322/* The msm_v4l2_event_data structure should match the
323 * v4l2_event.u.data field.
324 * should not exceed 64 bytes */
325
326struct msm_isp_buf_event {
327 uint32_t session_id;
328 uint32_t stream_id;
329 uint32_t handle;
330 int8_t buf_idx;
331};
332struct msm_isp_stats_event {
333 uint32_t stats_mask; /* 4 bytes */
334 uint8_t stats_buf_idxs[MSM_ISP_STATS_MAX]; /* 11 bytes */
335};
336
337struct msm_isp_stream_ack {
338 uint32_t session_id;
339 uint32_t stream_id;
340 uint32_t handle;
341};
342
343struct msm_isp_event_data {
Kevin Chan9f7785c2013-02-22 22:09:57 -0800344 /*Wall clock except for buffer divert events
345 *which use monotonic clock
346 */
347 struct timeval timestamp;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800348 /* if pix is a src frame_id is from camif */
349 uint32_t frame_id;
350 union {
351 /* START_ACK, STOP_ACK */
352 struct msm_isp_stream_ack stream_ack;
353 /* REG_UPDATE_TRIGGER, bus over flow */
354 enum msm_vfe_input_src input_src;
355 /* stats notify */
356 struct msm_isp_stats_event stats;
357 /* IRQ_VIOLATION, STATS_OVER_FLOW, WM_OVER_FLOW */
358 uint32_t irq_status_mask;
359 struct msm_isp_buf_event buf_done;
360 } u; /* union can have max 52 bytes */
361};
362
Kevin Chan80b7b6d2013-01-31 16:08:35 -0800363#define V4L2_PIX_FMT_QBGGR8 v4l2_fourcc('Q', 'B', 'G', '8')
364#define V4L2_PIX_FMT_QGBRG8 v4l2_fourcc('Q', 'G', 'B', '8')
365#define V4L2_PIX_FMT_QGRBG8 v4l2_fourcc('Q', 'G', 'R', '8')
366#define V4L2_PIX_FMT_QRGGB8 v4l2_fourcc('Q', 'R', 'G', '8')
367#define V4L2_PIX_FMT_QBGGR10 v4l2_fourcc('Q', 'B', 'G', '0')
368#define V4L2_PIX_FMT_QGBRG10 v4l2_fourcc('Q', 'G', 'B', '0')
369#define V4L2_PIX_FMT_QGRBG10 v4l2_fourcc('Q', 'G', 'R', '0')
370#define V4L2_PIX_FMT_QRGGB10 v4l2_fourcc('Q', 'R', 'G', '0')
371#define V4L2_PIX_FMT_QBGGR12 v4l2_fourcc('Q', 'B', 'G', '2')
372#define V4L2_PIX_FMT_QGBRG12 v4l2_fourcc('Q', 'G', 'B', '2')
373#define V4L2_PIX_FMT_QGRBG12 v4l2_fourcc('Q', 'G', 'R', '2')
374#define V4L2_PIX_FMT_QRGGB12 v4l2_fourcc('Q', 'R', 'G', '2')
375
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800376#define VIDIOC_MSM_VFE_REG_CFG \
377 _IOWR('V', BASE_VIDIOC_PRIVATE, struct msm_vfe_cfg_cmd2)
378
379#define VIDIOC_MSM_ISP_REQUEST_BUF \
380 _IOWR('V', BASE_VIDIOC_PRIVATE+1, struct msm_isp_buf_request)
381
382#define VIDIOC_MSM_ISP_ENQUEUE_BUF \
383 _IOWR('V', BASE_VIDIOC_PRIVATE+2, struct msm_isp_qbuf_info)
384
385#define VIDIOC_MSM_ISP_RELEASE_BUF \
386 _IOWR('V', BASE_VIDIOC_PRIVATE+3, struct msm_isp_buf_request)
387
388#define VIDIOC_MSM_ISP_REQUEST_STREAM \
389 _IOWR('V', BASE_VIDIOC_PRIVATE+4, struct msm_vfe_axi_stream_request_cmd)
390
391#define VIDIOC_MSM_ISP_CFG_STREAM \
392 _IOWR('V', BASE_VIDIOC_PRIVATE+5, struct msm_vfe_axi_stream_cfg_cmd)
393
394#define VIDIOC_MSM_ISP_RELEASE_STREAM \
395 _IOWR('V', BASE_VIDIOC_PRIVATE+6, struct msm_vfe_axi_stream_release_cmd)
396
397#define VIDIOC_MSM_ISP_INPUT_CFG \
398 _IOWR('V', BASE_VIDIOC_PRIVATE+7, struct msm_vfe_input_cfg)
399
400#define VIDIOC_MSM_ISP_SET_SRC_STATE \
401 _IOWR('V', BASE_VIDIOC_PRIVATE+8, struct msm_vfe_axi_src_state)
402
403#define VIDIOC_MSM_ISP_REQUEST_STATS_STREAM \
404 _IOWR('V', BASE_VIDIOC_PRIVATE+9, \
405 struct msm_vfe_stats_stream_request_cmd)
406
407#define VIDIOC_MSM_ISP_CFG_STATS_STREAM \
408 _IOWR('V', BASE_VIDIOC_PRIVATE+10, struct msm_vfe_stats_stream_cfg_cmd)
409
410#define VIDIOC_MSM_ISP_RELEASE_STATS_STREAM \
411 _IOWR('V', BASE_VIDIOC_PRIVATE+11, \
412 struct msm_vfe_stats_stream_release_cmd)
413
Kevin Chan3454e2b2013-01-17 19:18:57 -0800414#define VIDIOC_MSM_ISP_CFG_STATS_COMP_POLICY \
415 _IOWR('V', BASE_VIDIOC_PRIVATE+12, \
416 struct msm_vfe_stats_comp_policy_cfg)
417
Kevin Chan5bebd2e2013-01-30 20:25:05 -0800418#define VIDIOC_MSM_ISP_UPDATE_STREAM \
419 _IOWR('V', BASE_VIDIOC_PRIVATE+13, struct msm_vfe_axi_stream_update_cmd)
420
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800421#endif /* __MSMB_ISP__ */