1 #ifndef __MSMB_PPROC_H 2 #define __MSMB_PPROC_H 3 4 #ifdef MSM_CAMERA_BIONIC 5 #include <sys/types.h> 6 #endif 7 #ifdef CONFIG_COMPAT 8 #include <linux/compat.h> 9 #endif 10 #include <linux/videodev2.h> 11 #include <linux/types.h> 12 #include <media/msmb_generic_buf_mgr.h> 13 14 /* Should be same as VIDEO_MAX_PLANES in videodev2.h */ 15 #define MAX_PLANES VIDEO_MAX_PLANES 16 /* PARTIAL_FRAME_STRIPE_COUNT must be even */ 17 #define PARTIAL_FRAME_STRIPE_COUNT 4 18 19 #define MAX_NUM_CPP_STRIPS 8 20 #define MSM_CPP_MAX_NUM_PLANES 3 21 #define MSM_CPP_MIN_FRAME_LENGTH 13 22 #define MSM_CPP_MAX_FRAME_LENGTH 4096 23 #define MSM_CPP_MAX_FW_NAME_LEN 32 24 #define MAX_FREQ_TBL 10 25 26 enum msm_cpp_frame_type { 27 MSM_CPP_OFFLINE_FRAME, 28 MSM_CPP_REALTIME_FRAME, 29 }; 30 31 enum msm_vpe_frame_type { 32 MSM_VPE_OFFLINE_FRAME, 33 MSM_VPE_REALTIME_FRAME, 34 }; 35 36 struct msm_cpp_frame_strip_info { 37 uint32_t scale_v_en; 38 uint32_t scale_h_en; 39 40 uint32_t upscale_v_en; 41 uint32_t upscale_h_en; 42 43 int32_t src_start_x; 44 uint32_t src_end_x; 45 int32_t src_start_y; 46 uint32_t src_end_y; 47 48 /* extra 5th and 6th layer parameters */ 49 int32_t extra_src_start_x; 50 int32_t extra_src_end_x; 51 int32_t extra_src_start_y; 52 int32_t extra_src_end_y; 53 54 int32_t extra_initial_vertical_count[2]; 55 int32_t extra_initial_horizontal_count[2]; 56 57 /* crop downscale 32x pixels */ 58 int32_t extra_left_crop; 59 int32_t extra_top_crop; 60 61 int32_t extra_pad_bottom; 62 int32_t extra_pad_top; 63 int32_t extra_pad_right; 64 int32_t extra_pad_left; 65 66 int32_t extra_upscale_width; 67 int32_t extra_upscale_height; 68 69 uint32_t temporal_pad_bottom; 70 uint32_t temporal_pad_top; 71 uint32_t temporal_pad_right; 72 uint32_t temporal_pad_left; 73 74 int32_t temporal_src_start_x; 75 uint32_t temporal_src_end_x; 76 int32_t temporal_src_start_y; 77 uint32_t temporal_src_end_y; 78 79 /* Padding is required for upscaler because it does not 80 * pad internally like other blocks, also needed for rotation 81 * rotation expects all the blocks in the stripe to be the same size 82 * Padding is done such that all the extra padded pixels 83 * are on the right and bottom 84 */ 85 uint32_t pad_bottom; 86 uint32_t pad_top; 87 uint32_t pad_right; 88 uint32_t pad_left; 89 90 uint32_t v_init_phase; 91 uint32_t h_init_phase; 92 uint32_t h_phase_step; 93 uint32_t v_phase_step; 94 95 uint32_t spatial_denoise_crop_width_first_pixel; 96 uint32_t spatial_denoise_crop_width_last_pixel; 97 uint32_t spatial_denoise_crop_height_first_line; 98 uint32_t spatial_denoise_crop_height_last_line; 99 100 uint32_t sharpen_crop_height_first_line; 101 uint32_t sharpen_crop_height_last_line; 102 uint32_t sharpen_crop_width_first_pixel; 103 uint32_t sharpen_crop_width_last_pixel; 104 105 uint32_t temporal_denoise_crop_width_first_pixel; 106 uint32_t temporal_denoise_crop_width_last_pixel; 107 uint32_t temporal_denoise_crop_height_first_line; 108 uint32_t temporal_denoise_crop_height_last_line; 109 110 uint32_t prescaler_spatial_denoise_crop_width_first_pixel; 111 uint32_t prescaler_spatial_denoise_crop_width_last_pixel; 112 uint32_t prescaler_spatial_denoise_crop_height_first_line; 113 uint32_t prescaler_spatial_denoise_crop_height_last_line; 114 115 uint32_t state_crop_width_first_pixel; 116 uint32_t state_crop_width_last_pixel; 117 uint32_t state_crop_height_first_line; 118 uint32_t state_crop_height_last_line; 119 120 int32_t dst_start_x; 121 uint32_t dst_end_x; 122 int32_t dst_start_y; 123 uint32_t dst_end_y; 124 125 int32_t temporal_dst_start_x; 126 uint32_t temporal_dst_end_x; 127 int32_t temporal_dst_start_y; 128 uint32_t temporal_dst_end_y; 129 130 uint32_t input_bytes_per_pixel; 131 uint32_t output_bytes_per_pixel; 132 uint32_t temporal_bytes_per_pixel; 133 134 uint32_t source_address[2]; 135 uint32_t extra_source_address[2]; 136 uint32_t destination_address[2]; 137 /* source_address[1] is used for CbCR planar 138 * to CbCr interleaved conversion 139 */ 140 uint32_t temporal_source_address[2]; 141 /* destination_address[1] is used for CbCr interleved 142 * to CbCr planar conversion 143 */ 144 uint32_t temporal_destination_address[2]; 145 uint32_t src_stride; 146 uint32_t dst_stride; 147 uint32_t rotate_270; 148 uint32_t horizontal_flip; 149 uint32_t vertical_flip; 150 uint32_t scale_output_width; 151 uint32_t scale_output_height; 152 uint32_t spatial_denoise_crop_en; 153 uint32_t sharpen_crop_en; 154 uint32_t temporal_denoise_crop_en; 155 uint32_t prescaler_spatial_denoise_crop_en; 156 uint32_t state_crop_en; 157 158 int32_t we_h_init; 159 int32_t we_v_init; 160 int32_t we_h_step; 161 int32_t we_v_step; 162 }; 163 164 struct msm_cpp_buffer_info_t { 165 int32_t fd; 166 uint32_t index; 167 uint32_t offset; 168 uint8_t native_buff; 169 uint8_t processed_divert; 170 uint32_t identity; 171 }; 172 173 struct msm_cpp_stream_buff_info_t { 174 uint32_t identity; 175 uint32_t num_buffs; 176 struct msm_cpp_buffer_info_t *buffer_info; 177 }; 178 179 enum msm_cpp_batch_mode_t { 180 BATCH_MODE_NONE, 181 BATCH_MODE_VIDEO, 182 BATCH_MODE_PREVIEW 183 }; 184 185 struct msm_cpp_batch_info_t { 186 enum msm_cpp_batch_mode_t batch_mode; 187 uint32_t batch_size; 188 uint32_t intra_plane_offset[MAX_PLANES]; 189 uint32_t pick_preview_idx; 190 uint32_t cont_idx; 191 }; 192 193 struct msm_cpp_frame_info_t { 194 int32_t frame_id; 195 struct timeval timestamp; 196 uint32_t inst_id; 197 uint32_t identity; 198 uint32_t client_id; 199 enum msm_cpp_frame_type frame_type; 200 uint32_t num_strips; 201 struct msm_cpp_frame_strip_info __user *strip_info; 202 uint32_t msg_len; 203 uint32_t *cpp_cmd_msg; 204 int src_fd; 205 int dst_fd; 206 struct timeval in_time, out_time; 207 void __user *cookie; 208 int32_t *status; 209 int32_t duplicate_output; 210 uint32_t duplicate_identity; 211 uint32_t feature_mask; 212 uint8_t we_disable; 213 struct msm_cpp_buffer_info_t input_buffer_info; 214 struct msm_cpp_buffer_info_t output_buffer_info[8]; 215 struct msm_cpp_buffer_info_t duplicate_buffer_info; 216 struct msm_cpp_buffer_info_t tnr_scratch_buffer_info[2]; 217 uint32_t reserved; 218 uint8_t partial_frame_indicator; 219 /* the followings are used only for partial_frame type 220 * and is only used for offline frame processing and 221 * only if payload big enough and need to be split into partial_frame 222 * if first_payload, kernel acquires output buffer 223 * first payload must have the last stripe 224 * buffer addresses from 0 to last_stripe_index are updated. 225 * kernel updates payload with msg_len and stripe_info 226 * kernel sends top level, plane level, then only stripes 227 * starting with first_stripe_index and 228 * ends with last_stripe_index 229 * kernel then sends trailing flag at frame done, 230 * if last payload, kernel queues the output buffer to HAL 231 */ 232 uint8_t first_payload; 233 uint8_t last_payload; 234 uint32_t first_stripe_index; 235 uint32_t last_stripe_index; 236 uint32_t stripe_info_offset; 237 uint32_t stripe_info; 238 struct msm_cpp_batch_info_t batch_info; 239 }; 240 241 struct msm_cpp_pop_stream_info_t { 242 int32_t frame_id; 243 uint32_t identity; 244 }; 245 246 struct cpp_hw_info { 247 uint32_t cpp_hw_version; 248 uint32_t cpp_hw_caps; 249 unsigned long freq_tbl[MAX_FREQ_TBL]; 250 uint32_t freq_tbl_count; 251 }; 252 253 struct msm_vpe_frame_strip_info { 254 uint32_t src_w; 255 uint32_t src_h; 256 uint32_t dst_w; 257 uint32_t dst_h; 258 uint32_t src_x; 259 uint32_t src_y; 260 uint32_t phase_step_x; 261 uint32_t phase_step_y; 262 uint32_t phase_init_x; 263 uint32_t phase_init_y; 264 }; 265 266 struct msm_vpe_buffer_info_t { 267 int32_t fd; 268 uint32_t index; 269 uint32_t offset; 270 uint8_t native_buff; 271 uint8_t processed_divert; 272 }; 273 274 struct msm_vpe_stream_buff_info_t { 275 uint32_t identity; 276 uint32_t num_buffs; 277 struct msm_vpe_buffer_info_t *buffer_info; 278 }; 279 280 struct msm_vpe_frame_info_t { 281 int32_t frame_id; 282 struct timeval timestamp; 283 uint32_t inst_id; 284 uint32_t identity; 285 uint32_t client_id; 286 enum msm_vpe_frame_type frame_type; 287 struct msm_vpe_frame_strip_info strip_info; 288 unsigned long src_fd; 289 unsigned long dst_fd; 290 struct ion_handle *src_ion_handle; 291 struct ion_handle *dest_ion_handle; 292 unsigned long src_phyaddr; 293 unsigned long dest_phyaddr; 294 unsigned long src_chroma_plane_offset; 295 unsigned long dest_chroma_plane_offset; 296 struct timeval in_time, out_time; 297 void *cookie; 298 299 struct msm_vpe_buffer_info_t input_buffer_info; 300 struct msm_vpe_buffer_info_t output_buffer_info; 301 }; 302 303 struct msm_pproc_queue_buf_info { 304 struct msm_buf_mngr_info buff_mgr_info; 305 uint8_t is_buf_dirty; 306 }; 307 308 struct msm_cpp_clock_settings_t { 309 unsigned long clock_rate; 310 uint64_t avg; 311 uint64_t inst; 312 }; 313 314 #define VIDIOC_MSM_CPP_CFG \ 315 _IOWR('V', BASE_VIDIOC_PRIVATE, struct msm_camera_v4l2_ioctl_t) 316 317 #define VIDIOC_MSM_CPP_GET_EVENTPAYLOAD \ 318 _IOWR('V', BASE_VIDIOC_PRIVATE + 1, struct msm_camera_v4l2_ioctl_t) 319 320 #define VIDIOC_MSM_CPP_GET_INST_INFO \ 321 _IOWR('V', BASE_VIDIOC_PRIVATE + 2, struct msm_camera_v4l2_ioctl_t) 322 323 #define VIDIOC_MSM_CPP_LOAD_FIRMWARE \ 324 _IOWR('V', BASE_VIDIOC_PRIVATE + 3, struct msm_camera_v4l2_ioctl_t) 325 326 #define VIDIOC_MSM_CPP_GET_HW_INFO \ 327 _IOWR('V', BASE_VIDIOC_PRIVATE + 4, struct msm_camera_v4l2_ioctl_t) 328 329 #define VIDIOC_MSM_CPP_FLUSH_QUEUE \ 330 _IOWR('V', BASE_VIDIOC_PRIVATE + 5, struct msm_camera_v4l2_ioctl_t) 331 332 #define VIDIOC_MSM_CPP_ENQUEUE_STREAM_BUFF_INFO \ 333 _IOWR('V', BASE_VIDIOC_PRIVATE + 6, struct msm_camera_v4l2_ioctl_t) 334 335 #define VIDIOC_MSM_CPP_DEQUEUE_STREAM_BUFF_INFO \ 336 _IOWR('V', BASE_VIDIOC_PRIVATE + 7, struct msm_camera_v4l2_ioctl_t) 337 338 #define VIDIOC_MSM_VPE_CFG \ 339 _IOWR('V', BASE_VIDIOC_PRIVATE + 8, struct msm_camera_v4l2_ioctl_t) 340 341 #define VIDIOC_MSM_VPE_TRANSACTION_SETUP \ 342 _IOWR('V', BASE_VIDIOC_PRIVATE + 9, struct msm_camera_v4l2_ioctl_t) 343 344 #define VIDIOC_MSM_VPE_GET_EVENTPAYLOAD \ 345 _IOWR('V', BASE_VIDIOC_PRIVATE + 10, struct msm_camera_v4l2_ioctl_t) 346 347 #define VIDIOC_MSM_VPE_GET_INST_INFO \ 348 _IOWR('V', BASE_VIDIOC_PRIVATE + 11, struct msm_camera_v4l2_ioctl_t) 349 350 #define VIDIOC_MSM_VPE_ENQUEUE_STREAM_BUFF_INFO \ 351 _IOWR('V', BASE_VIDIOC_PRIVATE + 12, struct msm_camera_v4l2_ioctl_t) 352 353 #define VIDIOC_MSM_VPE_DEQUEUE_STREAM_BUFF_INFO \ 354 _IOWR('V', BASE_VIDIOC_PRIVATE + 13, struct msm_camera_v4l2_ioctl_t) 355 356 #define VIDIOC_MSM_CPP_QUEUE_BUF \ 357 _IOWR('V', BASE_VIDIOC_PRIVATE + 14, struct msm_camera_v4l2_ioctl_t) 358 359 #define VIDIOC_MSM_CPP_APPEND_STREAM_BUFF_INFO \ 360 _IOWR('V', BASE_VIDIOC_PRIVATE + 15, struct msm_camera_v4l2_ioctl_t) 361 362 #define VIDIOC_MSM_CPP_SET_CLOCK \ 363 _IOWR('V', BASE_VIDIOC_PRIVATE + 16, struct msm_camera_v4l2_ioctl_t) 364 365 #define VIDIOC_MSM_CPP_POP_STREAM_BUFFER \ 366 _IOWR('V', BASE_VIDIOC_PRIVATE + 17, struct msm_camera_v4l2_ioctl_t) 367 368 #define VIDIOC_MSM_CPP_IOMMU_ATTACH \ 369 _IOWR('V', BASE_VIDIOC_PRIVATE + 18, struct msm_camera_v4l2_ioctl_t) 370 371 #define VIDIOC_MSM_CPP_IOMMU_DETACH \ 372 _IOWR('V', BASE_VIDIOC_PRIVATE + 19, struct msm_camera_v4l2_ioctl_t) 373 374 #define VIDIOC_MSM_CPP_DELETE_STREAM_BUFF\ 375 _IOWR('V', BASE_VIDIOC_PRIVATE + 20, struct msm_camera_v4l2_ioctl_t) 376 377 378 #define V4L2_EVENT_CPP_FRAME_DONE (V4L2_EVENT_PRIVATE_START + 0) 379 #define V4L2_EVENT_VPE_FRAME_DONE (V4L2_EVENT_PRIVATE_START + 1) 380 381 struct msm_camera_v4l2_ioctl_t { 382 uint32_t id; 383 size_t len; 384 int32_t trans_code; 385 void __user *ioctl_ptr; 386 }; 387 388 #ifdef CONFIG_COMPAT 389 struct msm_cpp_frame_info32_t { 390 int32_t frame_id; 391 struct compat_timeval timestamp; 392 uint32_t inst_id; 393 uint32_t identity; 394 uint32_t client_id; 395 enum msm_cpp_frame_type frame_type; 396 uint32_t num_strips; 397 compat_caddr_t strip_info; 398 uint32_t msg_len; 399 compat_uint_t cpp_cmd_msg; 400 int src_fd; 401 int dst_fd; 402 struct compat_timeval in_time, out_time; 403 compat_caddr_t cookie; 404 compat_int_t status; 405 int32_t duplicate_output; 406 uint32_t duplicate_identity; 407 uint32_t feature_mask; 408 uint8_t we_disable; 409 struct msm_cpp_buffer_info_t input_buffer_info; 410 struct msm_cpp_buffer_info_t output_buffer_info[8]; 411 struct msm_cpp_buffer_info_t duplicate_buffer_info; 412 struct msm_cpp_buffer_info_t tnr_scratch_buffer_info[2]; 413 uint32_t reserved; 414 uint8_t partial_frame_indicator; 415 /* the followings are used only for partial_frame type 416 * and is only used for offline frame processing and 417 * only if payload big enough and need to be split into partial_frame 418 * if first_payload, kernel acquires output buffer 419 * first payload must have the last stripe 420 * buffer addresses from 0 to last_stripe_index are updated. 421 * kernel updates payload with msg_len and stripe_info 422 * kernel sends top level, plane level, then only stripes 423 * starting with first_stripe_index and 424 * ends with last_stripe_index 425 * kernel then sends trailing flag at frame done, 426 * if last payload, kernel queues the output buffer to HAL 427 */ 428 uint8_t first_payload; 429 uint8_t last_payload; 430 uint32_t first_stripe_index; 431 uint32_t last_stripe_index; 432 uint32_t stripe_info_offset; 433 uint32_t stripe_info; 434 struct msm_cpp_batch_info_t batch_info; 435 }; 436 437 struct msm_cpp_clock_settings32_t { 438 compat_long_t clock_rate; 439 uint64_t avg; 440 uint64_t inst; 441 }; 442 443 struct msm_cpp_stream_buff_info32_t { 444 uint32_t identity; 445 uint32_t num_buffs; 446 compat_caddr_t buffer_info; 447 }; 448 449 struct msm_pproc_queue_buf_info32_t { 450 struct msm_buf_mngr_info32_t buff_mgr_info; 451 uint8_t is_buf_dirty; 452 }; 453 454 struct cpp_hw_info_32_t { 455 uint32_t cpp_hw_version; 456 uint32_t cpp_hw_caps; 457 compat_long_t freq_tbl[MAX_FREQ_TBL]; 458 uint32_t freq_tbl_count; 459 }; 460 461 462 #define VIDIOC_MSM_CPP_CFG32 \ 463 _IOWR('V', BASE_VIDIOC_PRIVATE, struct msm_camera_v4l2_ioctl32_t) 464 465 #define VIDIOC_MSM_CPP_GET_EVENTPAYLOAD32 \ 466 _IOWR('V', BASE_VIDIOC_PRIVATE + 1, struct msm_camera_v4l2_ioctl32_t) 467 468 #define VIDIOC_MSM_CPP_GET_INST_INFO32 \ 469 _IOWR('V', BASE_VIDIOC_PRIVATE + 2, struct msm_camera_v4l2_ioctl32_t) 470 471 #define VIDIOC_MSM_CPP_LOAD_FIRMWARE32 \ 472 _IOWR('V', BASE_VIDIOC_PRIVATE + 3, struct msm_camera_v4l2_ioctl32_t) 473 474 #define VIDIOC_MSM_CPP_GET_HW_INFO32 \ 475 _IOWR('V', BASE_VIDIOC_PRIVATE + 4, struct msm_camera_v4l2_ioctl32_t) 476 477 #define VIDIOC_MSM_CPP_FLUSH_QUEUE32 \ 478 _IOWR('V', BASE_VIDIOC_PRIVATE + 5, struct msm_camera_v4l2_ioctl32_t) 479 480 #define VIDIOC_MSM_CPP_ENQUEUE_STREAM_BUFF_INFO32 \ 481 _IOWR('V', BASE_VIDIOC_PRIVATE + 6, struct msm_camera_v4l2_ioctl32_t) 482 483 #define VIDIOC_MSM_CPP_DEQUEUE_STREAM_BUFF_INFO32 \ 484 _IOWR('V', BASE_VIDIOC_PRIVATE + 7, struct msm_camera_v4l2_ioctl32_t) 485 486 #define VIDIOC_MSM_VPE_CFG32 \ 487 _IOWR('V', BASE_VIDIOC_PRIVATE + 8, struct msm_camera_v4l2_ioctl32_t) 488 489 #define VIDIOC_MSM_VPE_TRANSACTION_SETUP32 \ 490 _IOWR('V', BASE_VIDIOC_PRIVATE + 9, struct msm_camera_v4l2_ioctl32_t) 491 492 #define VIDIOC_MSM_VPE_GET_EVENTPAYLOAD32 \ 493 _IOWR('V', BASE_VIDIOC_PRIVATE + 10, struct msm_camera_v4l2_ioctl32_t) 494 495 #define VIDIOC_MSM_VPE_GET_INST_INFO32 \ 496 _IOWR('V', BASE_VIDIOC_PRIVATE + 11, struct msm_camera_v4l2_ioctl32_t) 497 498 #define VIDIOC_MSM_VPE_ENQUEUE_STREAM_BUFF_INFO32 \ 499 _IOWR('V', BASE_VIDIOC_PRIVATE + 12, struct msm_camera_v4l2_ioctl32_t) 500 501 #define VIDIOC_MSM_VPE_DEQUEUE_STREAM_BUFF_INFO32 \ 502 _IOWR('V', BASE_VIDIOC_PRIVATE + 13, struct msm_camera_v4l2_ioctl32_t) 503 504 #define VIDIOC_MSM_CPP_QUEUE_BUF32 \ 505 _IOWR('V', BASE_VIDIOC_PRIVATE + 14, struct msm_camera_v4l2_ioctl32_t) 506 507 #define VIDIOC_MSM_CPP_APPEND_STREAM_BUFF_INFO32 \ 508 _IOWR('V', BASE_VIDIOC_PRIVATE + 15, struct msm_camera_v4l2_ioctl32_t) 509 510 #define VIDIOC_MSM_CPP_SET_CLOCK32 \ 511 _IOWR('V', BASE_VIDIOC_PRIVATE + 16, struct msm_camera_v4l2_ioctl32_t) 512 513 #define VIDIOC_MSM_CPP_POP_STREAM_BUFFER32 \ 514 _IOWR('V', BASE_VIDIOC_PRIVATE + 17, struct msm_camera_v4l2_ioctl32_t) 515 516 #define VIDIOC_MSM_CPP_IOMMU_ATTACH32 \ 517 _IOWR('V', BASE_VIDIOC_PRIVATE + 18, struct msm_camera_v4l2_ioctl32_t) 518 519 #define VIDIOC_MSM_CPP_IOMMU_DETACH32 \ 520 _IOWR('V', BASE_VIDIOC_PRIVATE + 19, struct msm_camera_v4l2_ioctl32_t) 521 522 #define VIDIOC_MSM_CPP_DELETE_STREAM_BUFF32\ 523 _IOWR('V', BASE_VIDIOC_PRIVATE + 20, struct msm_camera_v4l2_ioctl32_t) 524 525 struct msm_camera_v4l2_ioctl32_t { 526 uint32_t id; 527 uint32_t len; 528 int32_t trans_code; 529 compat_caddr_t ioctl_ptr; 530 }; 531 #endif 532 533 #endif /* __MSMB_PPROC_H */ 534