Home | History | Annotate | Download | only in inc
      1 /*
      2 Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
      3 
      4 Redistribution and use in source and binary forms, with or without
      5 modification, are permitted provided that the following conditions are
      6 met:
      7     * Redistributions of source code must retain the above copyright
      8       notice, this list of conditions and the following disclaimer.
      9     * Redistributions in binary form must reproduce the above
     10       copyright notice, this list of conditions and the following
     11       disclaimer in the documentation and/or other materials provided
     12       with the distribution.
     13     * Neither the name of The Linux Foundation nor the names of its
     14       contributors may be used to endorse or promote products derived
     15       from this software without specific prior written permission.
     16 
     17 THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
     18 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
     20 ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
     21 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
     24 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     25 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
     26 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
     27 IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28 */
     29 
     30 #ifndef __MM_CAMERA_H__
     31 #define __MM_CAMERA_H__
     32 
     33 #include "mm_camera_interface.h"
     34 
     35 /**********************************************************************************
     36 * Data structure declare
     37 ***********************************************************************************/
     38 /* num of streams allowed in a channel obj */
     39 //TODO: change for Stats
     40 #define MM_CAMEAR_STRAEM_NUM_MAX (16)
     41 /* num of channels allowed in a camera obj */
     42 #define MM_CAMERA_CHANNEL_MAX 1
     43 /* num of callbacks allowed for an event type */
     44 #define MM_CAMERA_EVT_ENTRY_MAX 4
     45 /* num of data callbacks allowed in a stream obj */
     46 #define MM_CAMERA_STREAM_BUF_CB_MAX 4
     47 /* num of data poll threads allowed in a channel obj */
     48 #define MM_CAMERA_CHANNEL_POLL_THREAD_MAX 1
     49 
     50 #define MM_CAMERA_DEV_NAME_LEN 32
     51 #define MM_CAMERA_DEV_OPEN_TRIES 2
     52 #define MM_CAMERA_DEV_OPEN_RETRY_SLEEP 20
     53 
     54 struct mm_channel;
     55 struct mm_stream;
     56 struct mm_camera_obj;
     57 
     58 /* common use */
     59 typedef struct {
     60     struct cam_list list;
     61     void* data;
     62 } mm_camera_q_node_t;
     63 
     64 typedef struct {
     65     mm_camera_q_node_t head; /* dummy head */
     66     uint32_t size;
     67     pthread_mutex_t lock;
     68 } mm_camera_queue_t;
     69 
     70 typedef enum
     71 {
     72     MM_CAMERA_ASYNC_CMD_TYPE_STOP,    /* async stop */
     73     MM_CAMERA_ASYNC_CMD_TYPE_MAX
     74 } mm_camera_async_cmd_type_t;
     75 
     76 typedef struct {
     77     struct mm_channel* ch_obj;
     78     uint8_t num_streams;
     79     uint32_t stream_ids[MM_CAMEAR_STRAEM_NUM_MAX];
     80 } mm_camera_async_stop_cmd_t;
     81 
     82 typedef struct {
     83     mm_camera_async_cmd_type_t cmd_type;
     84     union {
     85         mm_camera_async_stop_cmd_t stop_cmd;
     86     } u;
     87 } mm_camera_async_cmd_t;
     88 
     89 typedef enum
     90 {
     91     MM_CAMERA_CMD_TYPE_DATA_CB,    /* dataB CMD */
     92     MM_CAMERA_CMD_TYPE_EVT_CB,     /* evtCB CMD */
     93     MM_CAMERA_CMD_TYPE_ASYNC_CB,   /* asyncCB CMD */
     94     MM_CAMERA_CMD_TYPE_EXIT,       /* EXIT */
     95     MM_CAMERA_CMD_TYPE_REQ_DATA_CB,/* request data */
     96     MM_CAMERA_CMD_TYPE_SUPER_BUF_DATA_CB,    /* superbuf dataB CMD */
     97     MM_CAMERA_CMD_TYPE_MAX
     98 } mm_camera_cmdcb_type_t;
     99 
    100 typedef struct {
    101     uint32_t stream_id;
    102     uint32_t frame_idx;
    103     mm_camera_buf_def_t *buf; /* ref to buf */
    104 } mm_camera_buf_info_t;
    105 
    106 typedef struct {
    107     uint32_t num_buf_requested;
    108 } mm_camera_req_buf_t;
    109 
    110 typedef struct {
    111     mm_camera_cmdcb_type_t cmd_type;
    112     union {
    113         mm_camera_buf_info_t buf;    /* frame buf if dataCB */
    114         mm_camera_event_t evt;       /* evt if evtCB */
    115         mm_camera_async_cmd_t async; /* async cmd */
    116         mm_camera_super_buf_t superbuf; /* superbuf if superbuf dataCB*/
    117         mm_camera_req_buf_t req_buf; /* num of buf requested */
    118     } u;
    119 } mm_camera_cmdcb_t;
    120 
    121 typedef void (*mm_camera_cmd_cb_t)(mm_camera_cmdcb_t * cmd_cb, void* user_data);
    122 
    123 typedef struct {
    124     mm_camera_queue_t cmd_queue; /* cmd queue (queuing dataCB, asyncCB, or exitCMD) */
    125     pthread_t cmd_pid;           /* cmd thread ID */
    126     sem_t cmd_sem;               /* semaphore for cmd thread */
    127     mm_camera_cmd_cb_t cb;       /* cb for cmd */
    128     void* user_data;             /* user_data for cb */
    129 } mm_camera_cmd_thread_t;
    130 
    131 typedef enum {
    132     MM_CAMERA_POLL_TYPE_EVT,
    133     MM_CAMERA_POLL_TYPE_CH,
    134     MM_CAMERA_POLL_TYPE_MAX
    135 } mm_camera_poll_thread_type_t;
    136 
    137 /* function ptr defined for poll notify CB,
    138  * registered at poll thread with poll fd */
    139 typedef void (*mm_camera_poll_notify_t)(void *user_data);
    140 
    141 typedef struct {
    142     int32_t fd;
    143     mm_camera_poll_notify_t notify_cb;
    144     uint32_t handler;
    145     void* user_data;
    146 } mm_camera_poll_entry_t;
    147 
    148 typedef struct {
    149     mm_camera_poll_thread_type_t poll_type;
    150     /* array to store poll fd and cb info
    151      * for MM_CAMERA_POLL_TYPE_EVT, only index 0 is valid;
    152      * for MM_CAMERA_POLL_TYPE_CH, depends on valid stream fd */
    153     mm_camera_poll_entry_t poll_entries[MM_CAMEAR_STRAEM_NUM_MAX];
    154     int32_t pfds[2];
    155     pthread_t pid;
    156     int32_t state;
    157     int timeoutms;
    158     uint32_t cmd;
    159     struct pollfd poll_fds[MM_CAMEAR_STRAEM_NUM_MAX+1];
    160     uint8_t num_fds;
    161     pthread_mutex_t mutex;
    162     pthread_cond_t cond_v;
    163     int32_t status;
    164     //void *my_obj;
    165 } mm_camera_poll_thread_t;
    166 
    167 /* mm_stream */
    168 typedef enum {
    169     MM_STREAM_STATE_NOTUSED = 0,      /* not used */
    170     MM_STREAM_STATE_INITED,           /* inited  */
    171     MM_STREAM_STATE_ACQUIRED,         /* acquired, fd opened  */
    172     MM_STREAM_STATE_CFG,              /* fmt & dim configured */
    173     MM_STREAM_STATE_BUFFED,           /* buf allocated */
    174     MM_STREAM_STATE_REG,              /* buf regged, stream off */
    175     MM_STREAM_STATE_ACTIVE_STREAM_ON, /* active with stream on */
    176     MM_STREAM_STATE_ACTIVE_STREAM_OFF, /* active with stream off */
    177     MM_STREAM_STATE_MAX
    178 } mm_stream_state_type_t;
    179 
    180 typedef enum {
    181     MM_STREAM_EVT_ACQUIRE,
    182     MM_STREAM_EVT_RELEASE,
    183     MM_STREAM_EVT_SET_FMT,
    184     MM_STREAM_EVT_GET_BUF,
    185     MM_STREAM_EVT_PUT_BUF,
    186     MM_STREAM_EVT_REG_BUF,
    187     MM_STREAM_EVT_UNREG_BUF,
    188     MM_STREAM_EVT_START,
    189     MM_STREAM_EVT_STOP,
    190     MM_STREAM_EVT_QBUF,
    191     MM_STREAM_EVT_SET_PARM,
    192     MM_STREAM_EVT_GET_PARM,
    193     MM_STREAM_EVT_MAX
    194 } mm_stream_evt_type_t;
    195 
    196 typedef struct {
    197     mm_camera_buf_notify_t cb;
    198     void *user_data;
    199     /* cb_count = -1: infinite
    200      * cb_count > 0: register only for required times */
    201     int8_t cb_count;
    202 } mm_stream_data_cb_t;
    203 
    204 typedef struct {
    205     /* buf reference count */
    206     uint8_t buf_refcnt;
    207 
    208     /* This flag is to indicate if after allocation,
    209      * the corresponding buf needs to qbuf into kernel
    210      * (e.g. for preview usecase, display needs to hold two bufs,
    211      * so no need to qbuf these two bufs initially) */
    212     uint8_t initial_reg_flag;
    213 
    214     /* indicate if buf is in kernel(1) or client(0) */
    215     uint8_t in_kernel;
    216 } mm_stream_buf_status_t;
    217 
    218 typedef struct mm_stream {
    219     uint32_t my_hdl;
    220     uint32_t inst_hdl;
    221     int32_t fd;
    222     mm_stream_state_type_t state;
    223 
    224     /* ext_image_mode used as id for stream obj */
    225     uint32_t ext_image_mode;
    226 
    227     /* sensor index used */
    228     uint32_t sensor_idx;
    229 
    230     mm_camera_image_fmt_t fmt;
    231 
    232     mm_camera_cmd_thread_t cmd_thread;
    233 
    234     /* dataCB registered on this stream obj */
    235     pthread_mutex_t cb_lock; /* cb lock to protect buf_cb */
    236     mm_stream_data_cb_t buf_cb[MM_CAMERA_STREAM_BUF_CB_MAX];
    237 
    238     /* stream buffer management */
    239     pthread_mutex_t buf_lock;
    240     uint8_t buf_num; /* num of buffers allocated */
    241     mm_camera_buf_def_t* buf; /* ptr to buf array */
    242     mm_stream_buf_status_t* buf_status; /* ptr to buf status array */
    243 
    244     /* reference to parent channel_obj */
    245     struct mm_channel* ch_obj;
    246 
    247     uint8_t is_bundled; /* flag if stream is bundled */
    248     uint8_t is_local_buf; /* flag if buf is local copy, no need to qbuf to kernel */
    249     uint8_t hal_requested_num_bufs;
    250     uint8_t need_stream_on; /* flag if stream need streamon when start */
    251     uint8_t num_stream_cb_times; /* how many times to register for other stream data CB */
    252     uint8_t local_buf_idx; /* idx to local buf that can be used for non-stream-on cb */
    253 
    254     mm_camera_frame_len_offset frame_offset; /*Stream buffer offset information*/
    255 } mm_stream_t;
    256 
    257 /* mm_channel */
    258 typedef enum {
    259     MM_CHANNEL_STATE_NOTUSED = 0,   /* not used */
    260     MM_CHANNEL_STATE_STOPPED,       /* stopped */
    261     MM_CHANNEL_STATE_ACTIVE,        /* active, at least one stream active */
    262     MM_CHANNEL_STATE_PAUSED,        /* paused */
    263     MM_CHANNEL_STATE_MAX
    264 } mm_channel_state_type_t;
    265 
    266 typedef enum {
    267     MM_CHANNEL_EVT_ADD_STREAM,
    268     MM_CHANNEL_EVT_DEL_STREAM,
    269     MM_CHANNEL_EVT_START_STREAM,
    270     MM_CHANNEL_EVT_STOP_STREAM,
    271     MM_CHANNEL_EVT_TEARDOWN_STREAM,
    272     MM_CHANNEL_EVT_CONFIG_STREAM,
    273     MM_CHANNEL_EVT_PAUSE,
    274     MM_CHANNEL_EVT_RESUME,
    275     MM_CHANNEL_EVT_INIT_BUNDLE,
    276     MM_CHANNEL_EVT_DESTROY_BUNDLE,
    277     MM_CHANNEL_EVT_REQUEST_SUPER_BUF,
    278     MM_CHANNEL_EVT_CANCEL_REQUEST_SUPER_BUF,
    279     MM_CHANNEL_EVT_START_FOCUS,
    280     MM_CHANNEL_EVT_ABORT_FOCUS,
    281     MM_CHANNEL_EVT_PREPARE_SNAPSHOT,
    282     MM_CHANNEL_EVT_SET_STREAM_PARM,
    283     MM_CHANNEL_EVT_GET_STREAM_PARM,
    284     MM_CHANNEL_EVT_DELETE,
    285     MM_CHANNEL_EVT_OPEN_REPRO_ISP,
    286     MM_CHANNEL_EVT_CONFIG_REPRO_ISP,
    287     MM_CHANNEL_EVT_ATTACH_STREAM_TO_REPRO_ISP,
    288     MM_CHANNEL_EVT_START_REPRO_ISP,
    289     MM_CHANNEL_EVT_REPROCESS,
    290     MM_CHANNEL_EVT_STOP_REPRO_ISP,
    291     MM_CHANNEL_EVT_DETACH_STREAM_FROM_REPRO_ISP,
    292     MM_CHANNEL_EVT_CLOSE_REPRO_ISP,
    293     MM_CHANNEL_EVT_MAX
    294 } mm_channel_evt_type_t;
    295 
    296 typedef struct {
    297     mm_camera_buf_notify_t buf_cb;
    298     void *user_data;
    299     uint32_t ext_image_mode;
    300     uint32_t sensor_idx;
    301 } mm_evt_paylod_add_stream_t;
    302 
    303 typedef struct {
    304     uint32_t stream_id;
    305     mm_camera_stream_config_t *config;
    306 } mm_evt_paylod_config_stream_t;
    307 
    308 typedef struct {
    309     mm_camera_stream_parm_t parm_type;
    310     void *value;
    311 } mm_evt_paylod_stream_parm_t;
    312 
    313 typedef struct {
    314     mm_camera_buf_notify_t super_frame_notify_cb;
    315     void *user_data;
    316     mm_camera_bundle_attr_t *attr;
    317     uint8_t num_streams;
    318     uint32_t *stream_ids;
    319 } mm_evt_payload_bundle_stream_t;
    320 
    321 typedef struct {
    322     uint8_t num_streams;
    323     uint32_t *stream_ids;
    324 } mm_evt_payload_start_stream_t;
    325 
    326 typedef struct {
    327     uint8_t num_streams;
    328     uint32_t *stream_ids;
    329 } mm_evt_payload_stop_stream_t;
    330 
    331 typedef struct {
    332     uint32_t sensor_idx;
    333     uint32_t focus_mode;
    334 } mm_evt_payload_start_focus_t;
    335 
    336 typedef struct {
    337     uint32_t repro_isp_handle;
    338     mm_camera_repro_isp_config_t *config;
    339 } mm_evt_paylod_config_repro_isp_t;
    340 
    341 typedef struct {
    342     uint32_t repro_isp_handle;
    343     uint32_t stream_id;
    344 } mm_evt_paylod_stream_to_repro_isp_t;
    345 
    346 typedef struct {
    347     uint32_t repro_isp_handle;
    348     mm_camera_repro_data_t *repro_data;
    349 } mm_evt_paylod_reprocess_t;
    350 
    351 typedef struct {
    352     uint32_t repro_isp_handle;
    353     uint32_t stream_id;
    354 } mm_evt_paylod_repro_start_stop_t;
    355 
    356 typedef struct {
    357     uint8_t num_of_bufs;
    358     mm_camera_buf_info_t super_buf[MM_CAMEAR_MAX_STRAEM_BUNDLE];
    359     uint8_t matched;
    360 } mm_channel_queue_node_t;
    361 
    362 typedef struct {
    363     mm_camera_queue_t que;
    364     uint8_t num_streams;
    365     /* container for bundled stream handlers */
    366     uint32_t bundled_streams[MM_CAMEAR_MAX_STRAEM_BUNDLE];
    367     mm_camera_bundle_attr_t attr;
    368     uint32_t expected_frame_id;
    369     uint32_t match_cnt;
    370 } mm_channel_queue_t;
    371 
    372 typedef struct {
    373     uint8_t is_active; /* flag to indicate if bundle is valid */
    374     /* queue to store bundled super buffers */
    375     mm_channel_queue_t superbuf_queue;
    376     mm_camera_buf_notify_t super_buf_notify_cb;
    377     void *user_data;
    378 } mm_channel_bundle_t;
    379 
    380 typedef struct mm_channel {
    381     uint32_t my_hdl;
    382     mm_channel_state_type_t state;
    383     pthread_mutex_t ch_lock; /* channel lock */
    384 
    385     /* stream bundle info in the channel */
    386     mm_channel_bundle_t bundle;
    387 
    388     /* num of pending suferbuffers */
    389     uint32_t pending_cnt;
    390 
    391     /* cmd thread for superbuffer dataCB and async stop*/
    392     mm_camera_cmd_thread_t cmd_thread;
    393 
    394     /* cb thread for sending data cb */
    395     mm_camera_cmd_thread_t cb_thread;
    396 
    397     /* data poll thread
    398     * currently one data poll thread per channel
    399     * could extended to support one data poll thread per stream in the channel */
    400     mm_camera_poll_thread_t poll_thread[MM_CAMERA_CHANNEL_POLL_THREAD_MAX];
    401 
    402     /* container for all streams in channel
    403     * stream is indexed by ext_image_mode */
    404     mm_stream_t streams[MM_CAMEAR_STRAEM_NUM_MAX];
    405 
    406     /* reference to parent cam_obj */
    407     struct mm_camera_obj* cam_obj;
    408 } mm_channel_t;
    409 
    410 /* struct to store information about pp cookie*/
    411 typedef struct {
    412     uint32_t cam_hdl;
    413     uint32_t ch_hdl;
    414     uint32_t stream_hdl;
    415     mm_channel_queue_node_t* super_buf;
    416 } mm_channel_pp_info_t;
    417 
    418 /* mm_camera */
    419 typedef struct {
    420     mm_camera_event_notify_t evt_cb;
    421     void *user_data;
    422 } mm_camera_evt_entry_t;
    423 
    424 typedef struct {
    425     mm_camera_evt_entry_t evt[MM_CAMERA_EVT_ENTRY_MAX];
    426     /* reg_count <=0: infinite
    427      * reg_count > 0: register only for required times */
    428     int reg_count;
    429 } mm_camera_evt_obj_t;
    430 
    431 typedef struct mm_camera_obj {
    432     uint32_t my_hdl;
    433     int ref_count;
    434     int32_t ctrl_fd;
    435     int32_t ds_fd; /* domain socket fd */
    436     cam_prop_t properties;
    437     mm_camera_2nd_sensor_t second_sensor; /*second sensor info */
    438     pthread_mutex_t cam_lock;
    439     pthread_mutex_t cb_lock; /* lock for evt cb */
    440     mm_channel_t ch[MM_CAMERA_CHANNEL_MAX];
    441     mm_camera_evt_obj_t evt[MM_CAMERA_EVT_TYPE_MAX];
    442     uint32_t evt_type_mask;
    443     mm_camear_mem_vtbl_t *mem_vtbl; /* vtable for memory management */
    444     mm_camera_poll_thread_t evt_poll_thread; /* evt poll thread */
    445     mm_camera_cmd_thread_t evt_thread;       /* thread for evt CB */
    446     mm_camera_cmd_thread_t async_cmd_thread; /* thread for async cmd */
    447     mm_camera_vtbl_t vtbl;
    448 
    449     /* some local variables */
    450     uint32_t snap_burst_num_by_user;
    451     camera_mode_t current_mode;
    452     uint32_t op_mode;
    453     cam_ctrl_dimension_t dim;
    454 } mm_camera_obj_t;
    455 
    456 typedef struct {
    457     mm_camera_info_t camera[MSM_MAX_CAMERA_SENSORS];
    458     int8_t num_cam;
    459     char video_dev_name[MSM_MAX_CAMERA_SENSORS][MM_CAMERA_DEV_NAME_LEN];
    460     mm_camera_obj_t *cam_obj[MSM_MAX_CAMERA_SENSORS];
    461 } mm_camera_ctrl_t;
    462 
    463 /**********************************************************************************
    464 * external function declare
    465 ***********************************************************************************/
    466 /* utility functions */
    467 /* set int32_t value */
    468 extern int32_t mm_camera_util_s_ctrl(int32_t fd,
    469                                      uint32_t id,
    470                                      int32_t value);
    471 
    472 extern int32_t mm_camera_util_private_s_ctrl( int32_t fd,
    473                                               uint32_t id, void* value);
    474 
    475 /* get int32_t value */
    476 extern int32_t mm_camera_util_g_ctrl(int32_t fd,
    477                                      uint32_t id,int32_t *value);
    478 
    479 /* send msg throught domain socket for fd mapping */
    480 extern int32_t mm_camera_util_sendmsg(mm_camera_obj_t *my_obj,
    481                                       void *msg,
    482                                       uint32_t buf_size,
    483                                       int sendfd);
    484 
    485 /* mm-camera */
    486 extern int32_t mm_camera_open(mm_camera_obj_t *my_obj);
    487 extern int32_t mm_camera_close(mm_camera_obj_t *my_obj);
    488 extern uint8_t mm_camera_is_event_supported(mm_camera_obj_t *my_obj,
    489                                             mm_camera_event_type_t evt_type);
    490 extern int32_t mm_camera_register_event_notify(mm_camera_obj_t *my_obj,
    491                                                mm_camera_event_notify_t evt_cb,
    492                                                void * user_data,
    493                                                mm_camera_event_type_t evt_type);
    494 extern int32_t mm_camera_qbuf(mm_camera_obj_t *my_obj,
    495                               uint32_t ch_id,
    496                               mm_camera_buf_def_t *buf);
    497 extern mm_camera_2nd_sensor_t * mm_camera_query_2nd_sensor_info(mm_camera_obj_t *my_obj);
    498 extern int32_t mm_camera_sync(mm_camera_obj_t *my_obj);
    499 extern int32_t mm_camera_is_op_supported(mm_camera_obj_t *my_obj,
    500                                               mm_camera_ops_type_t opcode);
    501 extern int32_t mm_camera_is_parm_supported(mm_camera_obj_t *my_obj,
    502                                            mm_camera_parm_type_t parm_type,
    503                                            uint8_t *support_set_parm,
    504                                            uint8_t *support_get_parm);
    505 extern int32_t mm_camera_set_parm(mm_camera_obj_t *my_obj,
    506                                   mm_camera_parm_type_t parm_type,
    507                                   void* p_value);
    508 extern int32_t mm_camera_get_parm(mm_camera_obj_t *my_obj,
    509                                   mm_camera_parm_type_t parm_type,
    510                                   void* p_value);
    511 extern uint32_t mm_camera_add_channel(mm_camera_obj_t *my_obj);
    512 extern void mm_camera_del_channel(mm_camera_obj_t *my_obj,
    513                                   uint32_t ch_id);
    514 extern uint32_t mm_camera_add_stream(mm_camera_obj_t *my_obj,
    515                                      uint32_t ch_id,
    516                                      mm_camera_buf_notify_t buf_cb, void *user_data,
    517                                      uint32_t ext_image_mode, uint32_t sensor_idx);
    518 extern int32_t mm_camera_del_stream(mm_camera_obj_t *my_obj,
    519                                     uint32_t ch_id,
    520                                     uint32_t stream_id);
    521 extern int32_t mm_camera_config_stream(mm_camera_obj_t *my_obj,
    522                                        uint32_t ch_id,
    523                                        uint32_t stream_id,
    524                                        mm_camera_stream_config_t *config);
    525 extern int32_t mm_camera_bundle_streams(mm_camera_obj_t *my_obj,
    526                                         uint32_t ch_id,
    527                                         mm_camera_buf_notify_t super_frame_notify_cb,
    528                                         void *user_data,
    529                                         mm_camera_bundle_attr_t *attr,
    530                                         uint8_t num_streams,
    531                                         uint32_t *stream_ids);
    532 extern int32_t mm_camera_destroy_bundle(mm_camera_obj_t *my_obj,
    533                                         uint32_t ch_id);
    534 extern int32_t mm_camera_start_streams(mm_camera_obj_t *my_obj,
    535                                        uint32_t ch_id,
    536                                        uint8_t num_streams,
    537                                        uint32_t *stream_ids);
    538 extern int32_t mm_camera_stop_streams(mm_camera_obj_t *my_obj,
    539                                       uint32_t ch_id,
    540                                       uint8_t num_streams,
    541                                       uint32_t *stream_ids);
    542 extern int32_t mm_camera_async_teardown_streams(mm_camera_obj_t *my_obj,
    543                                                 uint32_t ch_id,
    544                                                 uint8_t num_streams,
    545                                                 uint32_t *stream_ids);
    546 extern int32_t mm_camera_request_super_buf(mm_camera_obj_t *my_obj,
    547                                            uint32_t ch_id,
    548                                            uint32_t num_buf_requested);
    549 extern int32_t mm_camera_cancel_super_buf_request(mm_camera_obj_t *my_obj,
    550                                                   uint32_t ch_id);
    551 extern int32_t mm_camera_start_focus(mm_camera_obj_t *my_obj,
    552                                      uint32_t ch_id,
    553                                      uint32_t sensor_idx,
    554                                      uint32_t focus_mode);
    555 extern int32_t mm_camera_abort_focus(mm_camera_obj_t *my_obj,
    556                                      uint32_t ch_id,
    557                                      uint32_t sensor_idx);
    558 extern int32_t mm_camera_prepare_snapshot(mm_camera_obj_t *my_obj,
    559                                           uint32_t ch_id,
    560                                           uint32_t sensor_idx);
    561 extern int32_t mm_camera_set_stream_parm(mm_camera_obj_t *my_obj,
    562                                   uint32_t ch_id,
    563                                   uint32_t s_id,
    564                                   mm_camera_stream_parm_t parm_type,
    565                                   void* p_value);
    566 
    567 extern int32_t mm_camera_get_stream_parm(mm_camera_obj_t *my_obj,
    568                                   uint32_t ch_id,
    569                                   uint32_t s_id,
    570                                   mm_camera_stream_parm_t parm_type,
    571                                   void* p_value);
    572 
    573 extern int32_t mm_camera_register_event_notify_internal(
    574                                    mm_camera_obj_t *my_obj,
    575                                    mm_camera_event_notify_t evt_cb,
    576                                    void * user_data,
    577                                    mm_camera_event_type_t evt_type);
    578 extern int32_t mm_camera_map_buf(mm_camera_obj_t *my_obj,
    579                                  int ext_mode,
    580                                  int idx,
    581                                  int fd,
    582                                  uint32_t size);
    583 extern int32_t mm_camera_unmap_buf(mm_camera_obj_t *my_obj,
    584                                    int ext_mode,
    585                                    int idx);
    586 extern int32_t mm_camera_send_ch_event(mm_camera_obj_t *my_obj,
    587                                        uint32_t ch_id,
    588                                        uint32_t stream_id,
    589                                        mm_camera_ch_event_type_t evt);
    590 extern int32_t mm_camera_send_private_ioctl(mm_camera_obj_t *my_obj,
    591                                             uint32_t cmd_id,
    592                                             uint32_t cmd_length,
    593                                             void *cmd);
    594 extern int32_t mm_camera_open_repro_isp(mm_camera_obj_t *my_obj,
    595                                         uint32_t ch_id,
    596                                         mm_camera_repro_isp_type_t repro_isp_type,
    597                                         uint32_t *repro_isp_handle);
    598 extern int32_t mm_camera_config_repro_isp(mm_camera_obj_t *my_obj,
    599                                           uint32_t ch_id,
    600                                           uint32_t repro_isp_handle,
    601                                           mm_camera_repro_isp_config_t *config);
    602 extern int32_t mm_camera_attach_stream_to_repro_isp(mm_camera_obj_t *my_obj,
    603                                                     uint32_t ch_id,
    604                                                     uint32_t repro_isp_handle,
    605                                                     uint32_t stream_id);
    606 extern int32_t mm_camera_start_repro_isp(mm_camera_obj_t *my_obj,
    607                                          uint32_t ch_id,
    608                                          uint32_t repro_isp_handle,
    609                                          uint32_t stream_id);
    610 extern int32_t mm_camera_reprocess(mm_camera_obj_t *my_obj,
    611                                    uint32_t ch_id,
    612                                    uint32_t repro_isp_handle,
    613                                    mm_camera_repro_data_t *repo_data);
    614 extern int32_t mm_camera_stop_repro_isp(mm_camera_obj_t *my_obj,
    615                                         uint32_t ch_id,
    616                                         uint32_t repro_isp_handle,
    617                                         uint32_t stream_id);
    618 extern int32_t mm_camera_detach_stream_from_repro_isp(mm_camera_obj_t *my_obj,
    619                                                       uint32_t ch_id,
    620                                                       uint32_t repro_isp_handle,
    621                                                       uint32_t stream_id);
    622 extern int32_t mm_camera_close_repro_isp(mm_camera_obj_t *my_obj,
    623                                          uint32_t ch_id,
    624                                          uint32_t repro_isp_handle);
    625 
    626 extern uint8_t mm_camera_util_get_pp_mask(mm_camera_obj_t *my_obj);
    627 
    628 /* mm_channel */
    629 extern int32_t mm_channel_fsm_fn(mm_channel_t *my_obj,
    630                                  mm_channel_evt_type_t evt,
    631                                  void * in_val,
    632                                  void * out_val);
    633 
    634 /* qbuf is a special case that not going through state machine.
    635  * This is to avoid deadlock when trying to aquire ch_lock,
    636  * from the context of dataCB, but async stop is holding ch_lock */
    637 extern int32_t mm_channel_qbuf(mm_channel_t *my_obj,
    638                                mm_camera_buf_def_t *buf);
    639 
    640 /* Allow other stream to register dataCB at certain stream.
    641  * This is for use case of video sized live snapshot,
    642  * because snapshot stream need register one time CB at video stream.
    643  * ext_image_mode and sensor_idx are used to identify the destinate stream
    644  * to be register with dataCB. */
    645 extern int32_t mm_channel_reg_stream_cb(mm_channel_t *my_obj,
    646                                         mm_stream_data_cb_t *cb,
    647                                         uint32_t ext_image_mode,
    648                                         uint32_t sensor_idx);
    649 
    650 /* mm_stream */
    651 extern int32_t mm_stream_fsm_fn(mm_stream_t *my_obj,
    652                                 mm_stream_evt_type_t evt,
    653                                 void * in_val,
    654                                 void * out_val);
    655 /* Allow other stream to register dataCB at certain stream.
    656  * This is for use case of video sized live snapshot,
    657  * because snapshot stream need register one time CB at video stream.
    658  * ext_image_mode and sensor_idx are used to identify the destinate stream
    659  * to be register with dataCB. */
    660 extern int32_t mm_stream_reg_buf_cb(mm_stream_t *my_obj,
    661                                     mm_stream_data_cb_t *val);
    662 
    663 /* utiltity fucntion declared in mm-camera-inteface2.c
    664  * and need be used by mm-camera and below*/
    665 uint32_t mm_camera_util_generate_handler(uint8_t index);
    666 const char * mm_camera_util_get_dev_name(uint32_t cam_handler);
    667 uint8_t mm_camera_util_get_index_by_handler(uint32_t handler);
    668 
    669 /* queue functions */
    670 extern int32_t mm_camera_queue_init(mm_camera_queue_t* queue);
    671 extern int32_t mm_camera_queue_enq(mm_camera_queue_t* queue, void* node);
    672 extern void* mm_camera_queue_deq(mm_camera_queue_t* queue);
    673 extern int32_t mm_camera_queue_deinit(mm_camera_queue_t* queue);
    674 extern int32_t mm_camera_queue_flush(mm_camera_queue_t* queue);
    675 
    676 /* poll/cmd thread functions */
    677 extern int32_t mm_camera_poll_thread_launch(
    678                                 mm_camera_poll_thread_t * poll_cb,
    679                                 mm_camera_poll_thread_type_t poll_type);
    680 extern int32_t mm_camera_poll_thread_release(mm_camera_poll_thread_t *poll_cb);
    681 extern int32_t mm_camera_poll_thread_add_poll_fd(
    682                                 mm_camera_poll_thread_t * poll_cb,
    683                                 uint32_t handler,
    684                                 int32_t fd,
    685                                 mm_camera_poll_notify_t nofity_cb,
    686                                 void *userdata);
    687 extern int32_t mm_camera_poll_thread_del_poll_fd(
    688                                 mm_camera_poll_thread_t * poll_cb,
    689                                 uint32_t handler);
    690 extern int32_t mm_camera_cmd_thread_launch(
    691                                 mm_camera_cmd_thread_t * cmd_thread,
    692                                 mm_camera_cmd_cb_t cb,
    693                                 void* user_data);
    694 extern int32_t mm_camera_cmd_thread_release(mm_camera_cmd_thread_t * cmd_thread);
    695 
    696 #endif /* __MM_CAMERA_H__ */
    697