blob: 7b0ad148eacb45e861dc787d08733e6e86c472c4 [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 Kediya2ae1e592013-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,
155};
156
157struct msm_vfe_axi_stream_cfg_cmd {
158 uint8_t num_streams;
159 uint32_t stream_handle[MAX_NUM_STREAM];
160 enum msm_vfe_axi_stream_cmd cmd;
161};
162
Kevin Chan5bebd2e2013-01-30 20:25:05 -0800163enum msm_vfe_axi_stream_update_type {
164 ENABLE_STREAM_BUF_DIVERT,
165 DISABLE_STREAM_BUF_DIVERT,
166 UPDATE_STREAM_FRAMEDROP_PATTERN,
Kevin Chand5dfce22013-05-16 00:34:25 -0700167 UPDATE_STREAM_AXI_CONFIG,
168};
169
170struct msm_vfe_axi_stream_cfg_update_info {
171 uint32_t stream_handle;
172 uint32_t output_format;
173 enum msm_vfe_frame_skip_pattern skip_pattern;
174 struct msm_vfe_axi_plane_cfg plane_cfg[MAX_PLANES_PER_STREAM];
Kevin Chan5bebd2e2013-01-30 20:25:05 -0800175};
176
177struct msm_vfe_axi_stream_update_cmd {
Kevin Chand5dfce22013-05-16 00:34:25 -0700178 uint32_t num_streams;
Kevin Chan5bebd2e2013-01-30 20:25:05 -0800179 enum msm_vfe_axi_stream_update_type update_type;
Kevin Chand5dfce22013-05-16 00:34:25 -0700180 struct msm_vfe_axi_stream_cfg_update_info update_info[MAX_NUM_STREAM];
Kevin Chan5bebd2e2013-01-30 20:25:05 -0800181};
182
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800183enum msm_isp_stats_type {
184 MSM_ISP_STATS_AEC, /* legacy based AEC */
185 MSM_ISP_STATS_AF, /* legacy based AF */
186 MSM_ISP_STATS_AWB, /* legacy based AWB */
187 MSM_ISP_STATS_RS, /* legacy based RS */
188 MSM_ISP_STATS_CS, /* legacy based CS */
189 MSM_ISP_STATS_IHIST, /* legacy based HIST */
190 MSM_ISP_STATS_SKIN, /* legacy based SKIN */
191 MSM_ISP_STATS_BG, /* Bayer Grids */
192 MSM_ISP_STATS_BF, /* Bayer Focus */
193 MSM_ISP_STATS_BE, /* Bayer Exposure*/
194 MSM_ISP_STATS_BHIST, /* Bayer Hist */
195 MSM_ISP_STATS_MAX /* MAX */
196};
197
198struct msm_vfe_stats_stream_request_cmd {
199 uint32_t session_id;
200 uint32_t stream_id;
201 enum msm_isp_stats_type stats_type;
Kevin Chan1f152492013-03-21 23:36:48 -0700202 uint32_t composite_flag;
Mingcheng Zhu503a6f92013-01-06 13:23:24 -0800203 uint32_t framedrop_pattern;
Kevin Chan3454e2b2013-01-17 19:18:57 -0800204 uint32_t irq_subsample_pattern;
Kevin Chance198ee2013-03-14 18:47:18 -0700205 uint32_t buffer_offset;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800206 uint32_t stream_handle;
207};
Kevin Chan3454e2b2013-01-17 19:18:57 -0800208
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800209struct msm_vfe_stats_stream_release_cmd {
210 uint32_t stream_handle;
211};
212struct msm_vfe_stats_stream_cfg_cmd {
213 uint8_t num_streams;
214 uint32_t stream_handle[MSM_ISP_STATS_MAX];
215 uint8_t enable;
216};
Kevin Chan3454e2b2013-01-17 19:18:57 -0800217
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,
Slavi Dimitrov8dec27c2013-07-25 00:16:18 -0700229 GET_SOC_HW_VER,
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800230};
231
232struct msm_vfe_cfg_cmd2 {
233 uint16_t num_cfg;
234 uint16_t cmd_len;
235 void __user *cfg_data;
236 void __user *cfg_cmd;
237};
238
Kevin Chan7672ef32013-01-21 22:10:53 -0800239struct msm_vfe_reg_rw_info {
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800240 uint32_t reg_offset;
Kevin Chan7672ef32013-01-21 22:10:53 -0800241 uint32_t cmd_data_offset;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800242 uint32_t len;
Kevin Chan7672ef32013-01-21 22:10:53 -0800243};
244
245struct msm_vfe_reg_mask_info {
246 uint32_t reg_offset;
247 uint32_t mask;
248 uint32_t val;
249};
250
251struct msm_vfe_reg_dmi_info {
252 uint32_t hi_tbl_offset; /*Optional*/
253 uint32_t lo_tbl_offset; /*Required*/
254 uint32_t len;
255};
256
257struct msm_vfe_reg_cfg_cmd {
258 union {
259 struct msm_vfe_reg_rw_info rw_info;
260 struct msm_vfe_reg_mask_info mask_info;
261 struct msm_vfe_reg_dmi_info dmi_info;
262 } u;
263
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800264 enum msm_vfe_reg_cfg_type cmd_type;
265};
266
Kevin Chanbaf0a132013-03-05 20:08:23 -0800267enum msm_isp_buf_type {
268 ISP_PRIVATE_BUF,
269 ISP_SHARE_BUF,
270 MAX_ISP_BUF_TYPE,
271};
272
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800273struct msm_isp_buf_request {
274 uint32_t session_id;
275 uint32_t stream_id;
276 uint8_t num_buf;
277 uint32_t handle;
Kevin Chanbaf0a132013-03-05 20:08:23 -0800278 enum msm_isp_buf_type buf_type;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800279};
280
281struct msm_isp_qbuf_info {
282 uint32_t handle;
283 int buf_idx;
284 /*Only used for prepare buffer*/
285 struct v4l2_buffer buffer;
Kevin Chan5bebd2e2013-01-30 20:25:05 -0800286 /*Only used for diverted buffer*/
287 uint32_t dirty_buf;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800288};
289
290struct msm_vfe_axi_src_state {
291 enum msm_vfe_input_src input_src;
292 uint32_t src_active;
293};
294
295enum msm_isp_event_idx {
296 ISP_REG_UPDATE = 0,
297 ISP_START_ACK = 1,
298 ISP_STOP_ACK = 2,
299 ISP_IRQ_VIOLATION = 3,
300 ISP_WM_BUS_OVERFLOW = 4,
301 ISP_STATS_OVERFLOW = 5,
302 ISP_CAMIF_ERROR = 6,
Kevin Chan9c74c522013-02-06 22:27:47 -0800303 ISP_SOF = 7,
304 ISP_EOF = 8,
305 ISP_EVENT_MAX = 9
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800306};
307
Kevin Chan9c74c522013-02-06 22:27:47 -0800308#define ISP_EVENT_OFFSET 8
309#define ISP_EVENT_BASE (V4L2_EVENT_PRIVATE_START)
310#define ISP_BUF_EVENT_BASE (ISP_EVENT_BASE + (1 << ISP_EVENT_OFFSET))
311#define ISP_STATS_EVENT_BASE (ISP_EVENT_BASE + (2 << ISP_EVENT_OFFSET))
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800312#define ISP_EVENT_REG_UPDATE (ISP_EVENT_BASE + ISP_REG_UPDATE)
313#define ISP_EVENT_START_ACK (ISP_EVENT_BASE + ISP_START_ACK)
314#define ISP_EVENT_STOP_ACK (ISP_EVENT_BASE + ISP_STOP_ACK)
315#define ISP_EVENT_IRQ_VIOLATION (ISP_EVENT_BASE + ISP_IRQ_VIOLATION)
316#define ISP_EVENT_WM_BUS_OVERFLOW (ISP_EVENT_BASE + ISP_WM_BUS_OVERFLOW)
317#define ISP_EVENT_STATS_OVERFLOW (ISP_EVENT_BASE + ISP_STATS_OVERFLOW)
318#define ISP_EVENT_CAMIF_ERROR (ISP_EVENT_BASE + ISP_CAMIF_ERROR)
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800319#define ISP_EVENT_SOF (ISP_EVENT_BASE + ISP_SOF)
320#define ISP_EVENT_EOF (ISP_EVENT_BASE + ISP_EOF)
Kevin Chan9c74c522013-02-06 22:27:47 -0800321#define ISP_EVENT_BUF_DIVERT (ISP_BUF_EVENT_BASE)
322#define ISP_EVENT_STATS_NOTIFY (ISP_STATS_EVENT_BASE)
Kevin Chan1f152492013-03-21 23:36:48 -0700323#define ISP_EVENT_COMP_STATS_NOTIFY (ISP_EVENT_STATS_NOTIFY + MSM_ISP_STATS_MAX)
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800324/* The msm_v4l2_event_data structure should match the
325 * v4l2_event.u.data field.
326 * should not exceed 64 bytes */
327
328struct msm_isp_buf_event {
329 uint32_t session_id;
330 uint32_t stream_id;
331 uint32_t handle;
Kevin Chand5dfce22013-05-16 00:34:25 -0700332 uint32_t output_format;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800333 int8_t buf_idx;
334};
335struct msm_isp_stats_event {
336 uint32_t stats_mask; /* 4 bytes */
337 uint8_t stats_buf_idxs[MSM_ISP_STATS_MAX]; /* 11 bytes */
338};
339
340struct msm_isp_stream_ack {
341 uint32_t session_id;
342 uint32_t stream_id;
343 uint32_t handle;
344};
345
346struct msm_isp_event_data {
Kevin Chan9f7785c2013-02-22 22:09:57 -0800347 /*Wall clock except for buffer divert events
348 *which use monotonic clock
349 */
350 struct timeval timestamp;
Shuzhen Wang13844752013-05-20 15:13:45 -0700351 /* Monotonic timestamp since bootup */
352 struct timeval mono_timestamp;
Kevin Chan195687f2013-06-25 19:01:17 -0700353 enum msm_vfe_input_src input_intf;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800354 uint32_t frame_id;
355 union {
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800356 struct msm_isp_stats_event stats;
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800357 struct msm_isp_buf_event buf_done;
358 } u; /* union can have max 52 bytes */
359};
360
Kevin Chan80b7b6d2013-01-31 16:08:35 -0800361#define V4L2_PIX_FMT_QBGGR8 v4l2_fourcc('Q', 'B', 'G', '8')
362#define V4L2_PIX_FMT_QGBRG8 v4l2_fourcc('Q', 'G', 'B', '8')
363#define V4L2_PIX_FMT_QGRBG8 v4l2_fourcc('Q', 'G', 'R', '8')
364#define V4L2_PIX_FMT_QRGGB8 v4l2_fourcc('Q', 'R', 'G', '8')
365#define V4L2_PIX_FMT_QBGGR10 v4l2_fourcc('Q', 'B', 'G', '0')
366#define V4L2_PIX_FMT_QGBRG10 v4l2_fourcc('Q', 'G', 'B', '0')
367#define V4L2_PIX_FMT_QGRBG10 v4l2_fourcc('Q', 'G', 'R', '0')
368#define V4L2_PIX_FMT_QRGGB10 v4l2_fourcc('Q', 'R', 'G', '0')
369#define V4L2_PIX_FMT_QBGGR12 v4l2_fourcc('Q', 'B', 'G', '2')
370#define V4L2_PIX_FMT_QGBRG12 v4l2_fourcc('Q', 'G', 'B', '2')
371#define V4L2_PIX_FMT_QGRBG12 v4l2_fourcc('Q', 'G', 'R', '2')
372#define V4L2_PIX_FMT_QRGGB12 v4l2_fourcc('Q', 'R', 'G', '2')
Kevin Chand5dfce22013-05-16 00:34:25 -0700373#define V4L2_PIX_FMT_NV14 v4l2_fourcc('N', 'V', '1', '4')
374#define V4L2_PIX_FMT_NV41 v4l2_fourcc('N', 'V', '4', '1')
Harsh Shah18524932013-03-29 17:20:40 -0700375#define V4L2_PIX_FMT_META v4l2_fourcc('Q', 'M', 'E', 'T')
Kevin Chan80b7b6d2013-01-31 16:08:35 -0800376
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 Chan5bebd2e2013-01-30 20:25:05 -0800415#define VIDIOC_MSM_ISP_UPDATE_STREAM \
416 _IOWR('V', BASE_VIDIOC_PRIVATE+13, struct msm_vfe_axi_stream_update_cmd)
417
Kevin Chan1d5fd4a2013-01-11 14:08:14 -0800418#endif /* __MSMB_ISP__ */