blob: 23b19b57d14d19ac25993e14e4deb7ef01220fc2 [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;
132 uint32_t output_format;/*Planar/RAW/Misc*/
133 enum msm_vfe_axi_stream_src stream_src; /*CAMIF/IDEAL/RDIs*/
134 struct msm_vfe_axi_plane_cfg plane_cfg[MAX_PLANES_PER_STREAM];
135
136 uint32_t burst_count;
137 uint32_t hfr_mode;
138 uint8_t frame_base;
139
140 uint32_t init_frame_drop; /*MAX 31 Frames*/
141 enum msm_vfe_frame_skip_pattern frame_skip_pattern;
142 uint8_t buf_divert; /* if TRUE no vb2 buf done. */
143 /*Return values*/
144 uint32_t axi_stream_handle;
145};
146
147struct msm_vfe_axi_stream_release_cmd {
148 uint32_t stream_handle;
149};
150
151enum msm_vfe_axi_stream_cmd {
152 STOP_STREAM,
153 START_STREAM,
154};
155
156struct msm_vfe_axi_stream_cfg_cmd {
157 uint8_t num_streams;
158 uint32_t stream_handle[MAX_NUM_STREAM];
159 enum msm_vfe_axi_stream_cmd cmd;
160};
161
Kevin Chan5bebd2e2013-01-30 20:25:05 -0800162enum msm_vfe_axi_stream_update_type {
163 ENABLE_STREAM_BUF_DIVERT,
164 DISABLE_STREAM_BUF_DIVERT,
165 UPDATE_STREAM_FRAMEDROP_PATTERN,
Kevin Chand5dfce22013-05-16 00:34:25 -0700166 UPDATE_STREAM_AXI_CONFIG,
167};
168
169struct msm_vfe_axi_stream_cfg_update_info {
170 uint32_t stream_handle;
171 uint32_t output_format;
172 enum msm_vfe_frame_skip_pattern skip_pattern;
173 struct msm_vfe_axi_plane_cfg plane_cfg[MAX_PLANES_PER_STREAM];
Kevin Chan5bebd2e2013-01-30 20:25:05 -0800174};
175
176struct msm_vfe_axi_stream_update_cmd {
Kevin Chand5dfce22013-05-16 00:34:25 -0700177 uint32_t num_streams;
Kevin Chan5bebd2e2013-01-30 20:25:05 -0800178 enum msm_vfe_axi_stream_update_type update_type;
Kevin Chand5dfce22013-05-16 00:34:25 -0700179 struct msm_vfe_axi_stream_cfg_update_info update_info[MAX_NUM_STREAM];
Kevin Chan5bebd2e2013-01-30 20:25:05 -0800180};
181
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800182enum msm_isp_stats_type {
183 MSM_ISP_STATS_AEC, /* legacy based AEC */
184 MSM_ISP_STATS_AF, /* legacy based AF */
185 MSM_ISP_STATS_AWB, /* legacy based AWB */
186 MSM_ISP_STATS_RS, /* legacy based RS */
187 MSM_ISP_STATS_CS, /* legacy based CS */
188 MSM_ISP_STATS_IHIST, /* legacy based HIST */
189 MSM_ISP_STATS_SKIN, /* legacy based SKIN */
190 MSM_ISP_STATS_BG, /* Bayer Grids */
191 MSM_ISP_STATS_BF, /* Bayer Focus */
192 MSM_ISP_STATS_BE, /* Bayer Exposure*/
193 MSM_ISP_STATS_BHIST, /* Bayer Hist */
194 MSM_ISP_STATS_MAX /* MAX */
195};
196
197struct msm_vfe_stats_stream_request_cmd {
198 uint32_t session_id;
199 uint32_t stream_id;
200 enum msm_isp_stats_type stats_type;
Kevin Chan1f152492013-03-21 23:36:48 -0700201 uint32_t composite_flag;
Mingcheng Zhu503a6f92013-01-06 13:23:24 -0800202 uint32_t framedrop_pattern;
Kevin Chan3454e2b2013-01-17 19:18:57 -0800203 uint32_t irq_subsample_pattern;
Kevin Chance198ee2013-03-14 18:47:18 -0700204 uint32_t buffer_offset;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800205 uint32_t stream_handle;
206};
Kevin Chan3454e2b2013-01-17 19:18:57 -0800207
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800208struct msm_vfe_stats_stream_release_cmd {
209 uint32_t stream_handle;
210};
211struct msm_vfe_stats_stream_cfg_cmd {
212 uint8_t num_streams;
213 uint32_t stream_handle[MSM_ISP_STATS_MAX];
214 uint8_t enable;
215};
Kevin Chan3454e2b2013-01-17 19:18:57 -0800216
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,
Slavi Dimitrov8dec27c2013-07-25 00:16:18 -0700228 GET_SOC_HW_VER,
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 Chan1f152492013-03-21 23:36:48 -0700322#define ISP_EVENT_COMP_STATS_NOTIFY (ISP_EVENT_STATS_NOTIFY + MSM_ISP_STATS_MAX)
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800323/* 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;
Kevin Chand5dfce22013-05-16 00:34:25 -0700331 uint32_t output_format;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800332 int8_t buf_idx;
333};
334struct msm_isp_stats_event {
335 uint32_t stats_mask; /* 4 bytes */
336 uint8_t stats_buf_idxs[MSM_ISP_STATS_MAX]; /* 11 bytes */
337};
338
339struct msm_isp_stream_ack {
340 uint32_t session_id;
341 uint32_t stream_id;
342 uint32_t handle;
343};
344
345struct msm_isp_event_data {
Kevin Chan9f7785c2013-02-22 22:09:57 -0800346 /*Wall clock except for buffer divert events
347 *which use monotonic clock
348 */
349 struct timeval timestamp;
Shuzhen Wang13844752013-05-20 15:13:45 -0700350 /* Monotonic timestamp since bootup */
351 struct timeval mono_timestamp;
Kevin Chan195687f2013-06-25 19:01:17 -0700352 enum msm_vfe_input_src input_intf;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800353 uint32_t frame_id;
354 union {
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800355 struct msm_isp_stats_event stats;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800356 struct msm_isp_buf_event buf_done;
357 } u; /* union can have max 52 bytes */
358};
359
Kevin Chan80b7b6d2013-01-31 16:08:35 -0800360#define V4L2_PIX_FMT_QBGGR8 v4l2_fourcc('Q', 'B', 'G', '8')
361#define V4L2_PIX_FMT_QGBRG8 v4l2_fourcc('Q', 'G', 'B', '8')
362#define V4L2_PIX_FMT_QGRBG8 v4l2_fourcc('Q', 'G', 'R', '8')
363#define V4L2_PIX_FMT_QRGGB8 v4l2_fourcc('Q', 'R', 'G', '8')
364#define V4L2_PIX_FMT_QBGGR10 v4l2_fourcc('Q', 'B', 'G', '0')
365#define V4L2_PIX_FMT_QGBRG10 v4l2_fourcc('Q', 'G', 'B', '0')
366#define V4L2_PIX_FMT_QGRBG10 v4l2_fourcc('Q', 'G', 'R', '0')
367#define V4L2_PIX_FMT_QRGGB10 v4l2_fourcc('Q', 'R', 'G', '0')
368#define V4L2_PIX_FMT_QBGGR12 v4l2_fourcc('Q', 'B', 'G', '2')
369#define V4L2_PIX_FMT_QGBRG12 v4l2_fourcc('Q', 'G', 'B', '2')
370#define V4L2_PIX_FMT_QGRBG12 v4l2_fourcc('Q', 'G', 'R', '2')
371#define V4L2_PIX_FMT_QRGGB12 v4l2_fourcc('Q', 'R', 'G', '2')
Kevin Chand5dfce22013-05-16 00:34:25 -0700372#define V4L2_PIX_FMT_NV14 v4l2_fourcc('N', 'V', '1', '4')
373#define V4L2_PIX_FMT_NV41 v4l2_fourcc('N', 'V', '4', '1')
Harsh Shah18524932013-03-29 17:20:40 -0700374#define V4L2_PIX_FMT_META v4l2_fourcc('Q', 'M', 'E', 'T')
Kevin Chan80b7b6d2013-01-31 16:08:35 -0800375
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 Chan5bebd2e2013-01-30 20:25:05 -0800414#define VIDIOC_MSM_ISP_UPDATE_STREAM \
415 _IOWR('V', BASE_VIDIOC_PRIVATE+13, struct msm_vfe_axi_stream_update_cmd)
416
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800417#endif /* __MSMB_ISP__ */