Kevin Chan | 1d5fd4a | 2013-01-11 14:08:14 -0800 | [diff] [blame] | 1 | #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 Zhu | 503a6f9 | 2013-01-06 13:23:24 -0800 | [diff] [blame] | 11 | #define ISP_NATIVE_BUF_BIT 0x10000 |
| 12 | #define ISP_STATS_STREAM_BIT 0x80000000 |
Kevin Chan | 1d5fd4a | 2013-01-11 14:08:14 -0800 | [diff] [blame] | 13 | |
| 14 | enum ISP_START_PIXEL_PATTERN { |
| 15 | ISP_BAYER_RGRGRG, |
| 16 | ISP_BAYER_GRGRGR, |
| 17 | ISP_BAYER_BGBGBG, |
| 18 | ISP_BAYER_GBGBGB, |
| 19 | ISP_YUV_YCbYCr, |
| 20 | ISP_YUV_YCrYCb, |
| 21 | ISP_YUV_CbYCrY, |
| 22 | ISP_YUV_CrYCbY, |
| 23 | ISP_PIX_PATTERN_MAX |
| 24 | }; |
| 25 | |
| 26 | enum msm_vfe_plane_fmt { |
| 27 | Y_PLANE, |
| 28 | CB_PLANE, |
| 29 | CR_PLANE, |
| 30 | CRCB_PLANE, |
| 31 | CBCR_PLANE, |
| 32 | VFE_PLANE_FMT_MAX |
| 33 | }; |
| 34 | |
| 35 | enum msm_vfe_input_src { |
| 36 | VFE_PIX_0, |
| 37 | VFE_RAW_0, |
| 38 | VFE_RAW_1, |
| 39 | VFE_RAW_2, |
| 40 | VFE_SRC_MAX, |
| 41 | }; |
| 42 | |
| 43 | enum msm_vfe_axi_stream_src { |
| 44 | PIX_ENCODER, |
| 45 | PIX_VIEWFINDER, |
| 46 | CAMIF_RAW, |
| 47 | IDEAL_RAW, |
| 48 | RDI, |
| 49 | VFE_AXI_SRC_MAX |
| 50 | }; |
| 51 | |
| 52 | enum msm_vfe_frame_skip_pattern { |
| 53 | NO_SKIP, |
| 54 | EVERY_2FRAME, |
Kevin Chan | 1fe7fb7 | 2013-02-12 19:33:38 -0800 | [diff] [blame] | 55 | EVERY_3FRAME, |
Kevin Chan | 1d5fd4a | 2013-01-11 14:08:14 -0800 | [diff] [blame] | 56 | EVERY_4FRAME, |
Kevin Chan | 1fe7fb7 | 2013-02-12 19:33:38 -0800 | [diff] [blame] | 57 | EVERY_5FRAME, |
| 58 | EVERY_6FRAME, |
| 59 | EVERY_7FRAME, |
Kevin Chan | 1d5fd4a | 2013-01-11 14:08:14 -0800 | [diff] [blame] | 60 | EVERY_8FRAME, |
| 61 | EVERY_16FRAME, |
| 62 | EVERY_32FRAME, |
| 63 | MAX_SKIP, |
| 64 | }; |
| 65 | |
| 66 | enum msm_vfe_camif_input { |
| 67 | CAMIF_DISABLED, |
| 68 | CAMIF_PAD_REG_INPUT, |
| 69 | CAMIF_MIDDI_INPUT, |
| 70 | CAMIF_MIPI_INPUT, |
| 71 | }; |
| 72 | |
| 73 | struct msm_vfe_camif_cfg { |
| 74 | uint32_t lines_per_frame; |
| 75 | uint32_t pixels_per_line; |
| 76 | uint32_t first_pixel; |
| 77 | uint32_t last_pixel; |
| 78 | uint32_t first_line; |
| 79 | uint32_t last_line; |
| 80 | uint32_t epoch_line0; |
| 81 | uint32_t epoch_line1; |
| 82 | enum msm_vfe_camif_input camif_input; |
| 83 | }; |
| 84 | |
| 85 | enum msm_vfe_inputmux { |
| 86 | CAMIF, |
| 87 | TESTGEN, |
| 88 | EXTERNAL_READ, |
| 89 | }; |
| 90 | |
| 91 | struct msm_vfe_pix_cfg { |
| 92 | struct msm_vfe_camif_cfg camif_cfg; |
| 93 | enum msm_vfe_inputmux input_mux; |
| 94 | enum ISP_START_PIXEL_PATTERN pixel_pattern; |
| 95 | }; |
| 96 | |
| 97 | struct msm_vfe_input_cfg { |
| 98 | union { |
| 99 | struct msm_vfe_pix_cfg pix_cfg; |
| 100 | } d; |
| 101 | enum msm_vfe_input_src input_src; |
| 102 | |
| 103 | }; |
| 104 | |
| 105 | struct msm_vfe_axi_plane_cfg { |
| 106 | uint32_t output_width; /*Include padding*/ |
| 107 | uint32_t output_height; |
| 108 | uint32_t output_stride; |
| 109 | uint32_t output_scan_lines; |
| 110 | uint32_t output_plane_format; /*Y/Cb/Cr/CbCr*/ |
| 111 | |
| 112 | uint8_t csid_src; /*RDI 0-2*/ |
| 113 | uint8_t rdi_cid;/*CID 1-16*/ |
| 114 | }; |
| 115 | |
| 116 | struct msm_vfe_axi_stream_request_cmd { |
| 117 | uint32_t session_id; |
| 118 | uint32_t stream_id; |
| 119 | uint32_t output_format;/*Planar/RAW/Misc*/ |
| 120 | enum msm_vfe_axi_stream_src stream_src; /*CAMIF/IDEAL/RDIs*/ |
| 121 | struct msm_vfe_axi_plane_cfg plane_cfg[MAX_PLANES_PER_STREAM]; |
| 122 | |
| 123 | uint32_t burst_count; |
| 124 | uint32_t hfr_mode; |
| 125 | uint8_t frame_base; |
| 126 | |
| 127 | uint32_t init_frame_drop; /*MAX 31 Frames*/ |
| 128 | enum msm_vfe_frame_skip_pattern frame_skip_pattern; |
| 129 | uint8_t buf_divert; /* if TRUE no vb2 buf done. */ |
| 130 | /*Return values*/ |
| 131 | uint32_t axi_stream_handle; |
| 132 | }; |
| 133 | |
| 134 | struct msm_vfe_axi_stream_release_cmd { |
| 135 | uint32_t stream_handle; |
| 136 | }; |
| 137 | |
| 138 | enum msm_vfe_axi_stream_cmd { |
| 139 | STOP_STREAM, |
| 140 | START_STREAM, |
| 141 | }; |
| 142 | |
| 143 | struct msm_vfe_axi_stream_cfg_cmd { |
| 144 | uint8_t num_streams; |
| 145 | uint32_t stream_handle[MAX_NUM_STREAM]; |
| 146 | enum msm_vfe_axi_stream_cmd cmd; |
| 147 | }; |
| 148 | |
Kevin Chan | 5bebd2e | 2013-01-30 20:25:05 -0800 | [diff] [blame] | 149 | enum msm_vfe_axi_stream_update_type { |
| 150 | ENABLE_STREAM_BUF_DIVERT, |
| 151 | DISABLE_STREAM_BUF_DIVERT, |
| 152 | UPDATE_STREAM_FRAMEDROP_PATTERN, |
| 153 | }; |
| 154 | |
| 155 | struct msm_vfe_axi_stream_update_cmd { |
| 156 | uint32_t stream_handle; |
| 157 | enum msm_vfe_axi_stream_update_type update_type; |
| 158 | enum msm_vfe_frame_skip_pattern skip_pattern; |
| 159 | }; |
| 160 | |
Kevin Chan | 3454e2b | 2013-01-17 19:18:57 -0800 | [diff] [blame] | 161 | enum msm_vfe_stats_pipeline_policy { |
| 162 | STATS_COMP_ALL, |
| 163 | STATS_COMP_NONE, |
| 164 | MAX_STATS_POLICY, |
| 165 | }; |
| 166 | |
Kevin Chan | 1d5fd4a | 2013-01-11 14:08:14 -0800 | [diff] [blame] | 167 | enum msm_isp_stats_type { |
| 168 | MSM_ISP_STATS_AEC, /* legacy based AEC */ |
| 169 | MSM_ISP_STATS_AF, /* legacy based AF */ |
| 170 | MSM_ISP_STATS_AWB, /* legacy based AWB */ |
| 171 | MSM_ISP_STATS_RS, /* legacy based RS */ |
| 172 | MSM_ISP_STATS_CS, /* legacy based CS */ |
| 173 | MSM_ISP_STATS_IHIST, /* legacy based HIST */ |
| 174 | MSM_ISP_STATS_SKIN, /* legacy based SKIN */ |
| 175 | MSM_ISP_STATS_BG, /* Bayer Grids */ |
| 176 | MSM_ISP_STATS_BF, /* Bayer Focus */ |
| 177 | MSM_ISP_STATS_BE, /* Bayer Exposure*/ |
| 178 | MSM_ISP_STATS_BHIST, /* Bayer Hist */ |
| 179 | MSM_ISP_STATS_MAX /* MAX */ |
| 180 | }; |
| 181 | |
| 182 | struct msm_vfe_stats_stream_request_cmd { |
| 183 | uint32_t session_id; |
| 184 | uint32_t stream_id; |
| 185 | enum msm_isp_stats_type stats_type; |
Mingcheng Zhu | 503a6f9 | 2013-01-06 13:23:24 -0800 | [diff] [blame] | 186 | uint32_t framedrop_pattern; |
Kevin Chan | 3454e2b | 2013-01-17 19:18:57 -0800 | [diff] [blame] | 187 | uint32_t irq_subsample_pattern; |
Kevin Chan | 1d5fd4a | 2013-01-11 14:08:14 -0800 | [diff] [blame] | 188 | uint32_t stream_handle; |
Kevin Chan | 3454e2b | 2013-01-17 19:18:57 -0800 | [diff] [blame] | 189 | uint8_t comp_flag; |
Kevin Chan | 1d5fd4a | 2013-01-11 14:08:14 -0800 | [diff] [blame] | 190 | }; |
Kevin Chan | 3454e2b | 2013-01-17 19:18:57 -0800 | [diff] [blame] | 191 | |
Kevin Chan | 1d5fd4a | 2013-01-11 14:08:14 -0800 | [diff] [blame] | 192 | struct msm_vfe_stats_stream_release_cmd { |
| 193 | uint32_t stream_handle; |
| 194 | }; |
| 195 | struct msm_vfe_stats_stream_cfg_cmd { |
| 196 | uint8_t num_streams; |
| 197 | uint32_t stream_handle[MSM_ISP_STATS_MAX]; |
| 198 | uint8_t enable; |
| 199 | }; |
Kevin Chan | 3454e2b | 2013-01-17 19:18:57 -0800 | [diff] [blame] | 200 | |
| 201 | struct msm_vfe_stats_comp_policy_cfg { |
| 202 | enum msm_vfe_stats_pipeline_policy stats_pipeline_policy; |
| 203 | uint32_t comp_framedrop_pattern; |
| 204 | uint32_t comp_irq_subsample_pattern; |
| 205 | }; |
| 206 | |
Kevin Chan | 1d5fd4a | 2013-01-11 14:08:14 -0800 | [diff] [blame] | 207 | enum msm_vfe_reg_cfg_type { |
| 208 | VFE_WRITE, |
| 209 | VFE_WRITE_MB, |
| 210 | VFE_READ, |
Kevin Chan | 7672ef3 | 2013-01-21 22:10:53 -0800 | [diff] [blame] | 211 | VFE_CFG_MASK, |
| 212 | VFE_WRITE_DMI_16BIT, |
| 213 | VFE_WRITE_DMI_32BIT, |
| 214 | VFE_WRITE_DMI_64BIT, |
| 215 | VFE_READ_DMI_16BIT, |
| 216 | VFE_READ_DMI_32BIT, |
| 217 | VFE_READ_DMI_64BIT, |
Kevin Chan | 1d5fd4a | 2013-01-11 14:08:14 -0800 | [diff] [blame] | 218 | }; |
| 219 | |
| 220 | struct msm_vfe_cfg_cmd2 { |
| 221 | uint16_t num_cfg; |
| 222 | uint16_t cmd_len; |
| 223 | void __user *cfg_data; |
| 224 | void __user *cfg_cmd; |
| 225 | }; |
| 226 | |
Kevin Chan | 7672ef3 | 2013-01-21 22:10:53 -0800 | [diff] [blame] | 227 | struct msm_vfe_reg_rw_info { |
Kevin Chan | 1d5fd4a | 2013-01-11 14:08:14 -0800 | [diff] [blame] | 228 | uint32_t reg_offset; |
Kevin Chan | 7672ef3 | 2013-01-21 22:10:53 -0800 | [diff] [blame] | 229 | uint32_t cmd_data_offset; |
Kevin Chan | 1d5fd4a | 2013-01-11 14:08:14 -0800 | [diff] [blame] | 230 | uint32_t len; |
Kevin Chan | 7672ef3 | 2013-01-21 22:10:53 -0800 | [diff] [blame] | 231 | }; |
| 232 | |
| 233 | struct msm_vfe_reg_mask_info { |
| 234 | uint32_t reg_offset; |
| 235 | uint32_t mask; |
| 236 | uint32_t val; |
| 237 | }; |
| 238 | |
| 239 | struct msm_vfe_reg_dmi_info { |
| 240 | uint32_t hi_tbl_offset; /*Optional*/ |
| 241 | uint32_t lo_tbl_offset; /*Required*/ |
| 242 | uint32_t len; |
| 243 | }; |
| 244 | |
| 245 | struct msm_vfe_reg_cfg_cmd { |
| 246 | union { |
| 247 | struct msm_vfe_reg_rw_info rw_info; |
| 248 | struct msm_vfe_reg_mask_info mask_info; |
| 249 | struct msm_vfe_reg_dmi_info dmi_info; |
| 250 | } u; |
| 251 | |
Kevin Chan | 1d5fd4a | 2013-01-11 14:08:14 -0800 | [diff] [blame] | 252 | enum msm_vfe_reg_cfg_type cmd_type; |
| 253 | }; |
| 254 | |
| 255 | struct msm_isp_buf_request { |
| 256 | uint32_t session_id; |
| 257 | uint32_t stream_id; |
| 258 | uint8_t num_buf; |
| 259 | uint32_t handle; |
| 260 | }; |
| 261 | |
| 262 | struct msm_isp_qbuf_info { |
| 263 | uint32_t handle; |
| 264 | int buf_idx; |
| 265 | /*Only used for prepare buffer*/ |
| 266 | struct v4l2_buffer buffer; |
Kevin Chan | 5bebd2e | 2013-01-30 20:25:05 -0800 | [diff] [blame] | 267 | /*Only used for diverted buffer*/ |
| 268 | uint32_t dirty_buf; |
Kevin Chan | 1d5fd4a | 2013-01-11 14:08:14 -0800 | [diff] [blame] | 269 | }; |
| 270 | |
| 271 | struct msm_vfe_axi_src_state { |
| 272 | enum msm_vfe_input_src input_src; |
| 273 | uint32_t src_active; |
| 274 | }; |
| 275 | |
| 276 | enum msm_isp_event_idx { |
| 277 | ISP_REG_UPDATE = 0, |
| 278 | ISP_START_ACK = 1, |
| 279 | ISP_STOP_ACK = 2, |
| 280 | ISP_IRQ_VIOLATION = 3, |
| 281 | ISP_WM_BUS_OVERFLOW = 4, |
| 282 | ISP_STATS_OVERFLOW = 5, |
| 283 | ISP_CAMIF_ERROR = 6, |
| 284 | ISP_STATS_NOTIFY = 7, |
| 285 | ISP_SOF = 8, |
| 286 | ISP_EOF = 9, |
| 287 | ISP_BUF_DIVERT = 10, |
| 288 | ISP_EVENT_MAX = 11 |
| 289 | }; |
| 290 | |
| 291 | #define ISP_EVENT_BASE (V4L2_EVENT_PRIVATE_START + 1) |
| 292 | #define ISP_EVENT_REG_UPDATE (ISP_EVENT_BASE + ISP_REG_UPDATE) |
| 293 | #define ISP_EVENT_START_ACK (ISP_EVENT_BASE + ISP_START_ACK) |
| 294 | #define ISP_EVENT_STOP_ACK (ISP_EVENT_BASE + ISP_STOP_ACK) |
| 295 | #define ISP_EVENT_IRQ_VIOLATION (ISP_EVENT_BASE + ISP_IRQ_VIOLATION) |
| 296 | #define ISP_EVENT_WM_BUS_OVERFLOW (ISP_EVENT_BASE + ISP_WM_BUS_OVERFLOW) |
| 297 | #define ISP_EVENT_STATS_OVERFLOW (ISP_EVENT_BASE + ISP_STATS_OVERFLOW) |
| 298 | #define ISP_EVENT_CAMIF_ERROR (ISP_EVENT_BASE + ISP_CAMIF_ERROR) |
| 299 | #define ISP_EVENT_STATS_NOTIFY (ISP_EVENT_BASE + ISP_STATS_NOTIFY) |
| 300 | #define ISP_EVENT_SOF (ISP_EVENT_BASE + ISP_SOF) |
| 301 | #define ISP_EVENT_EOF (ISP_EVENT_BASE + ISP_EOF) |
| 302 | #define ISP_EVENT_BUF_DIVERT (ISP_EVENT_BASE + ISP_BUF_DIVERT) |
| 303 | |
| 304 | |
| 305 | /* The msm_v4l2_event_data structure should match the |
| 306 | * v4l2_event.u.data field. |
| 307 | * should not exceed 64 bytes */ |
| 308 | |
| 309 | struct msm_isp_buf_event { |
| 310 | uint32_t session_id; |
| 311 | uint32_t stream_id; |
| 312 | uint32_t handle; |
| 313 | int8_t buf_idx; |
| 314 | }; |
| 315 | struct msm_isp_stats_event { |
| 316 | uint32_t stats_mask; /* 4 bytes */ |
| 317 | uint8_t stats_buf_idxs[MSM_ISP_STATS_MAX]; /* 11 bytes */ |
| 318 | }; |
| 319 | |
| 320 | struct msm_isp_stream_ack { |
| 321 | uint32_t session_id; |
| 322 | uint32_t stream_id; |
| 323 | uint32_t handle; |
| 324 | }; |
| 325 | |
| 326 | struct msm_isp_event_data { |
Kevin Chan | d465e20 | 2013-02-22 00:55:29 -0800 | [diff] [blame^] | 327 | struct timeval timestamp; /*Wall clock*/ |
Kevin Chan | 1d5fd4a | 2013-01-11 14:08:14 -0800 | [diff] [blame] | 328 | /* if pix is a src frame_id is from camif */ |
| 329 | uint32_t frame_id; |
| 330 | union { |
| 331 | /* START_ACK, STOP_ACK */ |
| 332 | struct msm_isp_stream_ack stream_ack; |
| 333 | /* REG_UPDATE_TRIGGER, bus over flow */ |
| 334 | enum msm_vfe_input_src input_src; |
| 335 | /* stats notify */ |
| 336 | struct msm_isp_stats_event stats; |
| 337 | /* IRQ_VIOLATION, STATS_OVER_FLOW, WM_OVER_FLOW */ |
| 338 | uint32_t irq_status_mask; |
| 339 | struct msm_isp_buf_event buf_done; |
| 340 | } u; /* union can have max 52 bytes */ |
| 341 | }; |
| 342 | |
| 343 | #define VIDIOC_MSM_VFE_REG_CFG \ |
| 344 | _IOWR('V', BASE_VIDIOC_PRIVATE, struct msm_vfe_cfg_cmd2) |
| 345 | |
| 346 | #define VIDIOC_MSM_ISP_REQUEST_BUF \ |
| 347 | _IOWR('V', BASE_VIDIOC_PRIVATE+1, struct msm_isp_buf_request) |
| 348 | |
| 349 | #define VIDIOC_MSM_ISP_ENQUEUE_BUF \ |
| 350 | _IOWR('V', BASE_VIDIOC_PRIVATE+2, struct msm_isp_qbuf_info) |
| 351 | |
| 352 | #define VIDIOC_MSM_ISP_RELEASE_BUF \ |
| 353 | _IOWR('V', BASE_VIDIOC_PRIVATE+3, struct msm_isp_buf_request) |
| 354 | |
| 355 | #define VIDIOC_MSM_ISP_REQUEST_STREAM \ |
| 356 | _IOWR('V', BASE_VIDIOC_PRIVATE+4, struct msm_vfe_axi_stream_request_cmd) |
| 357 | |
| 358 | #define VIDIOC_MSM_ISP_CFG_STREAM \ |
| 359 | _IOWR('V', BASE_VIDIOC_PRIVATE+5, struct msm_vfe_axi_stream_cfg_cmd) |
| 360 | |
| 361 | #define VIDIOC_MSM_ISP_RELEASE_STREAM \ |
| 362 | _IOWR('V', BASE_VIDIOC_PRIVATE+6, struct msm_vfe_axi_stream_release_cmd) |
| 363 | |
| 364 | #define VIDIOC_MSM_ISP_INPUT_CFG \ |
| 365 | _IOWR('V', BASE_VIDIOC_PRIVATE+7, struct msm_vfe_input_cfg) |
| 366 | |
| 367 | #define VIDIOC_MSM_ISP_SET_SRC_STATE \ |
| 368 | _IOWR('V', BASE_VIDIOC_PRIVATE+8, struct msm_vfe_axi_src_state) |
| 369 | |
| 370 | #define VIDIOC_MSM_ISP_REQUEST_STATS_STREAM \ |
| 371 | _IOWR('V', BASE_VIDIOC_PRIVATE+9, \ |
| 372 | struct msm_vfe_stats_stream_request_cmd) |
| 373 | |
| 374 | #define VIDIOC_MSM_ISP_CFG_STATS_STREAM \ |
| 375 | _IOWR('V', BASE_VIDIOC_PRIVATE+10, struct msm_vfe_stats_stream_cfg_cmd) |
| 376 | |
| 377 | #define VIDIOC_MSM_ISP_RELEASE_STATS_STREAM \ |
| 378 | _IOWR('V', BASE_VIDIOC_PRIVATE+11, \ |
| 379 | struct msm_vfe_stats_stream_release_cmd) |
| 380 | |
Kevin Chan | 3454e2b | 2013-01-17 19:18:57 -0800 | [diff] [blame] | 381 | #define VIDIOC_MSM_ISP_CFG_STATS_COMP_POLICY \ |
| 382 | _IOWR('V', BASE_VIDIOC_PRIVATE+12, \ |
| 383 | struct msm_vfe_stats_comp_policy_cfg) |
| 384 | |
Kevin Chan | 5bebd2e | 2013-01-30 20:25:05 -0800 | [diff] [blame] | 385 | #define VIDIOC_MSM_ISP_UPDATE_STREAM \ |
| 386 | _IOWR('V', BASE_VIDIOC_PRIVATE+13, struct msm_vfe_axi_stream_update_cmd) |
| 387 | |
Kevin Chan | 1d5fd4a | 2013-01-11 14:08:14 -0800 | [diff] [blame] | 388 | #endif /* __MSMB_ISP__ */ |