Home | History | Annotate | Download | only in inc
      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 
     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 20
     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 struct mm_channel;
     60 struct mm_stream;
     61 struct mm_camera_obj;
     62 
     63 typedef enum
     64 {
     65     MM_CAMERA_CMD_TYPE_DATA_CB,    /* dataB CMD */
     66     MM_CAMERA_CMD_TYPE_EVT_CB,     /* evtCB CMD */
     67     MM_CAMERA_CMD_TYPE_EXIT,       /* EXIT */
     68     MM_CAMERA_CMD_TYPE_REQ_DATA_CB,/* request data */
     69     MM_CAMERA_CMD_TYPE_SUPER_BUF_DATA_CB,    /* superbuf dataB CMD */
     70     MM_CAMERA_CMD_TYPE_CONFIG_NOTIFY, /* configure notify mode */
     71     MM_CAMERA_CMD_TYPE_FLUSH_QUEUE, /* flush queue */
     72     MM_CAMERA_CMD_TYPE_MAX
     73 } mm_camera_cmdcb_type_t;
     74 
     75 typedef struct {
     76     uint32_t stream_id;
     77     uint32_t frame_idx;
     78     mm_camera_buf_def_t *buf; /* ref to buf */
     79 } mm_camera_buf_info_t;
     80 
     81 typedef struct {
     82     uint32_t num_buf_requested;
     83 } mm_camera_req_buf_t;
     84 
     85 typedef struct {
     86     mm_camera_cmdcb_type_t cmd_type;
     87     union {
     88         mm_camera_buf_info_t buf;    /* frame buf if dataCB */
     89         mm_camera_event_t evt;       /* evt if evtCB */
     90         mm_camera_super_buf_t superbuf; /* superbuf if superbuf dataCB*/
     91         mm_camera_req_buf_t req_buf; /* num of buf requested */
     92         uint32_t frame_idx; /* frame idx boundary for flush superbuf queue*/
     93         mm_camera_super_buf_notify_mode_t notify_mode; /* notification mode */
     94     } u;
     95 } mm_camera_cmdcb_t;
     96 
     97 typedef void (*mm_camera_cmd_cb_t)(mm_camera_cmdcb_t * cmd_cb, void* user_data);
     98 
     99 typedef struct {
    100     cam_queue_t cmd_queue; /* cmd queue (queuing dataCB, asyncCB, or exitCMD) */
    101     pthread_t cmd_pid;           /* cmd thread ID */
    102     cam_semaphore_t cmd_sem;     /* semaphore for cmd thread */
    103     mm_camera_cmd_cb_t cb;       /* cb for cmd */
    104     void* user_data;             /* user_data for cb */
    105 } mm_camera_cmd_thread_t;
    106 
    107 typedef enum {
    108     MM_CAMERA_POLL_TYPE_EVT,
    109     MM_CAMERA_POLL_TYPE_DATA,
    110     MM_CAMERA_POLL_TYPE_MAX
    111 } mm_camera_poll_thread_type_t;
    112 
    113 /* function ptr defined for poll notify CB,
    114  * registered at poll thread with poll fd */
    115 typedef void (*mm_camera_poll_notify_t)(void *user_data);
    116 
    117 typedef struct {
    118     int32_t fd;
    119     mm_camera_poll_notify_t notify_cb;
    120     uint32_t handler;
    121     void* user_data;
    122 } mm_camera_poll_entry_t;
    123 
    124 typedef struct {
    125     mm_camera_poll_thread_type_t poll_type;
    126     /* array to store poll fd and cb info
    127      * for MM_CAMERA_POLL_TYPE_EVT, only index 0 is valid;
    128      * for MM_CAMERA_POLL_TYPE_DATA, depends on valid stream fd */
    129     mm_camera_poll_entry_t poll_entries[MAX_STREAM_NUM_IN_BUNDLE];
    130     int32_t pfds[2];
    131     pthread_t pid;
    132     int32_t state;
    133     int timeoutms;
    134     uint32_t cmd;
    135     struct pollfd poll_fds[MAX_STREAM_NUM_IN_BUNDLE + 1];
    136     uint8_t num_fds;
    137     pthread_mutex_t mutex;
    138     pthread_cond_t cond_v;
    139     int32_t status;
    140     //void *my_obj;
    141 } mm_camera_poll_thread_t;
    142 
    143 /* mm_stream */
    144 typedef enum {
    145     MM_STREAM_STATE_NOTUSED = 0,      /* not used */
    146     MM_STREAM_STATE_INITED,           /* inited  */
    147     MM_STREAM_STATE_ACQUIRED,         /* acquired, fd opened  */
    148     MM_STREAM_STATE_CFG,              /* fmt & dim configured */
    149     MM_STREAM_STATE_BUFFED,           /* buf allocated */
    150     MM_STREAM_STATE_REG,              /* buf regged, stream off */
    151     MM_STREAM_STATE_ACTIVE,           /* active */
    152     MM_STREAM_STATE_MAX
    153 } mm_stream_state_type_t;
    154 
    155 typedef enum {
    156     MM_STREAM_EVT_ACQUIRE,
    157     MM_STREAM_EVT_RELEASE,
    158     MM_STREAM_EVT_SET_FMT,
    159     MM_STREAM_EVT_GET_BUF,
    160     MM_STREAM_EVT_PUT_BUF,
    161     MM_STREAM_EVT_REG_BUF,
    162     MM_STREAM_EVT_UNREG_BUF,
    163     MM_STREAM_EVT_START,
    164     MM_STREAM_EVT_STOP,
    165     MM_STREAM_EVT_QBUF,
    166     MM_STREAM_EVT_SET_PARM,
    167     MM_STREAM_EVT_GET_PARM,
    168     MM_STREAM_EVT_DO_ACTION,
    169     MM_STREAM_EVT_MAX
    170 } mm_stream_evt_type_t;
    171 
    172 typedef struct {
    173     mm_camera_buf_notify_t cb;
    174     void *user_data;
    175     /* cb_count = -1: infinite
    176      * cb_count > 0: register only for required times */
    177     int8_t cb_count;
    178 } mm_stream_data_cb_t;
    179 
    180 typedef struct {
    181     /* buf reference count */
    182     uint8_t buf_refcnt;
    183 
    184     /* This flag is to indicate if after allocation,
    185      * the corresponding buf needs to qbuf into kernel
    186      * (e.g. for preview usecase, display needs to hold two bufs,
    187      * so no need to qbuf these two bufs initially) */
    188     uint8_t initial_reg_flag;
    189 
    190     /* indicate if buf is in kernel(1) or client(0) */
    191     uint8_t in_kernel;
    192 } mm_stream_buf_status_t;
    193 
    194 typedef struct mm_stream {
    195     uint32_t my_hdl; /* local stream id */
    196     uint32_t server_stream_id; /* stream id from server */
    197     int32_t fd;
    198     mm_stream_state_type_t state;
    199 
    200     /* stream info*/
    201     cam_stream_info_t *stream_info;
    202 
    203     /* padding info */
    204     cam_padding_info_t padding_info;
    205 
    206     /* offset */
    207     cam_frame_len_offset_t frame_offset;
    208 
    209     mm_camera_cmd_thread_t cmd_thread;
    210 
    211     /* dataCB registered on this stream obj */
    212     pthread_mutex_t cb_lock; /* cb lock to protect buf_cb */
    213     mm_stream_data_cb_t buf_cb[MM_CAMERA_STREAM_BUF_CB_MAX];
    214 
    215     /* stream buffer management */
    216     pthread_mutex_t buf_lock;
    217     uint8_t buf_num; /* num of buffers allocated */
    218     mm_camera_buf_def_t* buf; /* ptr to buf array */
    219     mm_stream_buf_status_t* buf_status; /* ptr to buf status array */
    220 
    221     /* reference to parent channel_obj */
    222     struct mm_channel* ch_obj;
    223 
    224     uint8_t is_bundled; /* flag if stream is bundled */
    225 
    226     mm_camera_stream_mem_vtbl_t mem_vtbl; /* mem ops tbl */
    227 
    228     int8_t queued_buffer_count;
    229 } mm_stream_t;
    230 
    231 /* mm_channel */
    232 typedef enum {
    233     MM_CHANNEL_STATE_NOTUSED = 0,   /* not used */
    234     MM_CHANNEL_STATE_STOPPED,       /* stopped */
    235     MM_CHANNEL_STATE_ACTIVE,        /* active, at least one stream active */
    236     MM_CHANNEL_STATE_PAUSED,        /* paused */
    237     MM_CHANNEL_STATE_MAX
    238 } mm_channel_state_type_t;
    239 
    240 typedef enum {
    241     MM_CHANNEL_EVT_ADD_STREAM,
    242     MM_CHANNEL_EVT_DEL_STREAM,
    243     MM_CHANNEL_EVT_CONFIG_STREAM,
    244     MM_CHANNEL_EVT_GET_BUNDLE_INFO,
    245     MM_CHANNEL_EVT_START,
    246     MM_CHANNEL_EVT_STOP,
    247     MM_CHANNEL_EVT_PAUSE,
    248     MM_CHANNEL_EVT_RESUME,
    249     MM_CHANNEL_EVT_REQUEST_SUPER_BUF,
    250     MM_CHANNEL_EVT_CANCEL_REQUEST_SUPER_BUF,
    251     MM_CHANNEL_EVT_FLUSH_SUPER_BUF_QUEUE,
    252     MM_CHANNEL_EVT_CONFIG_NOTIFY_MODE,
    253     MM_CHANNEL_EVT_MAP_STREAM_BUF,
    254     MM_CHANNEL_EVT_UNMAP_STREAM_BUF,
    255     MM_CHANNEL_EVT_SET_STREAM_PARM,
    256     MM_CHANNEL_EVT_GET_STREAM_PARM,
    257     MM_CHANNEL_EVT_DO_STREAM_ACTION,
    258     MM_CHANNEL_EVT_DELETE,
    259 } mm_channel_evt_type_t;
    260 
    261 typedef struct {
    262     uint32_t stream_id;
    263     mm_camera_stream_config_t *config;
    264 } mm_evt_paylod_config_stream_t;
    265 
    266 typedef struct {
    267     uint32_t stream_id;
    268     cam_stream_parm_buffer_t *parms;
    269 } mm_evt_paylod_set_get_stream_parms_t;
    270 
    271 typedef struct {
    272     uint32_t stream_id;
    273     void *actions;
    274 } mm_evt_paylod_do_stream_action_t;
    275 
    276 typedef struct {
    277     uint32_t stream_id;
    278     uint8_t buf_type;
    279     uint32_t buf_idx;
    280     int32_t plane_idx;
    281     int fd;
    282     uint32_t size;
    283 } mm_evt_paylod_map_stream_buf_t;
    284 
    285 typedef struct {
    286     uint32_t stream_id;
    287     uint8_t buf_type;
    288     uint32_t buf_idx;
    289     int32_t plane_idx;
    290 } mm_evt_paylod_unmap_stream_buf_t;
    291 
    292 typedef struct {
    293     uint8_t num_of_bufs;
    294     mm_camera_buf_info_t super_buf[MAX_STREAM_NUM_IN_BUNDLE];
    295     uint8_t matched;
    296     uint32_t frame_idx;
    297 } mm_channel_queue_node_t;
    298 
    299 typedef struct {
    300     cam_queue_t que;
    301     uint8_t num_streams;
    302     /* container for bundled stream handlers */
    303     uint32_t bundled_streams[MAX_STREAM_NUM_IN_BUNDLE];
    304     mm_camera_channel_attr_t attr;
    305     uint32_t expected_frame_id;
    306     uint32_t match_cnt;
    307 } mm_channel_queue_t;
    308 
    309 typedef struct {
    310     uint8_t is_active; /* flag to indicate if bundle is valid */
    311     /* queue to store bundled super buffers */
    312     mm_channel_queue_t superbuf_queue;
    313     mm_camera_buf_notify_t super_buf_notify_cb;
    314     void *user_data;
    315 } mm_channel_bundle_t;
    316 
    317 typedef struct mm_channel {
    318     uint32_t my_hdl;
    319     mm_channel_state_type_t state;
    320     pthread_mutex_t ch_lock; /* channel lock */
    321 
    322     /* stream bundle info in the channel */
    323     mm_channel_bundle_t bundle;
    324 
    325     /* num of pending suferbuffers */
    326     uint32_t pending_cnt;
    327 
    328     /* cmd thread for superbuffer dataCB and async stop*/
    329     mm_camera_cmd_thread_t cmd_thread;
    330 
    331     /* cb thread for sending data cb */
    332     mm_camera_cmd_thread_t cb_thread;
    333 
    334     /* data poll thread
    335     * currently one data poll thread per channel
    336     * could extended to support one data poll thread per stream in the channel */
    337     mm_camera_poll_thread_t poll_thread[MM_CAMERA_CHANNEL_POLL_THREAD_MAX];
    338 
    339     /* container for all streams in channel */
    340     mm_stream_t streams[MAX_STREAM_NUM_IN_BUNDLE];
    341 
    342     /* reference to parent cam_obj */
    343     struct mm_camera_obj* cam_obj;
    344 } mm_channel_t;
    345 
    346 /* struct to store information about pp cookie*/
    347 typedef struct {
    348     uint32_t cam_hdl;
    349     uint32_t ch_hdl;
    350     uint32_t stream_hdl;
    351     mm_channel_queue_node_t* super_buf;
    352 } mm_channel_pp_info_t;
    353 
    354 /* mm_camera */
    355 typedef struct {
    356     mm_camera_event_notify_t evt_cb;
    357     void *user_data;
    358 } mm_camera_evt_entry_t;
    359 
    360 typedef struct {
    361     mm_camera_evt_entry_t evt[MM_CAMERA_EVT_ENTRY_MAX];
    362     /* reg_count <=0: infinite
    363      * reg_count > 0: register only for required times */
    364     int reg_count;
    365 } mm_camera_evt_obj_t;
    366 
    367 typedef struct mm_camera_obj {
    368     uint32_t my_hdl;
    369     int ref_count;
    370     int32_t ctrl_fd;
    371     int32_t ds_fd; /* domain socket fd */
    372     pthread_mutex_t cam_lock;
    373     pthread_mutex_t cb_lock; /* lock for evt cb */
    374     mm_channel_t ch[MM_CAMERA_CHANNEL_MAX];
    375     mm_camera_evt_obj_t evt;
    376     mm_camera_poll_thread_t evt_poll_thread; /* evt poll thread */
    377     mm_camera_cmd_thread_t evt_thread;       /* thread for evt CB */
    378     mm_camera_vtbl_t vtbl;
    379 
    380     pthread_mutex_t evt_lock;
    381     pthread_cond_t evt_cond;
    382     mm_camera_event_t evt_rcvd;
    383 
    384     pthread_mutex_t msg_lock; /* lock for sending msg through socket */
    385 } mm_camera_obj_t;
    386 
    387 typedef struct {
    388     int8_t num_cam;
    389     char video_dev_name[MM_CAMERA_MAX_NUM_SENSORS][MM_CAMERA_DEV_NAME_LEN];
    390     mm_camera_obj_t *cam_obj[MM_CAMERA_MAX_NUM_SENSORS];
    391 } mm_camera_ctrl_t;
    392 
    393 typedef enum {
    394     mm_camera_async_call,
    395     mm_camera_sync_call
    396 } mm_camera_call_type_t;
    397 
    398 /**********************************************************************************
    399 * external function declare
    400 ***********************************************************************************/
    401 /* utility functions */
    402 /* set int32_t value */
    403 extern int32_t mm_camera_util_s_ctrl(int32_t fd,
    404                                      uint32_t id,
    405                                      int32_t *value);
    406 
    407 /* get int32_t value */
    408 extern int32_t mm_camera_util_g_ctrl(int32_t fd,
    409                                      uint32_t id,
    410                                      int32_t *value);
    411 
    412 /* send msg throught domain socket for fd mapping */
    413 extern int32_t mm_camera_util_sendmsg(mm_camera_obj_t *my_obj,
    414                                       void *msg,
    415                                       uint32_t buf_size,
    416                                       int sendfd);
    417 /* Check if hardware target is A family */
    418 uint8_t mm_camera_util_chip_is_a_family(void);
    419 
    420 /* mm-camera */
    421 extern int32_t mm_camera_open(mm_camera_obj_t *my_obj);
    422 extern int32_t mm_camera_close(mm_camera_obj_t *my_obj);
    423 extern int32_t mm_camera_register_event_notify(mm_camera_obj_t *my_obj,
    424                                                mm_camera_event_notify_t evt_cb,
    425                                                void * user_data);
    426 extern int32_t mm_camera_qbuf(mm_camera_obj_t *my_obj,
    427                               uint32_t ch_id,
    428                               mm_camera_buf_def_t *buf);
    429 extern int32_t mm_camera_query_capability(mm_camera_obj_t *my_obj);
    430 extern int32_t mm_camera_set_parms(mm_camera_obj_t *my_obj,
    431                                    parm_buffer_t *parms);
    432 extern int32_t mm_camera_get_parms(mm_camera_obj_t *my_obj,
    433                                    parm_buffer_t *parms);
    434 extern int32_t mm_camera_map_buf(mm_camera_obj_t *my_obj,
    435                                  uint8_t buf_type,
    436                                  int fd,
    437                                  uint32_t size);
    438 extern int32_t mm_camera_unmap_buf(mm_camera_obj_t *my_obj,
    439                                    uint8_t buf_type);
    440 extern int32_t mm_camera_do_auto_focus(mm_camera_obj_t *my_obj);
    441 extern int32_t mm_camera_cancel_auto_focus(mm_camera_obj_t *my_obj);
    442 extern int32_t mm_camera_prepare_snapshot(mm_camera_obj_t *my_obj,
    443                                           int32_t do_af_flag);
    444 extern int32_t mm_camera_start_zsl_snapshot(mm_camera_obj_t *my_obj);
    445 extern int32_t mm_camera_stop_zsl_snapshot(mm_camera_obj_t *my_obj);
    446 extern uint32_t mm_camera_add_channel(mm_camera_obj_t *my_obj,
    447                                       mm_camera_channel_attr_t *attr,
    448                                       mm_camera_buf_notify_t channel_cb,
    449                                       void *userdata);
    450 extern int32_t mm_camera_del_channel(mm_camera_obj_t *my_obj,
    451                                      uint32_t ch_id);
    452 extern int32_t mm_camera_get_bundle_info(mm_camera_obj_t *my_obj,
    453                                          uint32_t ch_id,
    454                                          cam_bundle_config_t *bundle_info);
    455 extern uint32_t mm_camera_add_stream(mm_camera_obj_t *my_obj,
    456                                      uint32_t ch_id);
    457 extern int32_t mm_camera_del_stream(mm_camera_obj_t *my_obj,
    458                                     uint32_t ch_id,
    459                                     uint32_t stream_id);
    460 extern int32_t mm_camera_config_stream(mm_camera_obj_t *my_obj,
    461                                        uint32_t ch_id,
    462                                        uint32_t stream_id,
    463                                        mm_camera_stream_config_t *config);
    464 extern int32_t mm_camera_start_channel(mm_camera_obj_t *my_obj,
    465                                        uint32_t ch_id);
    466 extern int32_t mm_camera_stop_channel(mm_camera_obj_t *my_obj,
    467                                       uint32_t ch_id);
    468 extern int32_t mm_camera_request_super_buf(mm_camera_obj_t *my_obj,
    469                                            uint32_t ch_id,
    470                                            uint32_t num_buf_requested);
    471 extern int32_t mm_camera_cancel_super_buf_request(mm_camera_obj_t *my_obj,
    472                                                   uint32_t ch_id);
    473 extern int32_t mm_camera_flush_super_buf_queue(mm_camera_obj_t *my_obj,
    474                                                uint32_t ch_id,
    475                                                uint32_t frame_idx);
    476 extern int32_t mm_camera_config_channel_notify(mm_camera_obj_t *my_obj,
    477                                                uint32_t ch_id,
    478                                                mm_camera_super_buf_notify_mode_t notify_mode);
    479 extern int32_t mm_camera_set_stream_parms(mm_camera_obj_t *my_obj,
    480                                           uint32_t ch_id,
    481                                           uint32_t s_id,
    482                                           cam_stream_parm_buffer_t *parms);
    483 extern int32_t mm_camera_get_stream_parms(mm_camera_obj_t *my_obj,
    484                                           uint32_t ch_id,
    485                                           uint32_t s_id,
    486                                           cam_stream_parm_buffer_t *parms);
    487 extern int32_t mm_camera_register_event_notify_internal(mm_camera_obj_t *my_obj,
    488                                                         mm_camera_event_notify_t evt_cb,
    489                                                         void * user_data);
    490 extern int32_t mm_camera_map_stream_buf(mm_camera_obj_t *my_obj,
    491                                         uint32_t ch_id,
    492                                         uint32_t stream_id,
    493                                         uint8_t buf_type,
    494                                         uint32_t buf_idx,
    495                                         int32_t plane_idx,
    496                                         int fd,
    497                                         uint32_t size);
    498 extern int32_t mm_camera_unmap_stream_buf(mm_camera_obj_t *my_obj,
    499                                           uint32_t ch_id,
    500                                           uint32_t stream_id,
    501                                           uint8_t buf_type,
    502                                           uint32_t buf_idx,
    503                                           int32_t plane_idx);
    504 extern int32_t mm_camera_do_stream_action(mm_camera_obj_t *my_obj,
    505                                           uint32_t ch_id,
    506                                           uint32_t stream_id,
    507                                           void *actions);
    508 
    509 /* mm_channel */
    510 extern int32_t mm_channel_fsm_fn(mm_channel_t *my_obj,
    511                                  mm_channel_evt_type_t evt,
    512                                  void * in_val,
    513                                  void * out_val);
    514 extern int32_t mm_channel_init(mm_channel_t *my_obj,
    515                                mm_camera_channel_attr_t *attr,
    516                                mm_camera_buf_notify_t channel_cb,
    517                                void *userdata);
    518 /* qbuf is a special case that not going through state machine.
    519  * This is to avoid deadlock when trying to aquire ch_lock,
    520  * from the context of dataCB, but async stop is holding ch_lock */
    521 extern int32_t mm_channel_qbuf(mm_channel_t *my_obj,
    522                                mm_camera_buf_def_t *buf);
    523 
    524 /* mm_stream */
    525 extern int32_t mm_stream_fsm_fn(mm_stream_t *my_obj,
    526                                 mm_stream_evt_type_t evt,
    527                                 void * in_val,
    528                                 void * out_val);
    529 /* Allow other stream to register dataCB at certain stream.
    530  * This is for use case of video sized live snapshot,
    531  * because snapshot stream need register one time CB at video stream.
    532  * ext_image_mode and sensor_idx are used to identify the destinate stream
    533  * to be register with dataCB. */
    534 extern int32_t mm_stream_reg_buf_cb(mm_stream_t *my_obj,
    535                                     mm_stream_data_cb_t *val);
    536 extern int32_t mm_stream_map_buf(mm_stream_t *my_obj,
    537                                  uint8_t buf_type,
    538                                  uint32_t frame_idx,
    539                                  int32_t plane_idx,
    540                                  int fd,
    541                                  uint32_t size);
    542 extern int32_t mm_stream_unmap_buf(mm_stream_t *my_obj,
    543                                    uint8_t buf_type,
    544                                    uint32_t frame_idx,
    545                                    int32_t plane_idx);
    546 
    547 
    548 /* utiltity fucntion declared in mm-camera-inteface2.c
    549  * and need be used by mm-camera and below*/
    550 uint32_t mm_camera_util_generate_handler(uint8_t index);
    551 const char * mm_camera_util_get_dev_name(uint32_t cam_handler);
    552 uint8_t mm_camera_util_get_index_by_handler(uint32_t handler);
    553 
    554 /* poll/cmd thread functions */
    555 extern int32_t mm_camera_poll_thread_launch(
    556                                 mm_camera_poll_thread_t * poll_cb,
    557                                 mm_camera_poll_thread_type_t poll_type);
    558 extern int32_t mm_camera_poll_thread_release(mm_camera_poll_thread_t *poll_cb);
    559 extern int32_t mm_camera_poll_thread_add_poll_fd(
    560                                 mm_camera_poll_thread_t * poll_cb,
    561                                 uint32_t handler,
    562                                 int32_t fd,
    563                                 mm_camera_poll_notify_t nofity_cb,
    564                                 void *userdata,
    565                                 mm_camera_call_type_t);
    566 extern int32_t mm_camera_poll_thread_del_poll_fd(
    567                                 mm_camera_poll_thread_t * poll_cb,
    568                                 uint32_t handler,
    569                                 mm_camera_call_type_t);
    570 extern int32_t mm_camera_cmd_thread_launch(
    571                                 mm_camera_cmd_thread_t * cmd_thread,
    572                                 mm_camera_cmd_cb_t cb,
    573                                 void* user_data);
    574 extern int32_t mm_camera_cmd_thread_name(const char* name);
    575 extern int32_t mm_camera_cmd_thread_release(mm_camera_cmd_thread_t * cmd_thread);
    576 
    577 #endif /* __MM_CAMERA_H__ */
    578