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