1 /* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. 2 * 3 * Redistribution and use in source and binary forms, with or without 4 * modification, are permitted provided that the following conditions are 5 * met: 6 * * Redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer. 8 * * Redistributions in binary form must reproduce the above 9 * copyright notice, this list of conditions and the following 10 * disclaimer in the documentation and/or other materials provided 11 * with the distribution. 12 * * Neither the name of The Linux Foundation nor the names of its 13 * contributors may be used to endorse or promote products derived 14 * from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 */ 29 30 #ifndef __MM_CAMERA_H__ 31 #define __MM_CAMERA_H__ 32 33 #include <cam_semaphore.h> 34 35 #include "mm_camera_interface.h" 36 #include <hardware/camera.h> 37 /********************************************************************************** 38 * Data structure declare 39 ***********************************************************************************/ 40 /* num of callbacks allowed for an event type */ 41 #define MM_CAMERA_EVT_ENTRY_MAX 4 42 /* num of data callbacks allowed in a stream obj */ 43 #define MM_CAMERA_STREAM_BUF_CB_MAX 4 44 /* num of data poll threads allowed in a channel obj */ 45 #define MM_CAMERA_CHANNEL_POLL_THREAD_MAX 1 46 47 #define MM_CAMERA_DEV_NAME_LEN 32 48 #define MM_CAMERA_DEV_OPEN_TRIES 2 49 #define MM_CAMERA_DEV_OPEN_RETRY_SLEEP 20 50 51 #ifndef TRUE 52 #define TRUE 1 53 #endif 54 55 #ifndef FALSE 56 #define FALSE 0 57 #endif 58 59 #define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0])) 60 61 struct mm_channel; 62 struct mm_stream; 63 struct mm_camera_obj; 64 65 typedef enum 66 { 67 MM_CAMERA_CMD_TYPE_DATA_CB, /* dataB CMD */ 68 MM_CAMERA_CMD_TYPE_EVT_CB, /* evtCB CMD */ 69 MM_CAMERA_CMD_TYPE_EXIT, /* EXIT */ 70 MM_CAMERA_CMD_TYPE_REQ_DATA_CB,/* request data */ 71 MM_CAMERA_CMD_TYPE_SUPER_BUF_DATA_CB, /* superbuf dataB CMD */ 72 MM_CAMERA_CMD_TYPE_CONFIG_NOTIFY, /* configure notify mode */ 73 MM_CAMERA_CMD_TYPE_START_ZSL, /* start zsl snapshot for channel */ 74 MM_CAMERA_CMD_TYPE_STOP_ZSL, /* stop zsl snapshot for channel */ 75 MM_CAMERA_CMD_TYPE_FLUSH_QUEUE, /* flush queue */ 76 MM_CAMERA_CMD_TYPE_GENERAL, /* general cmd */ 77 MM_CAMERA_CMD_TYPE_MAX 78 } mm_camera_cmdcb_type_t; 79 80 typedef struct { 81 uint32_t stream_id; 82 uint32_t frame_idx; 83 uint32_t flags; 84 mm_camera_buf_def_t *buf; /* ref to buf */ 85 } mm_camera_buf_info_t; 86 87 typedef struct { 88 uint32_t num_buf_requested; 89 uint32_t num_retro_buf_requested; 90 } mm_camera_req_buf_t; 91 92 typedef enum { 93 MM_CAMERA_GENERIC_CMD_TYPE_AE_BRACKETING, 94 MM_CAMERA_GENERIC_CMD_TYPE_AF_BRACKETING, 95 MM_CAMERA_GENERIC_CMD_TYPE_FLASH_BRACKETING, 96 MM_CAMERA_GENERIC_CMD_TYPE_ZOOM_1X, 97 } mm_camera_generic_cmd_type_t; 98 99 typedef struct { 100 mm_camera_generic_cmd_type_t type; 101 uint32_t payload[32]; 102 } mm_camera_generic_cmd_t; 103 104 typedef struct { 105 mm_camera_cmdcb_type_t cmd_type; 106 union { 107 mm_camera_buf_info_t buf; /* frame buf if dataCB */ 108 mm_camera_event_t evt; /* evt if evtCB */ 109 mm_camera_super_buf_t superbuf; /* superbuf if superbuf dataCB*/ 110 mm_camera_req_buf_t req_buf; /* num of buf requested */ 111 uint32_t frame_idx; /* frame idx boundary for flush superbuf queue*/ 112 mm_camera_super_buf_notify_mode_t notify_mode; /* notification mode */ 113 mm_camera_generic_cmd_t gen_cmd; 114 } u; 115 } mm_camera_cmdcb_t; 116 117 typedef void (*mm_camera_cmd_cb_t)(mm_camera_cmdcb_t * cmd_cb, void* user_data); 118 119 typedef struct { 120 cam_queue_t cmd_queue; /* cmd queue (queuing dataCB, asyncCB, or exitCMD) */ 121 pthread_t cmd_pid; /* cmd thread ID */ 122 cam_semaphore_t cmd_sem; /* semaphore for cmd thread */ 123 mm_camera_cmd_cb_t cb; /* cb for cmd */ 124 void* user_data; /* user_data for cb */ 125 } mm_camera_cmd_thread_t; 126 127 typedef enum { 128 MM_CAMERA_POLL_TYPE_EVT, 129 MM_CAMERA_POLL_TYPE_DATA, 130 MM_CAMERA_POLL_TYPE_MAX 131 } mm_camera_poll_thread_type_t; 132 133 /* function ptr defined for poll notify CB, 134 * registered at poll thread with poll fd */ 135 typedef void (*mm_camera_poll_notify_t)(void *user_data); 136 137 typedef struct { 138 int32_t fd; 139 mm_camera_poll_notify_t notify_cb; 140 uint32_t handler; 141 void* user_data; 142 } mm_camera_poll_entry_t; 143 144 typedef struct { 145 mm_camera_poll_thread_type_t poll_type; 146 /* array to store poll fd and cb info 147 * for MM_CAMERA_POLL_TYPE_EVT, only index 0 is valid; 148 * for MM_CAMERA_POLL_TYPE_DATA, depends on valid stream fd */ 149 mm_camera_poll_entry_t poll_entries[MAX_STREAM_NUM_IN_BUNDLE]; 150 int32_t pfds[2]; 151 pthread_t pid; 152 int32_t state; 153 int timeoutms; 154 uint32_t cmd; 155 struct pollfd poll_fds[MAX_STREAM_NUM_IN_BUNDLE + 1]; 156 uint8_t num_fds; 157 pthread_mutex_t mutex; 158 pthread_cond_t cond_v; 159 int32_t status; 160 //void *my_obj; 161 } mm_camera_poll_thread_t; 162 163 /* mm_stream */ 164 typedef enum { 165 MM_STREAM_STATE_NOTUSED = 0, /* not used */ 166 MM_STREAM_STATE_INITED, /* inited */ 167 MM_STREAM_STATE_ACQUIRED, /* acquired, fd opened */ 168 MM_STREAM_STATE_CFG, /* fmt & dim configured */ 169 MM_STREAM_STATE_BUFFED, /* buf allocated */ 170 MM_STREAM_STATE_REG, /* buf regged, stream off */ 171 MM_STREAM_STATE_ACTIVE, /* active */ 172 MM_STREAM_STATE_MAX 173 } mm_stream_state_type_t; 174 175 typedef enum { 176 MM_STREAM_EVT_ACQUIRE, 177 MM_STREAM_EVT_RELEASE, 178 MM_STREAM_EVT_SET_FMT, 179 MM_STREAM_EVT_GET_BUF, 180 MM_STREAM_EVT_PUT_BUF, 181 MM_STREAM_EVT_REG_BUF, 182 MM_STREAM_EVT_UNREG_BUF, 183 MM_STREAM_EVT_START, 184 MM_STREAM_EVT_STOP, 185 MM_STREAM_EVT_QBUF, 186 MM_STREAM_EVT_SET_PARM, 187 MM_STREAM_EVT_GET_PARM, 188 MM_STREAM_EVT_DO_ACTION, 189 MM_STREAM_EVT_MAX 190 } mm_stream_evt_type_t; 191 192 typedef struct { 193 mm_camera_buf_notify_t cb; 194 void *user_data; 195 /* cb_count = -1: infinite 196 * cb_count > 0: register only for required times */ 197 int8_t cb_count; 198 } mm_stream_data_cb_t; 199 200 typedef struct { 201 /* buf reference count */ 202 uint8_t buf_refcnt; 203 204 /* This flag is to indicate if after allocation, 205 * the corresponding buf needs to qbuf into kernel 206 * (e.g. for preview usecase, display needs to hold two bufs, 207 * so no need to qbuf these two bufs initially) */ 208 uint8_t initial_reg_flag; 209 210 /* indicate if buf is in kernel(1) or client(0) */ 211 uint8_t in_kernel; 212 } mm_stream_buf_status_t; 213 214 typedef struct mm_stream { 215 uint32_t my_hdl; /* local stream id */ 216 uint32_t server_stream_id; /* stream id from server */ 217 int32_t fd; 218 mm_stream_state_type_t state; 219 220 /* stream info*/ 221 cam_stream_info_t *stream_info; 222 223 /* padding info */ 224 cam_padding_info_t padding_info; 225 226 /* offset */ 227 cam_frame_len_offset_t frame_offset; 228 229 mm_camera_cmd_thread_t cmd_thread; 230 231 /* dataCB registered on this stream obj */ 232 pthread_mutex_t cb_lock; /* cb lock to protect buf_cb */ 233 mm_stream_data_cb_t buf_cb[MM_CAMERA_STREAM_BUF_CB_MAX]; 234 235 /* stream buffer management */ 236 pthread_mutex_t buf_lock; 237 uint8_t buf_num; /* num of buffers allocated */ 238 mm_camera_buf_def_t* buf; /* ptr to buf array */ 239 mm_stream_buf_status_t* buf_status; /* ptr to buf status array */ 240 241 /* reference to parent channel_obj */ 242 struct mm_channel* ch_obj; 243 244 uint8_t is_bundled; /* flag if stream is bundled */ 245 246 mm_camera_stream_mem_vtbl_t mem_vtbl; /* mem ops tbl */ 247 248 mm_camera_map_unmap_ops_tbl_t map_ops; 249 250 int8_t queued_buffer_count; 251 } mm_stream_t; 252 253 /* mm_channel */ 254 typedef enum { 255 MM_CHANNEL_STATE_NOTUSED = 0, /* not used */ 256 MM_CHANNEL_STATE_STOPPED, /* stopped */ 257 MM_CHANNEL_STATE_ACTIVE, /* active, at least one stream active */ 258 MM_CHANNEL_STATE_PAUSED, /* paused */ 259 MM_CHANNEL_STATE_MAX 260 } mm_channel_state_type_t; 261 262 typedef enum { 263 MM_CHANNEL_EVT_ADD_STREAM, 264 MM_CHANNEL_EVT_DEL_STREAM, 265 MM_CHANNEL_EVT_CONFIG_STREAM, 266 MM_CHANNEL_EVT_GET_BUNDLE_INFO, 267 MM_CHANNEL_EVT_START, 268 MM_CHANNEL_EVT_STOP, 269 MM_CHANNEL_EVT_PAUSE, 270 MM_CHANNEL_EVT_RESUME, 271 MM_CHANNEL_EVT_REQUEST_SUPER_BUF, 272 MM_CHANNEL_EVT_CANCEL_REQUEST_SUPER_BUF, 273 MM_CHANNEL_EVT_FLUSH_SUPER_BUF_QUEUE, 274 MM_CHANNEL_EVT_CONFIG_NOTIFY_MODE, 275 MM_CHANNEL_EVT_START_ZSL_SNAPSHOT, 276 MM_CHANNEL_EVT_STOP_ZSL_SNAPSHOT, 277 MM_CHANNEL_EVT_MAP_STREAM_BUF, 278 MM_CHANNEL_EVT_UNMAP_STREAM_BUF, 279 MM_CHANNEL_EVT_SET_STREAM_PARM, 280 MM_CHANNEL_EVT_GET_STREAM_PARM, 281 MM_CHANNEL_EVT_DO_STREAM_ACTION, 282 MM_CHANNEL_EVT_DELETE, 283 MM_CHANNEL_EVT_AF_BRACKETING, 284 MM_CHANNEL_EVT_AE_BRACKETING, 285 MM_CHANNEL_EVT_FLASH_BRACKETING, 286 MM_CHANNEL_EVT_ZOOM_1X, 287 } mm_channel_evt_type_t; 288 289 typedef struct { 290 uint32_t stream_id; 291 mm_camera_stream_config_t *config; 292 } mm_evt_paylod_config_stream_t; 293 294 typedef struct { 295 uint32_t stream_id; 296 cam_stream_parm_buffer_t *parms; 297 } mm_evt_paylod_set_get_stream_parms_t; 298 299 typedef struct { 300 uint32_t stream_id; 301 void *actions; 302 } mm_evt_paylod_do_stream_action_t; 303 304 typedef struct { 305 uint32_t stream_id; 306 uint8_t buf_type; 307 uint32_t buf_idx; 308 int32_t plane_idx; 309 int fd; 310 uint32_t size; 311 } mm_evt_paylod_map_stream_buf_t; 312 313 typedef struct { 314 uint32_t stream_id; 315 uint8_t buf_type; 316 uint32_t buf_idx; 317 int32_t plane_idx; 318 } mm_evt_paylod_unmap_stream_buf_t; 319 320 typedef struct { 321 uint8_t num_of_bufs; 322 mm_camera_buf_info_t super_buf[MAX_STREAM_NUM_IN_BUNDLE]; 323 uint8_t matched; 324 uint32_t frame_idx; 325 } mm_channel_queue_node_t; 326 327 typedef struct { 328 cam_queue_t que; 329 uint8_t num_streams; 330 /* container for bundled stream handlers */ 331 uint32_t bundled_streams[MAX_STREAM_NUM_IN_BUNDLE]; 332 mm_camera_channel_attr_t attr; 333 uint32_t expected_frame_id; 334 uint32_t match_cnt; 335 uint32_t expected_frame_id_without_led; 336 uint32_t led_on_start_frame_id; 337 uint32_t led_off_start_frame_id; 338 uint32_t led_on_num_frames; 339 uint32_t once; 340 uint32_t frame_skip_count; 341 } mm_channel_queue_t; 342 343 typedef struct { 344 uint8_t is_active; /* flag to indicate if bundle is valid */ 345 /* queue to store bundled super buffers */ 346 mm_channel_queue_t superbuf_queue; 347 mm_camera_buf_notify_t super_buf_notify_cb; 348 void *user_data; 349 } mm_channel_bundle_t; 350 351 typedef struct mm_channel { 352 uint32_t my_hdl; 353 mm_channel_state_type_t state; 354 pthread_mutex_t ch_lock; /* channel lock */ 355 356 /* stream bundle info in the channel */ 357 mm_channel_bundle_t bundle; 358 359 /* num of pending suferbuffers */ 360 uint32_t pending_cnt; 361 uint32_t pending_retro_cnt; 362 uint32_t bWaitForPrepSnapshotDone; 363 uint32_t unLockAEC; 364 /* num of pending suferbuffers */ 365 uint8_t stopZslSnapshot; 366 367 /* cmd thread for superbuffer dataCB and async stop*/ 368 mm_camera_cmd_thread_t cmd_thread; 369 370 /* cb thread for sending data cb */ 371 mm_camera_cmd_thread_t cb_thread; 372 373 /* data poll thread 374 * currently one data poll thread per channel 375 * could extended to support one data poll thread per stream in the channel */ 376 mm_camera_poll_thread_t poll_thread[MM_CAMERA_CHANNEL_POLL_THREAD_MAX]; 377 378 /* container for all streams in channel */ 379 mm_stream_t streams[MAX_STREAM_NUM_IN_BUNDLE]; 380 381 /* reference to parent cam_obj */ 382 struct mm_camera_obj* cam_obj; 383 384 /* manual zsl snapshot control */ 385 uint8_t manualZSLSnapshot; 386 387 /* control for zsl led */ 388 uint8_t startZSlSnapshotCalled; 389 uint8_t needLEDFlash; 390 uint8_t need3ABracketing; 391 uint8_t isFlashBracketingEnabled; 392 uint8_t isZoom1xFrameRequested; 393 uint32_t burstSnapNum; 394 } mm_channel_t; 395 396 /* struct to store information about pp cookie*/ 397 typedef struct { 398 uint32_t cam_hdl; 399 uint32_t ch_hdl; 400 uint32_t stream_hdl; 401 mm_channel_queue_node_t* super_buf; 402 } mm_channel_pp_info_t; 403 404 /* mm_camera */ 405 typedef struct { 406 mm_camera_event_notify_t evt_cb; 407 void *user_data; 408 } mm_camera_evt_entry_t; 409 410 typedef struct { 411 mm_camera_evt_entry_t evt[MM_CAMERA_EVT_ENTRY_MAX]; 412 /* reg_count <=0: infinite 413 * reg_count > 0: register only for required times */ 414 int reg_count; 415 } mm_camera_evt_obj_t; 416 417 typedef struct mm_camera_obj { 418 uint32_t my_hdl; 419 int ref_count; 420 int32_t ctrl_fd; 421 int32_t ds_fd; /* domain socket fd */ 422 pthread_mutex_t cam_lock; 423 pthread_mutex_t cb_lock; /* lock for evt cb */ 424 mm_channel_t ch[MM_CAMERA_CHANNEL_MAX]; 425 mm_camera_evt_obj_t evt; 426 mm_camera_poll_thread_t evt_poll_thread; /* evt poll thread */ 427 mm_camera_cmd_thread_t evt_thread; /* thread for evt CB */ 428 mm_camera_vtbl_t vtbl; 429 430 pthread_mutex_t evt_lock; 431 pthread_cond_t evt_cond; 432 mm_camera_event_t evt_rcvd; 433 434 pthread_mutex_t msg_lock; /* lock for sending msg through socket */ 435 } mm_camera_obj_t; 436 437 typedef struct { 438 int8_t num_cam; 439 char video_dev_name[MM_CAMERA_MAX_NUM_SENSORS][MM_CAMERA_DEV_NAME_LEN]; 440 mm_camera_obj_t *cam_obj[MM_CAMERA_MAX_NUM_SENSORS]; 441 struct camera_info info[MM_CAMERA_MAX_NUM_SENSORS]; 442 } mm_camera_ctrl_t; 443 444 typedef enum { 445 mm_camera_async_call, 446 mm_camera_sync_call 447 } mm_camera_call_type_t; 448 449 /********************************************************************************** 450 * external function declare 451 ***********************************************************************************/ 452 /* utility functions */ 453 /* set int32_t value */ 454 extern int32_t mm_camera_util_s_ctrl(int32_t fd, 455 uint32_t id, 456 int32_t *value); 457 458 /* get int32_t value */ 459 extern int32_t mm_camera_util_g_ctrl(int32_t fd, 460 uint32_t id, 461 int32_t *value); 462 463 /* send msg throught domain socket for fd mapping */ 464 extern int32_t mm_camera_util_sendmsg(mm_camera_obj_t *my_obj, 465 void *msg, 466 uint32_t buf_size, 467 int sendfd); 468 /* Check if hardware target is A family */ 469 uint8_t mm_camera_util_chip_is_a_family(void); 470 471 /* mm-camera */ 472 extern int32_t mm_camera_open(mm_camera_obj_t *my_obj); 473 extern int32_t mm_camera_close(mm_camera_obj_t *my_obj); 474 extern int32_t mm_camera_register_event_notify(mm_camera_obj_t *my_obj, 475 mm_camera_event_notify_t evt_cb, 476 void * user_data); 477 extern int32_t mm_camera_qbuf(mm_camera_obj_t *my_obj, 478 uint32_t ch_id, 479 mm_camera_buf_def_t *buf); 480 extern int32_t mm_camera_query_capability(mm_camera_obj_t *my_obj); 481 extern int32_t mm_camera_set_parms(mm_camera_obj_t *my_obj, 482 parm_buffer_t *parms); 483 extern int32_t mm_camera_get_parms(mm_camera_obj_t *my_obj, 484 parm_buffer_t *parms); 485 extern int32_t mm_camera_map_buf(mm_camera_obj_t *my_obj, 486 uint8_t buf_type, 487 int fd, 488 uint32_t size); 489 extern int32_t mm_camera_unmap_buf(mm_camera_obj_t *my_obj, 490 uint8_t buf_type); 491 extern int32_t mm_camera_do_auto_focus(mm_camera_obj_t *my_obj); 492 extern int32_t mm_camera_cancel_auto_focus(mm_camera_obj_t *my_obj); 493 extern int32_t mm_camera_prepare_snapshot(mm_camera_obj_t *my_obj, 494 int32_t do_af_flag); 495 extern int32_t mm_camera_start_zsl_snapshot(mm_camera_obj_t *my_obj); 496 extern int32_t mm_camera_stop_zsl_snapshot(mm_camera_obj_t *my_obj); 497 extern int32_t mm_camera_start_zsl_snapshot_ch(mm_camera_obj_t *my_obj, 498 uint32_t ch_id); 499 extern int32_t mm_camera_stop_zsl_snapshot_ch(mm_camera_obj_t *my_obj, 500 uint32_t ch_id); 501 extern uint32_t mm_camera_add_channel(mm_camera_obj_t *my_obj, 502 mm_camera_channel_attr_t *attr, 503 mm_camera_buf_notify_t channel_cb, 504 void *userdata); 505 extern int32_t mm_camera_del_channel(mm_camera_obj_t *my_obj, 506 uint32_t ch_id); 507 extern int32_t mm_camera_get_bundle_info(mm_camera_obj_t *my_obj, 508 uint32_t ch_id, 509 cam_bundle_config_t *bundle_info); 510 extern uint32_t mm_camera_add_stream(mm_camera_obj_t *my_obj, 511 uint32_t ch_id); 512 extern int32_t mm_camera_del_stream(mm_camera_obj_t *my_obj, 513 uint32_t ch_id, 514 uint32_t stream_id); 515 extern int32_t mm_camera_config_stream(mm_camera_obj_t *my_obj, 516 uint32_t ch_id, 517 uint32_t stream_id, 518 mm_camera_stream_config_t *config); 519 extern int32_t mm_camera_start_channel(mm_camera_obj_t *my_obj, 520 uint32_t ch_id); 521 extern int32_t mm_camera_stop_channel(mm_camera_obj_t *my_obj, 522 uint32_t ch_id); 523 extern int32_t mm_camera_request_super_buf(mm_camera_obj_t *my_obj, 524 uint32_t ch_id, 525 uint32_t num_buf_requested, 526 uint32_t num_retro_buf_requested); 527 extern int32_t mm_camera_cancel_super_buf_request(mm_camera_obj_t *my_obj, 528 uint32_t ch_id); 529 extern int32_t mm_camera_flush_super_buf_queue(mm_camera_obj_t *my_obj, 530 uint32_t ch_id, 531 uint32_t frame_idx); 532 extern int32_t mm_camera_config_channel_notify(mm_camera_obj_t *my_obj, 533 uint32_t ch_id, 534 mm_camera_super_buf_notify_mode_t notify_mode); 535 extern int32_t mm_camera_set_stream_parms(mm_camera_obj_t *my_obj, 536 uint32_t ch_id, 537 uint32_t s_id, 538 cam_stream_parm_buffer_t *parms); 539 extern int32_t mm_camera_get_stream_parms(mm_camera_obj_t *my_obj, 540 uint32_t ch_id, 541 uint32_t s_id, 542 cam_stream_parm_buffer_t *parms); 543 extern int32_t mm_camera_register_event_notify_internal(mm_camera_obj_t *my_obj, 544 mm_camera_event_notify_t evt_cb, 545 void * user_data); 546 extern int32_t mm_camera_map_stream_buf(mm_camera_obj_t *my_obj, 547 uint32_t ch_id, 548 uint32_t stream_id, 549 uint8_t buf_type, 550 uint32_t buf_idx, 551 int32_t plane_idx, 552 int fd, 553 uint32_t size); 554 extern int32_t mm_camera_unmap_stream_buf(mm_camera_obj_t *my_obj, 555 uint32_t ch_id, 556 uint32_t stream_id, 557 uint8_t buf_type, 558 uint32_t buf_idx, 559 int32_t plane_idx); 560 extern int32_t mm_camera_do_stream_action(mm_camera_obj_t *my_obj, 561 uint32_t ch_id, 562 uint32_t stream_id, 563 void *actions); 564 565 /* mm_channel */ 566 extern int32_t mm_channel_fsm_fn(mm_channel_t *my_obj, 567 mm_channel_evt_type_t evt, 568 void * in_val, 569 void * out_val); 570 extern int32_t mm_channel_init(mm_channel_t *my_obj, 571 mm_camera_channel_attr_t *attr, 572 mm_camera_buf_notify_t channel_cb, 573 void *userdata); 574 /* qbuf is a special case that not going through state machine. 575 * This is to avoid deadlock when trying to aquire ch_lock, 576 * from the context of dataCB, but async stop is holding ch_lock */ 577 extern int32_t mm_channel_qbuf(mm_channel_t *my_obj, 578 mm_camera_buf_def_t *buf); 579 580 /* mm_stream */ 581 extern int32_t mm_stream_fsm_fn(mm_stream_t *my_obj, 582 mm_stream_evt_type_t evt, 583 void * in_val, 584 void * out_val); 585 /* Allow other stream to register dataCB at certain stream. 586 * This is for use case of video sized live snapshot, 587 * because snapshot stream need register one time CB at video stream. 588 * ext_image_mode and sensor_idx are used to identify the destinate stream 589 * to be register with dataCB. */ 590 extern int32_t mm_stream_reg_buf_cb(mm_stream_t *my_obj, 591 mm_stream_data_cb_t *val); 592 extern int32_t mm_stream_map_buf(mm_stream_t *my_obj, 593 uint8_t buf_type, 594 uint32_t frame_idx, 595 int32_t plane_idx, 596 int fd, 597 uint32_t size); 598 extern int32_t mm_stream_unmap_buf(mm_stream_t *my_obj, 599 uint8_t buf_type, 600 uint32_t frame_idx, 601 int32_t plane_idx); 602 603 604 /* utiltity fucntion declared in mm-camera-inteface2.c 605 * and need be used by mm-camera and below*/ 606 uint32_t mm_camera_util_generate_handler(uint8_t index); 607 const char * mm_camera_util_get_dev_name(uint32_t cam_handler); 608 uint8_t mm_camera_util_get_index_by_handler(uint32_t handler); 609 610 /* poll/cmd thread functions */ 611 extern int32_t mm_camera_poll_thread_launch( 612 mm_camera_poll_thread_t * poll_cb, 613 mm_camera_poll_thread_type_t poll_type); 614 extern int32_t mm_camera_poll_thread_release(mm_camera_poll_thread_t *poll_cb); 615 extern int32_t mm_camera_poll_thread_add_poll_fd( 616 mm_camera_poll_thread_t * poll_cb, 617 uint32_t handler, 618 int32_t fd, 619 mm_camera_poll_notify_t nofity_cb, 620 void *userdata, 621 mm_camera_call_type_t); 622 extern int32_t mm_camera_poll_thread_del_poll_fd( 623 mm_camera_poll_thread_t * poll_cb, 624 uint32_t handler, 625 mm_camera_call_type_t); 626 extern int32_t mm_camera_poll_thread_commit_updates( 627 mm_camera_poll_thread_t * poll_cb); 628 extern int32_t mm_camera_cmd_thread_launch( 629 mm_camera_cmd_thread_t * cmd_thread, 630 mm_camera_cmd_cb_t cb, 631 void* user_data); 632 extern int32_t mm_camera_cmd_thread_name(const char* name); 633 extern int32_t mm_camera_cmd_thread_release(mm_camera_cmd_thread_t * cmd_thread); 634 635 extern int32_t mm_camera_channel_advanced_capture(mm_camera_obj_t *my_obj, 636 mm_camera_advanced_capture_t advanced_capturetype, 637 uint32_t ch_id, 638 int32_t start_flag); 639 #endif /* __MM_CAMERA_H__ */ 640