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_QCAMERA_APP_H__
     31 #define __MM_QCAMERA_APP_H__
     32 
     33 #include "camera.h"
     34 #include "mm_qcamera_main_menu.h"
     35 #include "mm_camera_interface.h"
     36 #include "mm_jpeg_interface.h"
     37 
     38 #define MM_QCAMERA_APP_INTERATION 1
     39 
     40 #define MM_APP_MAX_DUMP_FRAME_NUM 1000
     41 
     42 #define PREVIEW_BUF_NUM 7
     43 #define VIDEO_BUF_NUM 7
     44 #define ISP_PIX_BUF_NUM 9
     45 
     46 #define STATS_BUF_NUM 4
     47 
     48 typedef enum {
     49     MM_CAMERA_OK,
     50     MM_CAMERA_E_GENERAL,
     51     MM_CAMERA_E_NO_MEMORY,
     52     MM_CAMERA_E_NOT_SUPPORTED,
     53     MM_CAMERA_E_INVALID_INPUT,
     54     MM_CAMERA_E_INVALID_OPERATION, /* 5 */
     55     MM_CAMERA_E_ENCODE,
     56     MM_CAMERA_E_BUFFER_REG,
     57     MM_CAMERA_E_PMEM_ALLOC,
     58     MM_CAMERA_E_CAPTURE_FAILED,
     59     MM_CAMERA_E_CAPTURE_TIMEOUT, /* 10 */
     60 }mm_camera_status_type_t;
     61 
     62 typedef struct {
     63     int num;
     64     mm_camera_buf_def_t bufs[MM_CAMERA_MAX_NUM_FRAMES];
     65     struct ion_allocation_data alloc[MM_CAMERA_MAX_NUM_FRAMES];
     66     struct ion_fd_data ion_info_fd[MM_CAMERA_MAX_NUM_FRAMES];
     67 } mm_camear_app_buf_t;
     68 
     69 typedef struct {
     70     uint32_t id;
     71     mm_camera_stream_config_t str_config;
     72     mm_camear_app_buf_t app_bufs;
     73 }mm_camear_stream_t;
     74 
     75 typedef enum{
     76     CAMERA_STATE_OPEN,
     77     CAMERA_STATE_PREVIEW,
     78     CAMERA_STATE_RECORD,
     79     CAMERA_STATE_SNAPSHOT,
     80     CAMERA_STATE_RDI
     81 }camera_state;
     82 
     83 typedef enum{
     84     CAMERA_MODE,
     85     RECORDER_MODE,
     86     ZSL_MODE,
     87     RDI_MODE
     88 }camera_mode;
     89 
     90 #define MM_QCAM_APP_MAX_STREAM_NUM MM_CAMERA_IMG_MODE_MAX
     91 
     92 typedef struct {
     93     mm_camera_buf_def_t *frame;
     94     uint8_t ref_cnt;
     95 } repro_src_buf_info;
     96 
     97 typedef struct {
     98     struct cam_list list;
     99     void* data;
    100 } mm_qcamera_q_node_t;
    101 
    102 typedef struct {
    103     mm_qcamera_q_node_t head; /* dummy head */
    104     uint32_t size;
    105     pthread_mutex_t lock;
    106 } mm_qcamera_queue_t;
    107 
    108 typedef struct {
    109     mm_camera_vtbl_t *cam;
    110     mm_camear_mem_vtbl_t *mem_cam;
    111     int8_t my_id;
    112     //mm_camera_op_mode_type_t op_mode;
    113     uint32_t ch_id;
    114     cam_ctrl_dimension_t dim;
    115     int open_flag;
    116     int ionfd;
    117     mm_camear_stream_t stream[MM_QCAM_APP_MAX_STREAM_NUM];
    118     camera_mode cam_mode;
    119     camera_state cam_state;
    120     int fullSizeSnapshot;
    121 
    122     mm_jpeg_ops_t jpeg_ops;
    123     uint32_t jpeg_hdl;
    124     mm_camera_super_buf_t* current_job_frames;
    125     uint32_t current_job_id;
    126     mm_camear_app_buf_t jpeg_buf;
    127 
    128     uint32_t isp_repro_handle;
    129     uint8_t repro_dest_num;
    130     mm_qcamera_queue_t repro_q;
    131     repro_src_buf_info repro_buf_info[ISP_PIX_BUF_NUM];
    132     mm_camera_repro_config_data_t repro_config;
    133 } mm_camera_app_obj_t;
    134 
    135 typedef struct {
    136   void *ptr;
    137   void* ptr_jpeg;
    138 
    139   mm_camera_info_t *(*mm_camera_query) (uint8_t *num_cameras);
    140   mm_camera_vtbl_t *(*mm_camera_open) (uint8_t camera_idx,
    141                                mm_camear_mem_vtbl_t *mem_vtbl);
    142   uint32_t (*jpeg_open) (mm_jpeg_ops_t *ops);
    143 
    144   /*uint8_t *(*mm_camera_do_mmap)(uint32_t size, int *pmemFd);
    145   int (*mm_camera_do_munmap)(int pmem_fd, void *addr, size_t size);
    146 
    147    uint8_t *(*mm_camera_do_mmap_ion)(int ion_fd, struct ion_allocation_data *alloc,
    148              struct ion_fd_data *ion_info_fd, int *mapFd);
    149   int (*mm_camera_do_munmap_ion) (int ion_fd, struct ion_fd_data *ion_info_fd,
    150                    void *addr, size_t size);*/
    151 #if 0
    152   uint32_t (*mm_camera_get_msm_frame_len)(cam_format_t fmt_type,
    153                                             camera_mode_t mode,
    154                                             int width,
    155                                             int height,
    156                                             int image_type,
    157                                             uint8_t *num_planes,
    158                                             uint32_t planes[]);
    159 #ifndef DISABLE_JPEG_ENCODING
    160   void (*set_callbacks)(jpegfragment_callback_t fragcallback,
    161     jpeg_callback_t eventcallback, void* userdata, void* output_buffer,
    162     int * outBufferSize);
    163   int8_t (*omxJpegOpen)(void);
    164   void (*omxJpegClose)(void);
    165   int8_t (*omxJpegStart)(void);
    166   int8_t (*omxJpegEncode)(omx_jpeg_encode_params *encode_params);
    167   void (*omxJpegFinish)(void);
    168   int8_t (*mm_jpeg_encoder_setMainImageQuality)(uint32_t quality);
    169 #endif
    170 #endif
    171 } hal_interface_lib_t;
    172 
    173 typedef struct {
    174     //mm_camera_vtbl_t *cam;
    175     uint8_t num_cameras;
    176     mm_camera_app_obj_t *obj[2];
    177     mm_camera_info_t *cam_info;
    178     int use_overlay;
    179     int use_user_ptr;
    180     hal_interface_lib_t hal_lib;
    181     int cam_open;
    182     int run_sanity;
    183 } mm_camera_app_t;
    184 
    185 extern mm_camera_app_t my_cam_app;
    186 extern USER_INPUT_DISPLAY_T input_display;
    187 extern int mm_app_dl_render(int frame_fd, struct crop_info * cropinfo);
    188 extern mm_camera_app_obj_t *mm_app_get_cam_obj(int8_t cam_id);
    189 extern int mm_app_load_hal();
    190 extern int mm_app_init();
    191 extern void mm_app_user_ptr(int use_user_ptr);
    192 extern int mm_app_open_ch(int cam_id);
    193 extern void mm_app_close_ch(int cam_id, int ch_type);
    194 extern int mm_app_set_dim(int8_t cam_id, cam_ctrl_dimension_t *dim);
    195 extern int mm_app_run_unit_test();
    196 extern int mm_app_unit_test_entry(mm_camera_app_t *cam_app);
    197 extern int mm_app_unit_test();
    198 extern void mm_app_set_dim_def(cam_ctrl_dimension_t *dim);
    199 extern int mm_app_open(uint8_t camera_idx);
    200 extern int mm_app_close(int8_t cam_id);
    201 extern int startPreview(int cam_id);
    202 extern int mm_app_stop_preview(int cam_id);
    203 extern int mm_app_stop_video(int cam_id);
    204 extern int startRecording(int cam_id);
    205 extern int stopRecording(int cam_id);
    206 extern int mm_app_take_picture(int cam_id);
    207 extern int mm_app_take_raw_picture(int cam_id);
    208 extern int mm_app_get_dim(int8_t cam_id, cam_ctrl_dimension_t *dim);
    209 extern int mm_app_streamon_preview(int cam_id);
    210 extern int mm_app_set_snapshot_fmt(int cam_id,mm_camera_image_fmt_t *fmt);
    211 
    212 extern int mm_app_dual_test_entry(mm_camera_app_t *cam_app);
    213 extern int mm_app_dual_test();
    214 
    215 extern int mm_camera_app_wait();
    216 extern void mm_camera_app_done();
    217 
    218 extern int mm_stream_initbuf(uint32_t camera_handle,
    219                              uint32_t ch_id, uint32_t stream_id,
    220                              void *user_data,
    221                              mm_camera_frame_len_offset *frame_offset_info,
    222                              uint8_t num_bufs,
    223                              uint8_t *initial_reg_flag,
    224                              mm_camera_buf_def_t *bufs);
    225 
    226 extern int mm_stream_deinitbuf(uint32_t camera_handle,
    227                              uint32_t ch_id, uint32_t stream_id,
    228                              void *user_data, uint8_t num_bufs,
    229                              mm_camera_buf_def_t *bufs);
    230 
    231 extern void mm_app_preview_notify_cb(mm_camera_super_buf_t *bufs,
    232                                      void *user_data);
    233 #endif /* __MM_QCAMERA_APP_H__ */
    234 
    235 
    236 
    237 
    238 
    239 
    240 
    241 
    242 
    243