blob: 3ba0abed971e377937c57d3dab07e0710ba9fa98 [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 Zhu1e6b5e32013-06-23 17:11:41 -070014#define ISP_META_CHANNEL_BIT 0x80000
Mingcheng Zhu503a6f92013-01-06 13:23:24 -080015#define ISP_STATS_STREAM_BIT 0x80000000
Kevin Chan1d5fd4a2013-01-11 14:08:14 -080016
17enum ISP_START_PIXEL_PATTERN {
18 ISP_BAYER_RGRGRG,
19 ISP_BAYER_GRGRGR,
20 ISP_BAYER_BGBGBG,
21 ISP_BAYER_GBGBGB,
22 ISP_YUV_YCbYCr,
23 ISP_YUV_YCrYCb,
24 ISP_YUV_CbYCrY,
25 ISP_YUV_CrYCbY,
26 ISP_PIX_PATTERN_MAX
27};
28
29enum msm_vfe_plane_fmt {
30 Y_PLANE,
31 CB_PLANE,
32 CR_PLANE,
33 CRCB_PLANE,
34 CBCR_PLANE,
35 VFE_PLANE_FMT_MAX
36};
37
38enum msm_vfe_input_src {
39 VFE_PIX_0,
40 VFE_RAW_0,
41 VFE_RAW_1,
42 VFE_RAW_2,
43 VFE_SRC_MAX,
44};
45
46enum msm_vfe_axi_stream_src {
47 PIX_ENCODER,
48 PIX_VIEWFINDER,
49 CAMIF_RAW,
50 IDEAL_RAW,
Kevin Chan80b7b6d2013-01-31 16:08:35 -080051 RDI_INTF_0,
52 RDI_INTF_1,
53 RDI_INTF_2,
Kevin Chan1d5fd4a2013-01-11 14:08:14 -080054 VFE_AXI_SRC_MAX
55};
56
57enum msm_vfe_frame_skip_pattern {
58 NO_SKIP,
59 EVERY_2FRAME,
Kevin Chan1fe7fb72013-02-12 19:33:38 -080060 EVERY_3FRAME,
Kevin Chan1d5fd4a2013-01-11 14:08:14 -080061 EVERY_4FRAME,
Kevin Chan1fe7fb72013-02-12 19:33:38 -080062 EVERY_5FRAME,
63 EVERY_6FRAME,
64 EVERY_7FRAME,
Kevin Chan1d5fd4a2013-01-11 14:08:14 -080065 EVERY_8FRAME,
66 EVERY_16FRAME,
67 EVERY_32FRAME,
Kevin Chan87cedbd2013-04-27 03:14:35 -070068 SKIP_ALL,
Kevin Chan1d5fd4a2013-01-11 14:08:14 -080069 MAX_SKIP,
70};
71
72enum msm_vfe_camif_input {
73 CAMIF_DISABLED,
74 CAMIF_PAD_REG_INPUT,
75 CAMIF_MIDDI_INPUT,
76 CAMIF_MIPI_INPUT,
77};
78
79struct msm_vfe_camif_cfg {
80 uint32_t lines_per_frame;
81 uint32_t pixels_per_line;
82 uint32_t first_pixel;
83 uint32_t last_pixel;
84 uint32_t first_line;
85 uint32_t last_line;
86 uint32_t epoch_line0;
87 uint32_t epoch_line1;
88 enum msm_vfe_camif_input camif_input;
89};
90
91enum msm_vfe_inputmux {
92 CAMIF,
93 TESTGEN,
94 EXTERNAL_READ,
95};
96
97struct msm_vfe_pix_cfg {
98 struct msm_vfe_camif_cfg camif_cfg;
99 enum msm_vfe_inputmux input_mux;
100 enum ISP_START_PIXEL_PATTERN pixel_pattern;
Kevin Chan9fd18a22013-06-24 16:21:02 -0700101 uint32_t input_format;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800102};
103
Kevin Chan80b7b6d2013-01-31 16:08:35 -0800104struct msm_vfe_rdi_cfg {
105 uint8_t cid;
106 uint8_t frame_based;
107};
108
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800109struct msm_vfe_input_cfg {
110 union {
111 struct msm_vfe_pix_cfg pix_cfg;
Kevin Chan80b7b6d2013-01-31 16:08:35 -0800112 struct msm_vfe_rdi_cfg rdi_cfg;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800113 } d;
114 enum msm_vfe_input_src input_src;
Kevin Chan9a8301b12013-03-18 15:39:37 -0700115 uint32_t input_pix_clk;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800116};
117
118struct msm_vfe_axi_plane_cfg {
119 uint32_t output_width; /*Include padding*/
120 uint32_t output_height;
121 uint32_t output_stride;
122 uint32_t output_scan_lines;
123 uint32_t output_plane_format; /*Y/Cb/Cr/CbCr*/
Kevin Chanbaf0a132013-03-05 20:08:23 -0800124 uint32_t plane_addr_offset;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800125 uint8_t csid_src; /*RDI 0-2*/
126 uint8_t rdi_cid;/*CID 1-16*/
127};
128
129struct msm_vfe_axi_stream_request_cmd {
130 uint32_t session_id;
131 uint32_t stream_id;
Alok Kediya6b1f21f2013-10-04 18:13:32 +0530132 uint32_t vt_enable;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800133 uint32_t output_format;/*Planar/RAW/Misc*/
134 enum msm_vfe_axi_stream_src stream_src; /*CAMIF/IDEAL/RDIs*/
135 struct msm_vfe_axi_plane_cfg plane_cfg[MAX_PLANES_PER_STREAM];
136
137 uint32_t burst_count;
138 uint32_t hfr_mode;
139 uint8_t frame_base;
140
141 uint32_t init_frame_drop; /*MAX 31 Frames*/
142 enum msm_vfe_frame_skip_pattern frame_skip_pattern;
143 uint8_t buf_divert; /* if TRUE no vb2 buf done. */
144 /*Return values*/
145 uint32_t axi_stream_handle;
146};
147
148struct msm_vfe_axi_stream_release_cmd {
149 uint32_t stream_handle;
150};
151
152enum msm_vfe_axi_stream_cmd {
153 STOP_STREAM,
154 START_STREAM,
Abhishek Kondaveeti74c1b272013-11-12 17:13:45 +0530155 STOP_IMMEDIATELY,
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800156};
157
158struct msm_vfe_axi_stream_cfg_cmd {
159 uint8_t num_streams;
160 uint32_t stream_handle[MAX_NUM_STREAM];
161 enum msm_vfe_axi_stream_cmd cmd;
162};
163
Kevin Chan5bebd2e2013-01-30 20:25:05 -0800164enum msm_vfe_axi_stream_update_type {
165 ENABLE_STREAM_BUF_DIVERT,
166 DISABLE_STREAM_BUF_DIVERT,
167 UPDATE_STREAM_FRAMEDROP_PATTERN,
Kevin Chand5dfce22013-05-16 00:34:25 -0700168 UPDATE_STREAM_AXI_CONFIG,
169};
170
171struct msm_vfe_axi_stream_cfg_update_info {
172 uint32_t stream_handle;
173 uint32_t output_format;
174 enum msm_vfe_frame_skip_pattern skip_pattern;
175 struct msm_vfe_axi_plane_cfg plane_cfg[MAX_PLANES_PER_STREAM];
Kevin Chan5bebd2e2013-01-30 20:25:05 -0800176};
177
178struct msm_vfe_axi_stream_update_cmd {
Kevin Chand5dfce22013-05-16 00:34:25 -0700179 uint32_t num_streams;
Kevin Chan5bebd2e2013-01-30 20:25:05 -0800180 enum msm_vfe_axi_stream_update_type update_type;
Kevin Chand5dfce22013-05-16 00:34:25 -0700181 struct msm_vfe_axi_stream_cfg_update_info update_info[MAX_NUM_STREAM];
Kevin Chan5bebd2e2013-01-30 20:25:05 -0800182};
183
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800184enum msm_isp_stats_type {
185 MSM_ISP_STATS_AEC, /* legacy based AEC */
186 MSM_ISP_STATS_AF, /* legacy based AF */
187 MSM_ISP_STATS_AWB, /* legacy based AWB */
188 MSM_ISP_STATS_RS, /* legacy based RS */
189 MSM_ISP_STATS_CS, /* legacy based CS */
190 MSM_ISP_STATS_IHIST, /* legacy based HIST */
191 MSM_ISP_STATS_SKIN, /* legacy based SKIN */
192 MSM_ISP_STATS_BG, /* Bayer Grids */
193 MSM_ISP_STATS_BF, /* Bayer Focus */
194 MSM_ISP_STATS_BE, /* Bayer Exposure*/
195 MSM_ISP_STATS_BHIST, /* Bayer Hist */
196 MSM_ISP_STATS_MAX /* MAX */
197};
198
199struct msm_vfe_stats_stream_request_cmd {
200 uint32_t session_id;
201 uint32_t stream_id;
202 enum msm_isp_stats_type stats_type;
Kevin Chan1f152492013-03-21 23:36:48 -0700203 uint32_t composite_flag;
Mingcheng Zhu503a6f92013-01-06 13:23:24 -0800204 uint32_t framedrop_pattern;
Kevin Chan3454e2b2013-01-17 19:18:57 -0800205 uint32_t irq_subsample_pattern;
Kevin Chance198ee2013-03-14 18:47:18 -0700206 uint32_t buffer_offset;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800207 uint32_t stream_handle;
208};
Kevin Chan3454e2b2013-01-17 19:18:57 -0800209
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800210struct msm_vfe_stats_stream_release_cmd {
211 uint32_t stream_handle;
212};
213struct msm_vfe_stats_stream_cfg_cmd {
214 uint8_t num_streams;
215 uint32_t stream_handle[MSM_ISP_STATS_MAX];
216 uint8_t enable;
217};
Kevin Chan3454e2b2013-01-17 19:18:57 -0800218
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800219enum msm_vfe_reg_cfg_type {
220 VFE_WRITE,
221 VFE_WRITE_MB,
222 VFE_READ,
Kevin Chan7672ef32013-01-21 22:10:53 -0800223 VFE_CFG_MASK,
224 VFE_WRITE_DMI_16BIT,
225 VFE_WRITE_DMI_32BIT,
226 VFE_WRITE_DMI_64BIT,
227 VFE_READ_DMI_16BIT,
228 VFE_READ_DMI_32BIT,
229 VFE_READ_DMI_64BIT,
Slavi Dimitrov8dec27c2013-07-25 00:16:18 -0700230 GET_SOC_HW_VER,
Sreesudhan Ramakrish Ramkumarbebd6dc2013-11-21 10:54:53 -0800231 GET_MAX_CLK_RATE,
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800232};
233
234struct msm_vfe_cfg_cmd2 {
235 uint16_t num_cfg;
236 uint16_t cmd_len;
237 void __user *cfg_data;
238 void __user *cfg_cmd;
239};
240
Kevin Chan7672ef32013-01-21 22:10:53 -0800241struct msm_vfe_reg_rw_info {
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800242 uint32_t reg_offset;
Kevin Chan7672ef32013-01-21 22:10:53 -0800243 uint32_t cmd_data_offset;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800244 uint32_t len;
Kevin Chan7672ef32013-01-21 22:10:53 -0800245};
246
247struct msm_vfe_reg_mask_info {
248 uint32_t reg_offset;
249 uint32_t mask;
250 uint32_t val;
251};
252
253struct msm_vfe_reg_dmi_info {
254 uint32_t hi_tbl_offset; /*Optional*/
255 uint32_t lo_tbl_offset; /*Required*/
256 uint32_t len;
257};
258
259struct msm_vfe_reg_cfg_cmd {
260 union {
261 struct msm_vfe_reg_rw_info rw_info;
262 struct msm_vfe_reg_mask_info mask_info;
263 struct msm_vfe_reg_dmi_info dmi_info;
264 } u;
265
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800266 enum msm_vfe_reg_cfg_type cmd_type;
267};
268
Kevin Chanbaf0a132013-03-05 20:08:23 -0800269enum msm_isp_buf_type {
270 ISP_PRIVATE_BUF,
271 ISP_SHARE_BUF,
272 MAX_ISP_BUF_TYPE,
273};
274
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800275struct msm_isp_buf_request {
276 uint32_t session_id;
277 uint32_t stream_id;
278 uint8_t num_buf;
279 uint32_t handle;
Kevin Chanbaf0a132013-03-05 20:08:23 -0800280 enum msm_isp_buf_type buf_type;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800281};
282
283struct msm_isp_qbuf_info {
284 uint32_t handle;
285 int buf_idx;
286 /*Only used for prepare buffer*/
287 struct v4l2_buffer buffer;
Kevin Chan5bebd2e2013-01-30 20:25:05 -0800288 /*Only used for diverted buffer*/
289 uint32_t dirty_buf;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800290};
291
292struct msm_vfe_axi_src_state {
293 enum msm_vfe_input_src input_src;
294 uint32_t src_active;
295};
296
297enum msm_isp_event_idx {
298 ISP_REG_UPDATE = 0,
299 ISP_START_ACK = 1,
300 ISP_STOP_ACK = 2,
301 ISP_IRQ_VIOLATION = 3,
302 ISP_WM_BUS_OVERFLOW = 4,
303 ISP_STATS_OVERFLOW = 5,
304 ISP_CAMIF_ERROR = 6,
Kevin Chan9c74c522013-02-06 22:27:47 -0800305 ISP_SOF = 7,
306 ISP_EOF = 8,
307 ISP_EVENT_MAX = 9
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800308};
309
Kevin Chan9c74c522013-02-06 22:27:47 -0800310#define ISP_EVENT_OFFSET 8
311#define ISP_EVENT_BASE (V4L2_EVENT_PRIVATE_START)
312#define ISP_BUF_EVENT_BASE (ISP_EVENT_BASE + (1 << ISP_EVENT_OFFSET))
313#define ISP_STATS_EVENT_BASE (ISP_EVENT_BASE + (2 << ISP_EVENT_OFFSET))
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800314#define ISP_EVENT_REG_UPDATE (ISP_EVENT_BASE + ISP_REG_UPDATE)
315#define ISP_EVENT_START_ACK (ISP_EVENT_BASE + ISP_START_ACK)
316#define ISP_EVENT_STOP_ACK (ISP_EVENT_BASE + ISP_STOP_ACK)
317#define ISP_EVENT_IRQ_VIOLATION (ISP_EVENT_BASE + ISP_IRQ_VIOLATION)
318#define ISP_EVENT_WM_BUS_OVERFLOW (ISP_EVENT_BASE + ISP_WM_BUS_OVERFLOW)
319#define ISP_EVENT_STATS_OVERFLOW (ISP_EVENT_BASE + ISP_STATS_OVERFLOW)
320#define ISP_EVENT_CAMIF_ERROR (ISP_EVENT_BASE + ISP_CAMIF_ERROR)
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800321#define ISP_EVENT_SOF (ISP_EVENT_BASE + ISP_SOF)
322#define ISP_EVENT_EOF (ISP_EVENT_BASE + ISP_EOF)
Kevin Chan9c74c522013-02-06 22:27:47 -0800323#define ISP_EVENT_BUF_DIVERT (ISP_BUF_EVENT_BASE)
324#define ISP_EVENT_STATS_NOTIFY (ISP_STATS_EVENT_BASE)
Kevin Chan1f152492013-03-21 23:36:48 -0700325#define ISP_EVENT_COMP_STATS_NOTIFY (ISP_EVENT_STATS_NOTIFY + MSM_ISP_STATS_MAX)
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800326/* The msm_v4l2_event_data structure should match the
327 * v4l2_event.u.data field.
328 * should not exceed 64 bytes */
329
330struct msm_isp_buf_event {
331 uint32_t session_id;
332 uint32_t stream_id;
333 uint32_t handle;
Kevin Chand5dfce22013-05-16 00:34:25 -0700334 uint32_t output_format;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800335 int8_t buf_idx;
336};
337struct msm_isp_stats_event {
338 uint32_t stats_mask; /* 4 bytes */
339 uint8_t stats_buf_idxs[MSM_ISP_STATS_MAX]; /* 11 bytes */
340};
341
342struct msm_isp_stream_ack {
343 uint32_t session_id;
344 uint32_t stream_id;
345 uint32_t handle;
346};
347
348struct msm_isp_event_data {
Kevin Chan9f7785c2013-02-22 22:09:57 -0800349 /*Wall clock except for buffer divert events
350 *which use monotonic clock
351 */
352 struct timeval timestamp;
Shuzhen Wang13844752013-05-20 15:13:45 -0700353 /* Monotonic timestamp since bootup */
354 struct timeval mono_timestamp;
Kevin Chan195687f2013-06-25 19:01:17 -0700355 enum msm_vfe_input_src input_intf;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800356 uint32_t frame_id;
357 union {
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800358 struct msm_isp_stats_event stats;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800359 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')
Kevin Chand5dfce22013-05-16 00:34:25 -0700375#define V4L2_PIX_FMT_NV14 v4l2_fourcc('N', 'V', '1', '4')
376#define V4L2_PIX_FMT_NV41 v4l2_fourcc('N', 'V', '4', '1')
Harsh Shah18524932013-03-29 17:20:40 -0700377#define V4L2_PIX_FMT_META v4l2_fourcc('Q', 'M', 'E', 'T')
Kevin Chan80b7b6d2013-01-31 16:08:35 -0800378
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800379#define VIDIOC_MSM_VFE_REG_CFG \
380 _IOWR('V', BASE_VIDIOC_PRIVATE, struct msm_vfe_cfg_cmd2)
381
382#define VIDIOC_MSM_ISP_REQUEST_BUF \
383 _IOWR('V', BASE_VIDIOC_PRIVATE+1, struct msm_isp_buf_request)
384
385#define VIDIOC_MSM_ISP_ENQUEUE_BUF \
386 _IOWR('V', BASE_VIDIOC_PRIVATE+2, struct msm_isp_qbuf_info)
387
388#define VIDIOC_MSM_ISP_RELEASE_BUF \
389 _IOWR('V', BASE_VIDIOC_PRIVATE+3, struct msm_isp_buf_request)
390
391#define VIDIOC_MSM_ISP_REQUEST_STREAM \
392 _IOWR('V', BASE_VIDIOC_PRIVATE+4, struct msm_vfe_axi_stream_request_cmd)
393
394#define VIDIOC_MSM_ISP_CFG_STREAM \
395 _IOWR('V', BASE_VIDIOC_PRIVATE+5, struct msm_vfe_axi_stream_cfg_cmd)
396
397#define VIDIOC_MSM_ISP_RELEASE_STREAM \
398 _IOWR('V', BASE_VIDIOC_PRIVATE+6, struct msm_vfe_axi_stream_release_cmd)
399
400#define VIDIOC_MSM_ISP_INPUT_CFG \
401 _IOWR('V', BASE_VIDIOC_PRIVATE+7, struct msm_vfe_input_cfg)
402
403#define VIDIOC_MSM_ISP_SET_SRC_STATE \
404 _IOWR('V', BASE_VIDIOC_PRIVATE+8, struct msm_vfe_axi_src_state)
405
406#define VIDIOC_MSM_ISP_REQUEST_STATS_STREAM \
407 _IOWR('V', BASE_VIDIOC_PRIVATE+9, \
408 struct msm_vfe_stats_stream_request_cmd)
409
410#define VIDIOC_MSM_ISP_CFG_STATS_STREAM \
411 _IOWR('V', BASE_VIDIOC_PRIVATE+10, struct msm_vfe_stats_stream_cfg_cmd)
412
413#define VIDIOC_MSM_ISP_RELEASE_STATS_STREAM \
414 _IOWR('V', BASE_VIDIOC_PRIVATE+11, \
415 struct msm_vfe_stats_stream_release_cmd)
416
Kevin Chan5bebd2e2013-01-30 20:25:05 -0800417#define VIDIOC_MSM_ISP_UPDATE_STREAM \
418 _IOWR('V', BASE_VIDIOC_PRIVATE+13, struct msm_vfe_axi_stream_update_cmd)
419
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800420#endif /* __MSMB_ISP__ */