blob: 6fb1a6542ebf714231b82fee735caac8ddee2368 [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 Chan9a8301b12013-03-18 15:39:37 -0700112 uint32_t input_pix_clk;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800113};
114
115struct msm_vfe_axi_plane_cfg {
116 uint32_t output_width; /*Include padding*/
117 uint32_t output_height;
118 uint32_t output_stride;
119 uint32_t output_scan_lines;
120 uint32_t output_plane_format; /*Y/Cb/Cr/CbCr*/
Kevin Chanbaf0a132013-03-05 20:08:23 -0800121 uint32_t plane_addr_offset;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800122 uint8_t csid_src; /*RDI 0-2*/
123 uint8_t rdi_cid;/*CID 1-16*/
124};
125
126struct msm_vfe_axi_stream_request_cmd {
127 uint32_t session_id;
128 uint32_t stream_id;
129 uint32_t output_format;/*Planar/RAW/Misc*/
130 enum msm_vfe_axi_stream_src stream_src; /*CAMIF/IDEAL/RDIs*/
131 struct msm_vfe_axi_plane_cfg plane_cfg[MAX_PLANES_PER_STREAM];
132
133 uint32_t burst_count;
134 uint32_t hfr_mode;
135 uint8_t frame_base;
136
137 uint32_t init_frame_drop; /*MAX 31 Frames*/
138 enum msm_vfe_frame_skip_pattern frame_skip_pattern;
139 uint8_t buf_divert; /* if TRUE no vb2 buf done. */
140 /*Return values*/
141 uint32_t axi_stream_handle;
142};
143
144struct msm_vfe_axi_stream_release_cmd {
145 uint32_t stream_handle;
146};
147
148enum msm_vfe_axi_stream_cmd {
149 STOP_STREAM,
150 START_STREAM,
151};
152
153struct msm_vfe_axi_stream_cfg_cmd {
154 uint8_t num_streams;
155 uint32_t stream_handle[MAX_NUM_STREAM];
156 enum msm_vfe_axi_stream_cmd cmd;
157};
158
Kevin Chan5bebd2e2013-01-30 20:25:05 -0800159enum msm_vfe_axi_stream_update_type {
160 ENABLE_STREAM_BUF_DIVERT,
161 DISABLE_STREAM_BUF_DIVERT,
162 UPDATE_STREAM_FRAMEDROP_PATTERN,
163};
164
165struct msm_vfe_axi_stream_update_cmd {
166 uint32_t stream_handle;
167 enum msm_vfe_axi_stream_update_type update_type;
168 enum msm_vfe_frame_skip_pattern skip_pattern;
169};
170
Kevin Chan3454e2b2013-01-17 19:18:57 -0800171enum msm_vfe_stats_pipeline_policy {
172 STATS_COMP_ALL,
173 STATS_COMP_NONE,
174 MAX_STATS_POLICY,
175};
176
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800177enum msm_isp_stats_type {
178 MSM_ISP_STATS_AEC, /* legacy based AEC */
179 MSM_ISP_STATS_AF, /* legacy based AF */
180 MSM_ISP_STATS_AWB, /* legacy based AWB */
181 MSM_ISP_STATS_RS, /* legacy based RS */
182 MSM_ISP_STATS_CS, /* legacy based CS */
183 MSM_ISP_STATS_IHIST, /* legacy based HIST */
184 MSM_ISP_STATS_SKIN, /* legacy based SKIN */
185 MSM_ISP_STATS_BG, /* Bayer Grids */
186 MSM_ISP_STATS_BF, /* Bayer Focus */
187 MSM_ISP_STATS_BE, /* Bayer Exposure*/
188 MSM_ISP_STATS_BHIST, /* Bayer Hist */
189 MSM_ISP_STATS_MAX /* MAX */
190};
191
192struct msm_vfe_stats_stream_request_cmd {
193 uint32_t session_id;
194 uint32_t stream_id;
195 enum msm_isp_stats_type stats_type;
Mingcheng Zhu503a6f92013-01-06 13:23:24 -0800196 uint32_t framedrop_pattern;
Kevin Chan3454e2b2013-01-17 19:18:57 -0800197 uint32_t irq_subsample_pattern;
Kevin Chance198ee2013-03-14 18:47:18 -0700198 uint32_t buffer_offset;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800199 uint32_t stream_handle;
Kevin Chan3454e2b2013-01-17 19:18:57 -0800200 uint8_t comp_flag;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800201};
Kevin Chan3454e2b2013-01-17 19:18:57 -0800202
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800203struct msm_vfe_stats_stream_release_cmd {
204 uint32_t stream_handle;
205};
206struct msm_vfe_stats_stream_cfg_cmd {
207 uint8_t num_streams;
208 uint32_t stream_handle[MSM_ISP_STATS_MAX];
209 uint8_t enable;
210};
Kevin Chan3454e2b2013-01-17 19:18:57 -0800211
212struct msm_vfe_stats_comp_policy_cfg {
213 enum msm_vfe_stats_pipeline_policy stats_pipeline_policy;
214 uint32_t comp_framedrop_pattern;
215 uint32_t comp_irq_subsample_pattern;
216};
217
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800218enum msm_vfe_reg_cfg_type {
219 VFE_WRITE,
220 VFE_WRITE_MB,
221 VFE_READ,
Kevin Chan7672ef32013-01-21 22:10:53 -0800222 VFE_CFG_MASK,
223 VFE_WRITE_DMI_16BIT,
224 VFE_WRITE_DMI_32BIT,
225 VFE_WRITE_DMI_64BIT,
226 VFE_READ_DMI_16BIT,
227 VFE_READ_DMI_32BIT,
228 VFE_READ_DMI_64BIT,
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800229};
230
231struct msm_vfe_cfg_cmd2 {
232 uint16_t num_cfg;
233 uint16_t cmd_len;
234 void __user *cfg_data;
235 void __user *cfg_cmd;
236};
237
Kevin Chan7672ef32013-01-21 22:10:53 -0800238struct msm_vfe_reg_rw_info {
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800239 uint32_t reg_offset;
Kevin Chan7672ef32013-01-21 22:10:53 -0800240 uint32_t cmd_data_offset;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800241 uint32_t len;
Kevin Chan7672ef32013-01-21 22:10:53 -0800242};
243
244struct msm_vfe_reg_mask_info {
245 uint32_t reg_offset;
246 uint32_t mask;
247 uint32_t val;
248};
249
250struct msm_vfe_reg_dmi_info {
251 uint32_t hi_tbl_offset; /*Optional*/
252 uint32_t lo_tbl_offset; /*Required*/
253 uint32_t len;
254};
255
256struct msm_vfe_reg_cfg_cmd {
257 union {
258 struct msm_vfe_reg_rw_info rw_info;
259 struct msm_vfe_reg_mask_info mask_info;
260 struct msm_vfe_reg_dmi_info dmi_info;
261 } u;
262
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800263 enum msm_vfe_reg_cfg_type cmd_type;
264};
265
Kevin Chanbaf0a132013-03-05 20:08:23 -0800266enum msm_isp_buf_type {
267 ISP_PRIVATE_BUF,
268 ISP_SHARE_BUF,
269 MAX_ISP_BUF_TYPE,
270};
271
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800272struct msm_isp_buf_request {
273 uint32_t session_id;
274 uint32_t stream_id;
275 uint8_t num_buf;
276 uint32_t handle;
Kevin Chanbaf0a132013-03-05 20:08:23 -0800277 enum msm_isp_buf_type buf_type;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800278};
279
280struct msm_isp_qbuf_info {
281 uint32_t handle;
282 int buf_idx;
283 /*Only used for prepare buffer*/
284 struct v4l2_buffer buffer;
Kevin Chan5bebd2e2013-01-30 20:25:05 -0800285 /*Only used for diverted buffer*/
286 uint32_t dirty_buf;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800287};
288
289struct msm_vfe_axi_src_state {
290 enum msm_vfe_input_src input_src;
291 uint32_t src_active;
292};
293
294enum msm_isp_event_idx {
295 ISP_REG_UPDATE = 0,
296 ISP_START_ACK = 1,
297 ISP_STOP_ACK = 2,
298 ISP_IRQ_VIOLATION = 3,
299 ISP_WM_BUS_OVERFLOW = 4,
300 ISP_STATS_OVERFLOW = 5,
301 ISP_CAMIF_ERROR = 6,
Kevin Chan9c74c522013-02-06 22:27:47 -0800302 ISP_SOF = 7,
303 ISP_EOF = 8,
304 ISP_EVENT_MAX = 9
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800305};
306
Kevin Chan9c74c522013-02-06 22:27:47 -0800307#define ISP_EVENT_OFFSET 8
308#define ISP_EVENT_BASE (V4L2_EVENT_PRIVATE_START)
309#define ISP_BUF_EVENT_BASE (ISP_EVENT_BASE + (1 << ISP_EVENT_OFFSET))
310#define ISP_STATS_EVENT_BASE (ISP_EVENT_BASE + (2 << ISP_EVENT_OFFSET))
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800311#define ISP_EVENT_REG_UPDATE (ISP_EVENT_BASE + ISP_REG_UPDATE)
312#define ISP_EVENT_START_ACK (ISP_EVENT_BASE + ISP_START_ACK)
313#define ISP_EVENT_STOP_ACK (ISP_EVENT_BASE + ISP_STOP_ACK)
314#define ISP_EVENT_IRQ_VIOLATION (ISP_EVENT_BASE + ISP_IRQ_VIOLATION)
315#define ISP_EVENT_WM_BUS_OVERFLOW (ISP_EVENT_BASE + ISP_WM_BUS_OVERFLOW)
316#define ISP_EVENT_STATS_OVERFLOW (ISP_EVENT_BASE + ISP_STATS_OVERFLOW)
317#define ISP_EVENT_CAMIF_ERROR (ISP_EVENT_BASE + ISP_CAMIF_ERROR)
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800318#define ISP_EVENT_SOF (ISP_EVENT_BASE + ISP_SOF)
319#define ISP_EVENT_EOF (ISP_EVENT_BASE + ISP_EOF)
Kevin Chan9c74c522013-02-06 22:27:47 -0800320#define ISP_EVENT_BUF_DIVERT (ISP_BUF_EVENT_BASE)
321#define ISP_EVENT_STATS_NOTIFY (ISP_STATS_EVENT_BASE)
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800322
323/* The msm_v4l2_event_data structure should match the
324 * v4l2_event.u.data field.
325 * should not exceed 64 bytes */
326
327struct msm_isp_buf_event {
328 uint32_t session_id;
329 uint32_t stream_id;
330 uint32_t handle;
331 int8_t buf_idx;
332};
333struct msm_isp_stats_event {
334 uint32_t stats_mask; /* 4 bytes */
335 uint8_t stats_buf_idxs[MSM_ISP_STATS_MAX]; /* 11 bytes */
336};
337
338struct msm_isp_stream_ack {
339 uint32_t session_id;
340 uint32_t stream_id;
341 uint32_t handle;
342};
343
344struct msm_isp_event_data {
Kevin Chan9f7785c2013-02-22 22:09:57 -0800345 /*Wall clock except for buffer divert events
346 *which use monotonic clock
347 */
348 struct timeval timestamp;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800349 /* if pix is a src frame_id is from camif */
350 uint32_t frame_id;
351 union {
352 /* START_ACK, STOP_ACK */
353 struct msm_isp_stream_ack stream_ack;
354 /* REG_UPDATE_TRIGGER, bus over flow */
355 enum msm_vfe_input_src input_src;
356 /* stats notify */
357 struct msm_isp_stats_event stats;
358 /* IRQ_VIOLATION, STATS_OVER_FLOW, WM_OVER_FLOW */
359 uint32_t irq_status_mask;
360 struct msm_isp_buf_event buf_done;
361 } u; /* union can have max 52 bytes */
362};
363
Kevin Chan80b7b6d2013-01-31 16:08:35 -0800364#define V4L2_PIX_FMT_QBGGR8 v4l2_fourcc('Q', 'B', 'G', '8')
365#define V4L2_PIX_FMT_QGBRG8 v4l2_fourcc('Q', 'G', 'B', '8')
366#define V4L2_PIX_FMT_QGRBG8 v4l2_fourcc('Q', 'G', 'R', '8')
367#define V4L2_PIX_FMT_QRGGB8 v4l2_fourcc('Q', 'R', 'G', '8')
368#define V4L2_PIX_FMT_QBGGR10 v4l2_fourcc('Q', 'B', 'G', '0')
369#define V4L2_PIX_FMT_QGBRG10 v4l2_fourcc('Q', 'G', 'B', '0')
370#define V4L2_PIX_FMT_QGRBG10 v4l2_fourcc('Q', 'G', 'R', '0')
371#define V4L2_PIX_FMT_QRGGB10 v4l2_fourcc('Q', 'R', 'G', '0')
372#define V4L2_PIX_FMT_QBGGR12 v4l2_fourcc('Q', 'B', 'G', '2')
373#define V4L2_PIX_FMT_QGBRG12 v4l2_fourcc('Q', 'G', 'B', '2')
374#define V4L2_PIX_FMT_QGRBG12 v4l2_fourcc('Q', 'G', 'R', '2')
375#define V4L2_PIX_FMT_QRGGB12 v4l2_fourcc('Q', 'R', 'G', '2')
376
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800377#define VIDIOC_MSM_VFE_REG_CFG \
378 _IOWR('V', BASE_VIDIOC_PRIVATE, struct msm_vfe_cfg_cmd2)
379
380#define VIDIOC_MSM_ISP_REQUEST_BUF \
381 _IOWR('V', BASE_VIDIOC_PRIVATE+1, struct msm_isp_buf_request)
382
383#define VIDIOC_MSM_ISP_ENQUEUE_BUF \
384 _IOWR('V', BASE_VIDIOC_PRIVATE+2, struct msm_isp_qbuf_info)
385
386#define VIDIOC_MSM_ISP_RELEASE_BUF \
387 _IOWR('V', BASE_VIDIOC_PRIVATE+3, struct msm_isp_buf_request)
388
389#define VIDIOC_MSM_ISP_REQUEST_STREAM \
390 _IOWR('V', BASE_VIDIOC_PRIVATE+4, struct msm_vfe_axi_stream_request_cmd)
391
392#define VIDIOC_MSM_ISP_CFG_STREAM \
393 _IOWR('V', BASE_VIDIOC_PRIVATE+5, struct msm_vfe_axi_stream_cfg_cmd)
394
395#define VIDIOC_MSM_ISP_RELEASE_STREAM \
396 _IOWR('V', BASE_VIDIOC_PRIVATE+6, struct msm_vfe_axi_stream_release_cmd)
397
398#define VIDIOC_MSM_ISP_INPUT_CFG \
399 _IOWR('V', BASE_VIDIOC_PRIVATE+7, struct msm_vfe_input_cfg)
400
401#define VIDIOC_MSM_ISP_SET_SRC_STATE \
402 _IOWR('V', BASE_VIDIOC_PRIVATE+8, struct msm_vfe_axi_src_state)
403
404#define VIDIOC_MSM_ISP_REQUEST_STATS_STREAM \
405 _IOWR('V', BASE_VIDIOC_PRIVATE+9, \
406 struct msm_vfe_stats_stream_request_cmd)
407
408#define VIDIOC_MSM_ISP_CFG_STATS_STREAM \
409 _IOWR('V', BASE_VIDIOC_PRIVATE+10, struct msm_vfe_stats_stream_cfg_cmd)
410
411#define VIDIOC_MSM_ISP_RELEASE_STATS_STREAM \
412 _IOWR('V', BASE_VIDIOC_PRIVATE+11, \
413 struct msm_vfe_stats_stream_release_cmd)
414
Kevin Chan3454e2b2013-01-17 19:18:57 -0800415#define VIDIOC_MSM_ISP_CFG_STATS_COMP_POLICY \
416 _IOWR('V', BASE_VIDIOC_PRIVATE+12, \
417 struct msm_vfe_stats_comp_policy_cfg)
418
Kevin Chan5bebd2e2013-01-30 20:25:05 -0800419#define VIDIOC_MSM_ISP_UPDATE_STREAM \
420 _IOWR('V', BASE_VIDIOC_PRIVATE+13, struct msm_vfe_axi_stream_update_cmd)
421
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800422#endif /* __MSMB_ISP__ */