blob: bf6b23bd5bc13dbd70ca763f2cb2bcf885b2da4e [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 Chan1d5fd4a2013-01-11 14:08:14 -0800171enum msm_isp_stats_type {
172 MSM_ISP_STATS_AEC, /* legacy based AEC */
173 MSM_ISP_STATS_AF, /* legacy based AF */
174 MSM_ISP_STATS_AWB, /* legacy based AWB */
175 MSM_ISP_STATS_RS, /* legacy based RS */
176 MSM_ISP_STATS_CS, /* legacy based CS */
177 MSM_ISP_STATS_IHIST, /* legacy based HIST */
178 MSM_ISP_STATS_SKIN, /* legacy based SKIN */
179 MSM_ISP_STATS_BG, /* Bayer Grids */
180 MSM_ISP_STATS_BF, /* Bayer Focus */
181 MSM_ISP_STATS_BE, /* Bayer Exposure*/
182 MSM_ISP_STATS_BHIST, /* Bayer Hist */
183 MSM_ISP_STATS_MAX /* MAX */
184};
185
186struct msm_vfe_stats_stream_request_cmd {
187 uint32_t session_id;
188 uint32_t stream_id;
189 enum msm_isp_stats_type stats_type;
Kevin Chan1f152492013-03-21 23:36:48 -0700190 uint32_t composite_flag;
Mingcheng Zhu503a6f92013-01-06 13:23:24 -0800191 uint32_t framedrop_pattern;
Kevin Chan3454e2b2013-01-17 19:18:57 -0800192 uint32_t irq_subsample_pattern;
Kevin Chance198ee2013-03-14 18:47:18 -0700193 uint32_t buffer_offset;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800194 uint32_t stream_handle;
195};
Kevin Chan3454e2b2013-01-17 19:18:57 -0800196
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800197struct msm_vfe_stats_stream_release_cmd {
198 uint32_t stream_handle;
199};
200struct msm_vfe_stats_stream_cfg_cmd {
201 uint8_t num_streams;
202 uint32_t stream_handle[MSM_ISP_STATS_MAX];
203 uint8_t enable;
204};
Kevin Chan3454e2b2013-01-17 19:18:57 -0800205
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800206enum msm_vfe_reg_cfg_type {
207 VFE_WRITE,
208 VFE_WRITE_MB,
209 VFE_READ,
Kevin Chan7672ef32013-01-21 22:10:53 -0800210 VFE_CFG_MASK,
211 VFE_WRITE_DMI_16BIT,
212 VFE_WRITE_DMI_32BIT,
213 VFE_WRITE_DMI_64BIT,
214 VFE_READ_DMI_16BIT,
215 VFE_READ_DMI_32BIT,
216 VFE_READ_DMI_64BIT,
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800217};
218
219struct msm_vfe_cfg_cmd2 {
220 uint16_t num_cfg;
221 uint16_t cmd_len;
222 void __user *cfg_data;
223 void __user *cfg_cmd;
224};
225
Kevin Chan7672ef32013-01-21 22:10:53 -0800226struct msm_vfe_reg_rw_info {
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800227 uint32_t reg_offset;
Kevin Chan7672ef32013-01-21 22:10:53 -0800228 uint32_t cmd_data_offset;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800229 uint32_t len;
Kevin Chan7672ef32013-01-21 22:10:53 -0800230};
231
232struct msm_vfe_reg_mask_info {
233 uint32_t reg_offset;
234 uint32_t mask;
235 uint32_t val;
236};
237
238struct msm_vfe_reg_dmi_info {
239 uint32_t hi_tbl_offset; /*Optional*/
240 uint32_t lo_tbl_offset; /*Required*/
241 uint32_t len;
242};
243
244struct msm_vfe_reg_cfg_cmd {
245 union {
246 struct msm_vfe_reg_rw_info rw_info;
247 struct msm_vfe_reg_mask_info mask_info;
248 struct msm_vfe_reg_dmi_info dmi_info;
249 } u;
250
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800251 enum msm_vfe_reg_cfg_type cmd_type;
252};
253
Kevin Chanbaf0a132013-03-05 20:08:23 -0800254enum msm_isp_buf_type {
255 ISP_PRIVATE_BUF,
256 ISP_SHARE_BUF,
257 MAX_ISP_BUF_TYPE,
258};
259
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800260struct msm_isp_buf_request {
261 uint32_t session_id;
262 uint32_t stream_id;
263 uint8_t num_buf;
264 uint32_t handle;
Kevin Chanbaf0a132013-03-05 20:08:23 -0800265 enum msm_isp_buf_type buf_type;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800266};
267
268struct msm_isp_qbuf_info {
269 uint32_t handle;
270 int buf_idx;
271 /*Only used for prepare buffer*/
272 struct v4l2_buffer buffer;
Kevin Chan5bebd2e2013-01-30 20:25:05 -0800273 /*Only used for diverted buffer*/
274 uint32_t dirty_buf;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800275};
276
277struct msm_vfe_axi_src_state {
278 enum msm_vfe_input_src input_src;
279 uint32_t src_active;
280};
281
282enum msm_isp_event_idx {
283 ISP_REG_UPDATE = 0,
284 ISP_START_ACK = 1,
285 ISP_STOP_ACK = 2,
286 ISP_IRQ_VIOLATION = 3,
287 ISP_WM_BUS_OVERFLOW = 4,
288 ISP_STATS_OVERFLOW = 5,
289 ISP_CAMIF_ERROR = 6,
Kevin Chan9c74c522013-02-06 22:27:47 -0800290 ISP_SOF = 7,
291 ISP_EOF = 8,
292 ISP_EVENT_MAX = 9
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800293};
294
Kevin Chan9c74c522013-02-06 22:27:47 -0800295#define ISP_EVENT_OFFSET 8
296#define ISP_EVENT_BASE (V4L2_EVENT_PRIVATE_START)
297#define ISP_BUF_EVENT_BASE (ISP_EVENT_BASE + (1 << ISP_EVENT_OFFSET))
298#define ISP_STATS_EVENT_BASE (ISP_EVENT_BASE + (2 << ISP_EVENT_OFFSET))
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800299#define ISP_EVENT_REG_UPDATE (ISP_EVENT_BASE + ISP_REG_UPDATE)
300#define ISP_EVENT_START_ACK (ISP_EVENT_BASE + ISP_START_ACK)
301#define ISP_EVENT_STOP_ACK (ISP_EVENT_BASE + ISP_STOP_ACK)
302#define ISP_EVENT_IRQ_VIOLATION (ISP_EVENT_BASE + ISP_IRQ_VIOLATION)
303#define ISP_EVENT_WM_BUS_OVERFLOW (ISP_EVENT_BASE + ISP_WM_BUS_OVERFLOW)
304#define ISP_EVENT_STATS_OVERFLOW (ISP_EVENT_BASE + ISP_STATS_OVERFLOW)
305#define ISP_EVENT_CAMIF_ERROR (ISP_EVENT_BASE + ISP_CAMIF_ERROR)
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800306#define ISP_EVENT_SOF (ISP_EVENT_BASE + ISP_SOF)
307#define ISP_EVENT_EOF (ISP_EVENT_BASE + ISP_EOF)
Kevin Chan9c74c522013-02-06 22:27:47 -0800308#define ISP_EVENT_BUF_DIVERT (ISP_BUF_EVENT_BASE)
309#define ISP_EVENT_STATS_NOTIFY (ISP_STATS_EVENT_BASE)
Kevin Chan1f152492013-03-21 23:36:48 -0700310#define ISP_EVENT_COMP_STATS_NOTIFY (ISP_EVENT_STATS_NOTIFY + MSM_ISP_STATS_MAX)
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800311/* The msm_v4l2_event_data structure should match the
312 * v4l2_event.u.data field.
313 * should not exceed 64 bytes */
314
315struct msm_isp_buf_event {
316 uint32_t session_id;
317 uint32_t stream_id;
318 uint32_t handle;
319 int8_t buf_idx;
320};
321struct msm_isp_stats_event {
322 uint32_t stats_mask; /* 4 bytes */
323 uint8_t stats_buf_idxs[MSM_ISP_STATS_MAX]; /* 11 bytes */
324};
325
326struct msm_isp_stream_ack {
327 uint32_t session_id;
328 uint32_t stream_id;
329 uint32_t handle;
330};
331
332struct msm_isp_event_data {
Kevin Chan9f7785c2013-02-22 22:09:57 -0800333 /*Wall clock except for buffer divert events
334 *which use monotonic clock
335 */
336 struct timeval timestamp;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800337 /* if pix is a src frame_id is from camif */
338 uint32_t frame_id;
339 union {
340 /* START_ACK, STOP_ACK */
341 struct msm_isp_stream_ack stream_ack;
342 /* REG_UPDATE_TRIGGER, bus over flow */
343 enum msm_vfe_input_src input_src;
344 /* stats notify */
345 struct msm_isp_stats_event stats;
346 /* IRQ_VIOLATION, STATS_OVER_FLOW, WM_OVER_FLOW */
347 uint32_t irq_status_mask;
348 struct msm_isp_buf_event buf_done;
349 } u; /* union can have max 52 bytes */
350};
351
Kevin Chan80b7b6d2013-01-31 16:08:35 -0800352#define V4L2_PIX_FMT_QBGGR8 v4l2_fourcc('Q', 'B', 'G', '8')
353#define V4L2_PIX_FMT_QGBRG8 v4l2_fourcc('Q', 'G', 'B', '8')
354#define V4L2_PIX_FMT_QGRBG8 v4l2_fourcc('Q', 'G', 'R', '8')
355#define V4L2_PIX_FMT_QRGGB8 v4l2_fourcc('Q', 'R', 'G', '8')
356#define V4L2_PIX_FMT_QBGGR10 v4l2_fourcc('Q', 'B', 'G', '0')
357#define V4L2_PIX_FMT_QGBRG10 v4l2_fourcc('Q', 'G', 'B', '0')
358#define V4L2_PIX_FMT_QGRBG10 v4l2_fourcc('Q', 'G', 'R', '0')
359#define V4L2_PIX_FMT_QRGGB10 v4l2_fourcc('Q', 'R', 'G', '0')
360#define V4L2_PIX_FMT_QBGGR12 v4l2_fourcc('Q', 'B', 'G', '2')
361#define V4L2_PIX_FMT_QGBRG12 v4l2_fourcc('Q', 'G', 'B', '2')
362#define V4L2_PIX_FMT_QGRBG12 v4l2_fourcc('Q', 'G', 'R', '2')
363#define V4L2_PIX_FMT_QRGGB12 v4l2_fourcc('Q', 'R', 'G', '2')
364
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800365#define VIDIOC_MSM_VFE_REG_CFG \
366 _IOWR('V', BASE_VIDIOC_PRIVATE, struct msm_vfe_cfg_cmd2)
367
368#define VIDIOC_MSM_ISP_REQUEST_BUF \
369 _IOWR('V', BASE_VIDIOC_PRIVATE+1, struct msm_isp_buf_request)
370
371#define VIDIOC_MSM_ISP_ENQUEUE_BUF \
372 _IOWR('V', BASE_VIDIOC_PRIVATE+2, struct msm_isp_qbuf_info)
373
374#define VIDIOC_MSM_ISP_RELEASE_BUF \
375 _IOWR('V', BASE_VIDIOC_PRIVATE+3, struct msm_isp_buf_request)
376
377#define VIDIOC_MSM_ISP_REQUEST_STREAM \
378 _IOWR('V', BASE_VIDIOC_PRIVATE+4, struct msm_vfe_axi_stream_request_cmd)
379
380#define VIDIOC_MSM_ISP_CFG_STREAM \
381 _IOWR('V', BASE_VIDIOC_PRIVATE+5, struct msm_vfe_axi_stream_cfg_cmd)
382
383#define VIDIOC_MSM_ISP_RELEASE_STREAM \
384 _IOWR('V', BASE_VIDIOC_PRIVATE+6, struct msm_vfe_axi_stream_release_cmd)
385
386#define VIDIOC_MSM_ISP_INPUT_CFG \
387 _IOWR('V', BASE_VIDIOC_PRIVATE+7, struct msm_vfe_input_cfg)
388
389#define VIDIOC_MSM_ISP_SET_SRC_STATE \
390 _IOWR('V', BASE_VIDIOC_PRIVATE+8, struct msm_vfe_axi_src_state)
391
392#define VIDIOC_MSM_ISP_REQUEST_STATS_STREAM \
393 _IOWR('V', BASE_VIDIOC_PRIVATE+9, \
394 struct msm_vfe_stats_stream_request_cmd)
395
396#define VIDIOC_MSM_ISP_CFG_STATS_STREAM \
397 _IOWR('V', BASE_VIDIOC_PRIVATE+10, struct msm_vfe_stats_stream_cfg_cmd)
398
399#define VIDIOC_MSM_ISP_RELEASE_STATS_STREAM \
400 _IOWR('V', BASE_VIDIOC_PRIVATE+11, \
401 struct msm_vfe_stats_stream_release_cmd)
402
Kevin Chan5bebd2e2013-01-30 20:25:05 -0800403#define VIDIOC_MSM_ISP_UPDATE_STREAM \
404 _IOWR('V', BASE_VIDIOC_PRIVATE+13, struct msm_vfe_axi_stream_update_cmd)
405
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800406#endif /* __MSMB_ISP__ */