Home | History | Annotate | Download | only in camera
      1 /*
      2 ** Copyright (c) 2011-2012, 2015, The Linux Foundation. All rights reserved.
      3 **
      4 ** Licensed under the Apache License, Version 2.0 (the "License");
      5 ** you may not use this file except in compliance with the License.
      6 ** You may obtain a copy of the License at
      7 **
      8 **     http://www.apache.org/licenses/LICENSE-2.0
      9 **
     10 ** Unless required by applicable law or agreed to in writing, software
     11 ** distributed under the License is distributed on an "AS IS" BASIS,
     12 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13 ** See the License for the specific language governing permissions and
     14 ** limitations under the License.
     15 */
     16 
     17 #ifndef ANDROID_HARDWARE_QCAMERA_HARDWARE_INTERFACE_H
     18 #define ANDROID_HARDWARE_QCAMERA_HARDWARE_INTERFACE_H
     19 
     20 
     21 #include <utils/threads.h>
     22 //#include <camera/CameraHardwareInterface.h>
     23 #include <hardware/camera.h>
     24 #include <binder/MemoryBase.h>
     25 #include <binder/MemoryHeapBase.h>
     26 //#include <binder/MemoryHeapPmem.h>
     27 #include <utils/threads.h>
     28 #include <cutils/properties.h>
     29 #include <camera/Camera.h>
     30 #include "QCameraParameters.h"
     31 #include <system/window.h>
     32 #include <system/camera.h>
     33 #include <hardware/camera.h>
     34 #include <gralloc_priv.h>
     35 #include <QComOMXMetadata.h>
     36 
     37 extern "C" {
     38 #include <linux/msm_ion.h>
     39 #include <mm_camera_interface2.h>
     40 #include "mm_omx_jpeg_encoder.h"
     41 } //extern C
     42 
     43 #include "QCameraHWI_Mem.h"
     44 #include "QCameraStream.h"
     45 #include "QCamera_Intf.h"
     46 
     47 #include "hdr/include/morpho_noise_reduction_ext.h"
     48 //Error codes
     49 #define  NOT_FOUND -1
     50 #define MAX_ZOOM_RATIOS 62
     51 
     52 #ifdef Q12
     53 #undef Q12
     54 #endif
     55 
     56 #define Q12 4096
     57 #define QCAMERA_PARM_ENABLE   1
     58 #define QCAMERA_PARM_DISABLE  0
     59 #define PREVIEW_TBL_MAX_SIZE  14
     60 #define VIDEO_TBL_MAX_SIZE    14
     61 #define THUMB_TBL_MAX_SIZE    16
     62 #define HFR_TBL_MAX_SIZE      2
     63 
     64 struct str_map {
     65     const char *const desc;
     66     int val;
     67 };
     68 
     69 struct preview_format_info_t {
     70    int Hal_format;
     71    cam_format_t mm_cam_format;
     72    cam_pad_format_t padding;
     73    int num_planar;
     74 };
     75 
     76 typedef enum {
     77   CAMERA_STATE_UNINITED,
     78   CAMERA_STATE_READY,
     79   CAMERA_STATE_PREVIEW_START_CMD_SENT,
     80   CAMERA_STATE_PREVIEW_STOP_CMD_SENT,
     81   CAMERA_STATE_PREVIEW,
     82   CAMERA_STATE_RECORD_START_CMD_SENT,  /*5*/
     83   CAMERA_STATE_RECORD_STOP_CMD_SENT,
     84   CAMERA_STATE_RECORD,
     85   CAMERA_STATE_SNAP_START_CMD_SENT,
     86   CAMERA_STATE_SNAP_STOP_CMD_SENT,
     87   CAMERA_STATE_SNAP_CMD_ACKED,  /*10 - snapshot comd acked, snapshot not done yet*/
     88   CAMERA_STATE_ZSL_START_CMD_SENT,
     89   CAMERA_STATE_ZSL,
     90   CAMERA_STATE_AF_START_CMD_SENT,
     91   CAMERA_STATE_AF_STOP_CMD_SENT,
     92   CAMERA_STATE_ERROR, /*15*/
     93 
     94   /*Add any new state above*/
     95   CAMERA_STATE_MAX
     96 } HAL_camera_state_type_t;
     97 
     98 enum {
     99   BUFFER_NOT_OWNED,
    100   BUFFER_UNLOCKED,
    101   BUFFER_LOCKED,
    102 };
    103 
    104 typedef enum {
    105   HAL_DUMP_FRM_PREVIEW = 1,
    106   HAL_DUMP_FRM_VIDEO = 1<<1,
    107   HAL_DUMP_FRM_MAIN = 1<<2,
    108   HAL_DUMP_FRM_THUMBNAIL = 1<<3,
    109 
    110   /*8 bits mask*/
    111   HAL_DUMP_FRM_MAX = 1 << 8
    112 } HAL_cam_dump_frm_type_t;
    113 
    114 
    115 typedef enum {
    116   HAL_CAM_MODE_ZSL = 1,
    117 
    118   /*add new entry before and update the max entry*/
    119   HAL_CAM_MODE_MAX = HAL_CAM_MODE_ZSL << 1,
    120 } qQamera_mode_t;
    121 
    122 #define HAL_DUMP_FRM_MASK_ALL ( HAL_DUMP_FRM_PREVIEW + HAL_DUMP_FRM_VIDEO + \
    123     HAL_DUMP_FRM_MAIN + HAL_DUMP_FRM_THUMBNAIL)
    124 #define QCAMERA_HAL_PREVIEW_STOPPED    0
    125 #define QCAMERA_HAL_PREVIEW_START      1
    126 #define QCAMERA_HAL_PREVIEW_STARTED    2
    127 #define QCAMERA_HAL_RECORDING_STARTED  3
    128 #define QCAMERA_HAL_TAKE_PICTURE       4
    129 
    130 
    131 typedef struct {
    132      int                     buffer_count;
    133 	 buffer_handle_t        *buffer_handle[MM_CAMERA_MAX_NUM_FRAMES];
    134 	 struct private_handle_t *private_buffer_handle[MM_CAMERA_MAX_NUM_FRAMES];
    135 	 int                     stride[MM_CAMERA_MAX_NUM_FRAMES];
    136 	 uint32_t                addr_offset[MM_CAMERA_MAX_NUM_FRAMES];
    137 	 uint8_t                 local_flag[MM_CAMERA_MAX_NUM_FRAMES];
    138 	 camera_memory_t        *camera_memory[MM_CAMERA_MAX_NUM_FRAMES];
    139      int                     main_ion_fd[MM_CAMERA_MAX_NUM_FRAMES];
    140      struct ion_fd_data      ion_info_fd[MM_CAMERA_MAX_NUM_FRAMES];
    141 } QCameraHalMemory_t;
    142 
    143 
    144 typedef struct {
    145      int                     buffer_count;
    146      uint32_t                size;
    147      uint32_t                y_offset;
    148      uint32_t                cbcr_offset;
    149 	 int                     fd[MM_CAMERA_MAX_NUM_FRAMES];
    150 	 int                     local_flag[MM_CAMERA_MAX_NUM_FRAMES];
    151 	 camera_memory_t*        camera_memory[MM_CAMERA_MAX_NUM_FRAMES];
    152      camera_memory_t*        metadata_memory[MM_CAMERA_MAX_NUM_FRAMES];
    153      int main_ion_fd[MM_CAMERA_MAX_NUM_FRAMES];
    154      struct ion_allocation_data alloc[MM_CAMERA_MAX_NUM_FRAMES];
    155      struct ion_fd_data ion_info_fd[MM_CAMERA_MAX_NUM_FRAMES];
    156 } QCameraHalHeap_t;
    157 
    158 typedef struct {
    159      camera_memory_t*  camera_memory[3];
    160      int main_ion_fd[3];
    161      struct ion_allocation_data alloc[3];
    162      struct ion_fd_data ion_info_fd[3];
    163      int fd[3];
    164      int size;
    165 } QCameraStatHeap_t;
    166 
    167 typedef struct {
    168   int32_t msg_type;
    169   int32_t ext1;
    170   int32_t ext2;
    171   void    *cookie;
    172 } argm_notify_t;
    173 
    174 typedef struct {
    175   int32_t                  msg_type;
    176   camera_memory_t         *data;
    177   unsigned int             index;
    178   camera_frame_metadata_t *metadata;
    179   void                    *cookie;
    180 } argm_data_cb_t;
    181 
    182 typedef struct {
    183   camera_notify_callback notifyCb;
    184   camera_data_callback   dataCb;
    185   argm_notify_t argm_notify;
    186   argm_data_cb_t        argm_data_cb;
    187 } app_notify_cb_t;
    188 
    189 /* camera_area_t
    190  * rectangle with weight to store the focus and metering areas.
    191  * x1, y1, x2, y2: from -1000 to 1000
    192  * weight: 0 to 1000
    193  */
    194 typedef struct {
    195     int x1, y1, x2, y2;
    196     int weight;
    197 } camera_area_t;
    198 
    199 //EXIF globals
    200 static const char ExifAsciiPrefix[] = { 0x41, 0x53, 0x43, 0x49, 0x49, 0x0, 0x0, 0x0 };          // "ASCII\0\0\0"
    201 static const char ExifUndefinedPrefix[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };   // "\0\0\0\0\0\0\0\0"
    202 
    203 //EXIF detfines
    204 #define MAX_EXIF_TABLE_ENTRIES           23
    205 #define GPS_PROCESSING_METHOD_SIZE       101
    206 #define FOCAL_LENGTH_DECIMAL_PRECISION   100
    207 #define EXIF_ASCII_PREFIX_SIZE           8   //(sizeof(ExifAsciiPrefix))
    208 #define F_NUMBER_DECIMAL_PRECISION       100
    209 
    210 typedef struct{
    211     //GPS tags
    212     rat_t       latitude[3];
    213     rat_t       longitude[3];
    214     char        lonRef[2];
    215     char        latRef[2];
    216     rat_t       altitude;
    217     rat_t       gpsTimeStamp[3];
    218     char        gpsDateStamp[20];
    219     char        gpsProcessingMethod[EXIF_ASCII_PREFIX_SIZE+GPS_PROCESSING_METHOD_SIZE];
    220     //Other tags
    221     char        dateTime[20];
    222     char subsecTime[7];
    223     rat_t       focalLength;
    224     rat_t       f_number;
    225     uint16_t    flashMode;
    226     uint16_t    isoSpeed;
    227     rat_t       exposure_time;
    228 
    229     bool        mAltitude;
    230     bool        mLongitude;
    231     bool        mLatitude;
    232     bool        mTimeStamp;
    233     bool        mGpsProcess;
    234 
    235     int         mAltitude_ref;
    236     long        mGPSTimestamp;
    237     int         mWbMode;
    238     char        make[20];
    239     char        model[20];
    240 
    241 } exif_values_t;
    242 
    243 namespace android {
    244 
    245 class QCameraStream;
    246 
    247 class QCameraHardwareInterface : public virtual RefBase {
    248 public:
    249 
    250     QCameraHardwareInterface(int  cameraId, int mode);
    251 
    252     /** Set the ANativeWindow to which preview frames are sent */
    253     int setPreviewWindow(preview_stream_ops_t* window);
    254 
    255     /** Set the notification and data callbacks */
    256     void setCallbacks(camera_notify_callback notify_cb,
    257             camera_data_callback data_cb,
    258             camera_data_timestamp_callback data_cb_timestamp,
    259             camera_request_memory get_memory,
    260             void *user);
    261 
    262     /**
    263      * The following three functions all take a msg_type, which is a bitmask of
    264      * the messages defined in include/ui/Camera.h
    265      */
    266 
    267     /**
    268      * Enable a message, or set of messages.
    269      */
    270     void enableMsgType(int32_t msg_type);
    271 
    272     /**
    273      * Disable a message, or a set of messages.
    274      *
    275      * Once received a call to disableMsgType(CAMERA_MSG_VIDEO_FRAME), camera
    276      * HAL should not rely on its client to call releaseRecordingFrame() to
    277      * release video recording frames sent out by the cameral HAL before and
    278      * after the disableMsgType(CAMERA_MSG_VIDEO_FRAME) call. Camera HAL
    279      * clients must not modify/access any video recording frame after calling
    280      * disableMsgType(CAMERA_MSG_VIDEO_FRAME).
    281      */
    282     void disableMsgType(int32_t msg_type);
    283 
    284     /**
    285      * Query whether a message, or a set of messages, is enabled.  Note that
    286      * this is operates as an AND, if any of the messages queried are off, this
    287      * will return false.
    288      */
    289     int msgTypeEnabled(int32_t msg_type);
    290 
    291     /**
    292      * Start preview mode.
    293      */
    294     int startPreview();
    295     int startPreview2();
    296 
    297     /**
    298      * Stop a previously started preview.
    299      */
    300     void stopPreview();
    301 
    302     /**
    303      * Returns true if preview is enabled.
    304      */
    305     int previewEnabled();
    306 
    307 
    308     /**
    309      * Request the camera HAL to store meta data or real YUV data in the video
    310      * buffers sent out via CAMERA_MSG_VIDEO_FRAME for a recording session. If
    311      * it is not called, the default camera HAL behavior is to store real YUV
    312      * data in the video buffers.
    313      *
    314      * This method should be called before startRecording() in order to be
    315      * effective.
    316      *
    317      * If meta data is stored in the video buffers, it is up to the receiver of
    318      * the video buffers to interpret the contents and to find the actual frame
    319      * data with the help of the meta data in the buffer. How this is done is
    320      * outside of the scope of this method.
    321      *
    322      * Some camera HALs may not support storing meta data in the video buffers,
    323      * but all camera HALs should support storing real YUV data in the video
    324      * buffers. If the camera HAL does not support storing the meta data in the
    325      * video buffers when it is requested to do do, INVALID_OPERATION must be
    326      * returned. It is very useful for the camera HAL to pass meta data rather
    327      * than the actual frame data directly to the video encoder, since the
    328      * amount of the uncompressed frame data can be very large if video size is
    329      * large.
    330      *
    331      * @param enable if true to instruct the camera HAL to store
    332      *        meta data in the video buffers; false to instruct
    333      *        the camera HAL to store real YUV data in the video
    334      *        buffers.
    335      *
    336      * @return OK on success.
    337      */
    338     int storeMetaDataInBuffers(int enable);
    339 
    340     /**
    341      * Start record mode. When a record image is available, a
    342      * CAMERA_MSG_VIDEO_FRAME message is sent with the corresponding
    343      * frame. Every record frame must be released by a camera HAL client via
    344      * releaseRecordingFrame() before the client calls
    345      * disableMsgType(CAMERA_MSG_VIDEO_FRAME). After the client calls
    346      * disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's
    347      * responsibility to manage the life-cycle of the video recording frames,
    348      * and the client must not modify/access any video recording frames.
    349      */
    350     int startRecording();
    351 
    352     /**
    353      * Stop a previously started recording.
    354      */
    355     void stopRecording();
    356 
    357     /**
    358      * Returns true if recording is enabled.
    359      */
    360     int recordingEnabled();
    361 
    362     /**
    363      * Release a record frame previously returned by CAMERA_MSG_VIDEO_FRAME.
    364      *
    365      * It is camera HAL client's responsibility to release video recording
    366      * frames sent out by the camera HAL before the camera HAL receives a call
    367      * to disableMsgType(CAMERA_MSG_VIDEO_FRAME). After it receives the call to
    368      * disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's
    369      * responsibility to manage the life-cycle of the video recording frames.
    370      */
    371     void releaseRecordingFrame(const void *opaque);
    372 
    373     /**
    374      * Start auto focus, the notification callback routine is called with
    375      * CAMERA_MSG_FOCUS once when focusing is complete. autoFocus() will be
    376      * called again if another auto focus is needed.
    377      */
    378     int autoFocus();
    379 
    380     /**
    381      * Cancels auto-focus function. If the auto-focus is still in progress,
    382      * this function will cancel it. Whether the auto-focus is in progress or
    383      * not, this function will return the focus position to the default.  If
    384      * the camera does not support auto-focus, this is a no-op.
    385      */
    386     int cancelAutoFocus();
    387 
    388     /**
    389      * Take a picture.
    390      */
    391     int takePicture();
    392 
    393     /**
    394      * Cancel a picture that was started with takePicture. Calling this method
    395      * when no picture is being taken is a no-op.
    396      */
    397     int cancelPicture();
    398 
    399     /**
    400      * Set the camera parameters. This returns BAD_VALUE if any parameter is
    401      * invalid or not supported.
    402      */
    403     int setParameters(const char *parms);
    404 
    405     //status_t setParameters(const QCameraParameters& params);
    406     /** Retrieve the camera parameters.  The buffer returned by the camera HAL
    407         must be returned back to it with put_parameters, if put_parameters
    408         is not NULL.
    409      */
    410     int getParameters(char **parms);
    411 
    412     /** The camera HAL uses its own memory to pass us the parameters when we
    413         call get_parameters.  Use this function to return the memory back to
    414         the camera HAL, if put_parameters is not NULL.  If put_parameters
    415         is NULL, then you have to use free() to release the memory.
    416     */
    417     void putParameters(char *);
    418 
    419     /**
    420      * Send command to camera driver.
    421      */
    422     int sendCommand(int32_t cmd, int32_t arg1, int32_t arg2);
    423 
    424     /**
    425      * Release the hardware resources owned by this object.  Note that this is
    426      * *not* done in the destructor.
    427      */
    428     void release();
    429 
    430     /**
    431      * Dump state of the camera hardware
    432      */
    433     int dump(int fd);
    434 
    435     //virtual sp<IMemoryHeap> getPreviewHeap() const;
    436     //virtual sp<IMemoryHeap> getRawHeap() const;
    437 
    438 
    439     status_t    takeLiveSnapshot();
    440     status_t    takeFullSizeLiveshot();
    441     bool        canTakeFullSizeLiveshot();
    442 
    443     //virtual status_t          getBufferInfo( sp<IMemory>& Frame,
    444     //size_t *alignedSize);
    445     void         getPictureSize(int *picture_width, int *picture_height) const;
    446     void         getPreviewSize(int *preview_width, int *preview_height) const;
    447     cam_format_t getPreviewFormat() const;
    448 
    449     cam_pad_format_t getPreviewPadding() const;
    450 
    451     //bool     useOverlay(void);
    452     //virtual status_t setOverlay(const sp<Overlay> &overlay);
    453     void processEvent(mm_camera_event_t *);
    454     int  getJpegQuality() const;
    455     int  getNumOfSnapshots(void) const;
    456     int  getThumbSizesFromAspectRatio(uint32_t aspect_ratio,
    457                                      int *picture_width,
    458                                      int *picture_height);
    459     bool isRawSnapshot();
    460     bool mShutterSoundPlayed;
    461     void dumpFrameToFile(struct msm_frame*, HAL_cam_dump_frm_type_t);
    462 
    463     static QCameraHardwareInterface *createInstance(int, int);
    464     status_t setZSLBurstLookBack(const QCameraParameters& params);
    465     status_t setZSLBurstInterval(const QCameraParameters& params);
    466     int getZSLBurstInterval(void);
    467     int getZSLQueueDepth(void) const;
    468     int getZSLBackLookCount(void) const;
    469 
    470     ~QCameraHardwareInterface();
    471     int initHeapMem(QCameraHalHeap_t *heap, int num_of_buf, int pmem_type,
    472       int frame_len, int cbcr_off, int y_off, mm_cameara_stream_buf_t *StreamBuf,
    473       mm_camera_buf_def_t *buf_def, uint8_t num_planes, uint32_t *planes);
    474 
    475     int releaseHeapMem( QCameraHalHeap_t *heap);
    476     status_t sendMappingBuf(int ext_mode, int idx, int fd, uint32_t size,
    477       int cameraid, mm_camera_socket_msg_type msg_type);
    478     status_t sendUnMappingBuf(int ext_mode, int idx, int cameraid,
    479       mm_camera_socket_msg_type msg_type);
    480 
    481     int allocate_ion_memory(QCameraHalHeap_t *p_camera_memory, int cnt,
    482       int ion_type);
    483     int deallocate_ion_memory(QCameraHalHeap_t *p_camera_memory, int cnt);
    484 
    485     int allocate_ion_memory(QCameraStatHeap_t *p_camera_memory, int cnt,
    486       int ion_type);
    487     int deallocate_ion_memory(QCameraStatHeap_t *p_camera_memory, int cnt);
    488 
    489     int cache_ops(int ion_fd, struct ion_flush_data *cache_inv_data, int type);
    490 
    491     void dumpFrameToFile(const void * data, uint32_t size, char* name,
    492       char* ext, int index);
    493     preview_format_info_t getPreviewFormatInfo( );
    494     bool isCameraReady();
    495 
    496 private:
    497     int16_t  zoomRatios[MAX_ZOOM_RATIOS];
    498     struct camera_size_type default_preview_sizes[PREVIEW_TBL_MAX_SIZE];
    499     struct camera_size_type default_video_sizes[VIDEO_TBL_MAX_SIZE];
    500     struct camera_size_type default_hfr_sizes[HFR_TBL_MAX_SIZE];
    501     struct camera_size_type default_thumbnail_sizes[THUMB_TBL_MAX_SIZE];
    502     unsigned int preview_sizes_count;
    503     unsigned int video_sizes_count;
    504     unsigned int thumbnail_sizes_count;
    505     unsigned int hfr_sizes_count;
    506 
    507 
    508     bool mUseOverlay;
    509 
    510     void loadTables();
    511     void initDefaultParameters();
    512     bool getMaxPictureDimension(mm_camera_dimension_t *dim);
    513 
    514     status_t updateFocusDistances();
    515 
    516     bool native_set_parms(mm_camera_parm_type_t type, uint16_t length, void *value);
    517     bool native_set_parms( mm_camera_parm_type_t type, uint16_t length, void *value, int *result);
    518 
    519     void hasAutoFocusSupport();
    520     void debugShowPreviewFPS() const;
    521     //void prepareSnapshotAndWait();
    522 
    523     bool isPreviewRunning();
    524     bool isRecordingRunning();
    525     bool isSnapshotRunning();
    526 
    527     void processChannelEvent(mm_camera_ch_event_t *, app_notify_cb_t *);
    528     void processPreviewChannelEvent(mm_camera_ch_event_type_t channelEvent, app_notify_cb_t *);
    529     void processRecordChannelEvent(mm_camera_ch_event_type_t channelEvent, app_notify_cb_t *);
    530     void processSnapshotChannelEvent(mm_camera_ch_event_type_t channelEvent, app_notify_cb_t *);
    531     void processCtrlEvent(mm_camera_ctrl_event_t *, app_notify_cb_t *);
    532     void processStatsEvent(mm_camera_stats_event_t *, app_notify_cb_t *);
    533     void processInfoEvent(mm_camera_info_event_t *event, app_notify_cb_t *);
    534     void processprepareSnapshotEvent(cam_ctrl_status_t *);
    535     void roiEvent(fd_roi_t roi, app_notify_cb_t *);
    536     void zoomEvent(cam_ctrl_status_t *status, app_notify_cb_t *);
    537     void autofocusevent(cam_ctrl_status_t *status, app_notify_cb_t *);
    538     void handleZoomEventForPreview(app_notify_cb_t *);
    539     void handleZoomEventForSnapshot(void);
    540     status_t autoFocusEvent(cam_ctrl_status_t *, app_notify_cb_t *);
    541     status_t autoFocusMoveEvent(cam_ctrl_status_t *, app_notify_cb_t *);
    542 
    543     void filterPictureSizes();
    544     bool supportsSceneDetection();
    545     bool supportsSelectableZoneAf();
    546     bool supportsFaceDetection();
    547     bool supportsRedEyeReduction();
    548     bool preview_parm_config (cam_ctrl_dimension_t* dim,QCameraParameters& parm);
    549 
    550     void stopPreviewInternal();
    551     void stopRecordingInternal();
    552     //void stopPreviewZSL();
    553     status_t cancelPictureInternal();
    554     //status_t startPreviewZSL();
    555     void pausePreviewForSnapshot();
    556     void pausePreviewForZSL();
    557     void pausePreviewForVideo();
    558     void prepareVideoPicture(bool disable);
    559     status_t resumePreviewAfterSnapshot();
    560 
    561     status_t runFaceDetection();
    562 
    563     status_t           setParameters(const QCameraParameters& params);
    564     QCameraParameters&  getParameters() ;
    565 
    566     bool getFlashCondition(void);
    567 
    568     status_t setCameraMode(const QCameraParameters& params);
    569     status_t setPictureSizeTable(void);
    570     status_t setPreviewSizeTable(void);
    571     status_t setVideoSizeTable(void);
    572     status_t setPreviewSize(const QCameraParameters& params);
    573     status_t setJpegThumbnailSize(const QCameraParameters& params);
    574     status_t setPreviewFpsRange(const QCameraParameters& params);
    575     status_t setPreviewFrameRate(const QCameraParameters& params);
    576     status_t setPreviewFrameRateMode(const QCameraParameters& params);
    577     status_t setVideoSize(const QCameraParameters& params);
    578     status_t setPictureSize(const QCameraParameters& params);
    579     status_t setJpegQuality(const QCameraParameters& params);
    580     status_t setNumOfSnapshot();
    581     status_t setJpegRotation(int isZSL);
    582     int getJpegRotation(void);
    583     int getISOSpeedValue();
    584     status_t setAntibanding(const QCameraParameters& params);
    585     status_t setEffect(const QCameraParameters& params);
    586     status_t setExposureCompensation(const QCameraParameters &params);
    587     status_t setAutoExposure(const QCameraParameters& params);
    588     status_t setWhiteBalance(const QCameraParameters& params);
    589     status_t setFlash(const QCameraParameters& params);
    590     status_t setGpsLocation(const QCameraParameters& params);
    591     status_t setRotation(const QCameraParameters& params);
    592     status_t setZoom(const QCameraParameters& params);
    593     status_t setFocusMode(const QCameraParameters& params);
    594     status_t setBrightness(const QCameraParameters& params);
    595     status_t setSkinToneEnhancement(const QCameraParameters& params);
    596     status_t setOrientation(const QCameraParameters& params);
    597     status_t setLensshadeValue(const QCameraParameters& params);
    598     status_t setMCEValue(const QCameraParameters& params);
    599     status_t setISOValue(const QCameraParameters& params);
    600     status_t setPictureFormat(const QCameraParameters& params);
    601     status_t setSharpness(const QCameraParameters& params);
    602     status_t setContrast(const QCameraParameters& params);
    603     status_t setSaturation(const QCameraParameters& params);
    604     status_t setWaveletDenoise(const QCameraParameters& params);
    605     status_t setSceneMode(const QCameraParameters& params);
    606     status_t setContinuousAf(const QCameraParameters& params);
    607     status_t setFaceDetection(const char *str);
    608     status_t setSceneDetect(const QCameraParameters& params);
    609     status_t setStrTextures(const QCameraParameters& params);
    610     status_t setPreviewFormat(const QCameraParameters& params);
    611     status_t setSelectableZoneAf(const QCameraParameters& params);
    612     status_t setOverlayFormats(const QCameraParameters& params);
    613     status_t setHighFrameRate(const QCameraParameters& params);
    614     status_t setRedeyeReduction(const QCameraParameters& params);
    615     status_t setAEBracket(const QCameraParameters& params);
    616     status_t setFaceDetect(const QCameraParameters& params);
    617     status_t setDenoise(const QCameraParameters& params);
    618     status_t setAecAwbLock(const QCameraParameters & params);
    619     status_t setHistogram(int histogram_en);
    620     status_t setRecordingHint(const QCameraParameters& params);
    621     status_t setRecordingHintValue(const int32_t value);
    622     status_t setFocusAreas(const QCameraParameters& params);
    623     status_t setMeteringAreas(const QCameraParameters& params);
    624     status_t setFullLiveshot(void);
    625     status_t setDISMode(void);
    626     status_t setCaptureBurstExp(void);
    627     status_t setPowerMode(const QCameraParameters& params);
    628     void takePicturePrepareHardware( );
    629     status_t setNoDisplayMode(const QCameraParameters& params);
    630     status_t setCAFLockCancel(void);
    631 
    632     isp3a_af_mode_t getAutoFocusMode(const QCameraParameters& params);
    633     bool isValidDimension(int w, int h);
    634 
    635     String8 create_values_str(const str_map *values, int len);
    636 
    637     void setMyMode(int mode);
    638     bool isZSLMode();
    639     bool isWDenoiseEnabled();
    640     void wdenoiseEvent(cam_ctrl_status_t status, void *cookie);
    641     bool isLowPowerCamcorder();
    642     void freePictureTable(void);
    643     void freeVideoSizeTable(void);
    644 
    645     int32_t createPreview();
    646     int32_t createRecord();
    647     int32_t createSnapshot();
    648 
    649     int getHDRMode();
    650     //EXIF
    651     void addExifTag(exif_tag_id_t tagid, exif_tag_type_t type,
    652                         uint32_t count, uint8_t copy, void *data);
    653     void setExifTags();
    654     void initExifData();
    655     void deinitExifData();
    656     void setExifTagsGPS();
    657     exif_tags_info_t* getExifData(){ return mExifData; }
    658     int getExifTableNumEntries() { return mExifTableNumEntries; }
    659     void parseGPSCoordinate(const char *latlonString, rat_t* coord);
    660     bool getHdrInfoAndSetExp( int max_num_frm, int *num_frame, int *exp);
    661     void hdrEvent(cam_ctrl_status_t status, void *cookie);
    662 
    663     int           mCameraId;
    664     camera_mode_t myMode;
    665     bool mPauseFramedispatch;
    666 
    667     QCameraParameters    mParameters;
    668     //sp<Overlay>         mOverlay;
    669     int32_t             mMsgEnabled;
    670 
    671     camera_notify_callback         mNotifyCb;
    672     camera_data_callback           mDataCb;
    673     camera_data_timestamp_callback mDataCbTimestamp;
    674     camera_request_memory          mGetMemory;
    675     void                           *mCallbackCookie;
    676 
    677     sp<AshmemPool>      mMetaDataHeap;
    678 
    679     mutable Mutex       mLock;
    680     //mutable Mutex       eventLock;
    681     Mutex         mCallbackLock;
    682     Mutex         mPreviewMemoryLock;
    683     Mutex         mRecordingMemoryLock;
    684     Mutex         mAutofocusLock;
    685     Mutex         mMetaDataWaitLock;
    686     Mutex         mRecordFrameLock;
    687     Mutex         mRecordLock;
    688     Condition     mRecordWait;
    689     pthread_mutex_t     mAsyncCmdMutex;
    690     pthread_cond_t      mAsyncCmdWait;
    691 
    692     QCameraStream       *mStreamDisplay;
    693     QCameraStream       *mStreamRecord;
    694     QCameraStream       *mStreamSnap;
    695     QCameraStream       *mStreamLiveSnap;
    696 
    697     cam_ctrl_dimension_t mDimension;
    698     int  mPreviewWidth, mPreviewHeight;
    699     int  mVideoWidth, mVideoHeight;
    700     int  thumbnailWidth, thumbnailHeight;
    701     int  maxSnapshotWidth, maxSnapshotHeight;
    702     int  mPreviewFormat;
    703     int  mFps;
    704     int  mDebugFps;
    705     int  mBrightness;
    706     int  mContrast;
    707     int  mBestShotMode;
    708     int  mEffects;
    709     int  mSkinToneEnhancement;
    710     int  mDenoiseValue;
    711     int  mHJR;
    712     int  mRotation;
    713     int  mJpegQuality;
    714     int  mThumbnailQuality;
    715     int  mTargetSmoothZoom;
    716     int  mSmoothZoomStep;
    717     int  mMaxZoom;
    718     int  mCurrentZoom;
    719     int  mSupportedPictureSizesCount;
    720     int  mFaceDetectOn;
    721     int  mDumpFrmCnt;
    722     int  mDumpSkipCnt;
    723     int  mFocusMode;
    724 
    725     unsigned int mPictureSizeCount;
    726     unsigned int mPreviewSizeCount;
    727     int mPowerMode;
    728     unsigned int mVideoSizeCount;
    729 
    730     bool mAutoFocusRunning;
    731     bool mNeedToUnlockCaf;
    732     bool mMultiTouch;
    733     bool mHasAutoFocusSupport;
    734     bool mInitialized;
    735     bool mDisEnabled;
    736     bool strTexturesOn;
    737     bool mIs3DModeOn;
    738     bool mSmoothZoomRunning;
    739     bool mPreparingSnapshot;
    740     bool mParamStringInitialized;
    741     bool mZoomSupported;
    742     bool mSendMetaData;
    743     bool mFullLiveshotEnabled;
    744     bool mRecordingHint;
    745     bool mAppRecordingHint;
    746     bool mStartRecording;
    747     bool mReleasedRecordingFrame;
    748     bool mStateLiveshot;
    749     int mHdrMode;
    750     int mSnapshotFormat;
    751     int mZslInterval;
    752     bool mRestartPreview;
    753     bool isCameraOpen;
    754 
    755     led_mode_t mLedStatusForZsl;
    756     bool mFlashCond;
    757 
    758 /*for histogram*/
    759     int            mStatsOn;
    760     int            mCurrentHisto;
    761     bool           mSendData;
    762     sp<AshmemPool> mStatHeap;
    763     camera_memory_t *mStatsMapped[3];
    764     QCameraStatHeap_t mHistServer;
    765     int32_t        mStatSize;
    766 
    767     bool mZslLookBackMode;
    768     int mZslLookBackValue;
    769 	int mHFRLevel;
    770     bool mZslEmptyQueueFlag;
    771     String8 mEffectValues;
    772     String8 mIsoValues;
    773     String8 mSceneModeValues;
    774     String8 mSceneDetectValues;
    775     String8 mFocusModeValues;
    776     String8 mSelectableZoneAfValues;
    777     String8 mAutoExposureValues;
    778     String8 mWhitebalanceValues;
    779     String8 mAntibandingValues;
    780     String8 mFrameRateModeValues;
    781     String8 mTouchAfAecValues;
    782     String8 mPreviewSizeValues;
    783     String8 mPictureSizeValues;
    784     String8 mVideoSizeValues;
    785     String8 mFlashValues;
    786     String8 mLensShadeValues;
    787     String8 mMceValues;
    788     String8 mHistogramValues;
    789     String8 mSkinToneEnhancementValues;
    790     String8 mPictureFormatValues;
    791     String8 mDenoiseValues;
    792     String8 mZoomRatioValues;
    793     String8 mPreviewFrameRateValues;
    794     String8 mPreviewFormatValues;
    795     String8 mFaceDetectionValues;
    796     String8 mHfrValues;
    797     String8 mHfrSizeValues;
    798     String8 mRedeyeReductionValues;
    799     String8 denoise_value;
    800     String8 mFpsRangesSupportedValues;
    801     String8 mZslValues;
    802     String8 mFocusDistance;
    803 
    804     friend class QCameraStream;
    805     friend class QCameraStream_record;
    806     friend class QCameraStream_preview;
    807     friend class QCameraStream_Snapshot;
    808 
    809     camera_size_type* mPictureSizes;
    810     camera_size_type* mPreviewSizes;
    811     camera_size_type* mVideoSizes;
    812     const camera_size_type * mPictureSizesPtr;
    813     HAL_camera_state_type_t mCameraState;
    814     void *libdnr;
    815     int (*LINK_morpho_DNR_ProcessFrame)(unsigned char* yuvImage, int width, int height, int y_level, int c_level);
    816 
    817      /* Temporary - can be removed after Honeycomb*/
    818 #ifdef USE_ION
    819     sp<IonPool>  mPostPreviewHeap;
    820 #else
    821     sp<PmemPool> mPostPreviewHeap;
    822 #endif
    823      mm_cameara_stream_buf_t mPrevForPostviewBuf;
    824      int mStoreMetaDataInFrame;
    825      preview_stream_ops_t *mPreviewWindow;
    826      Mutex                mStateLock;
    827      int                  mPreviewState;
    828      /*preview memory with display case: memory is allocated and freed via
    829      gralloc */
    830      QCameraHalMemory_t   mPreviewMemory;
    831 
    832      /*preview memory without display case: memory is allocated
    833       directly by camera */
    834      QCameraHalHeap_t     mNoDispPreviewMemory;
    835 
    836      QCameraHalHeap_t     mSnapshotMemory;
    837      QCameraHalHeap_t     mThumbnailMemory;
    838      QCameraHalHeap_t     mRecordingMemory;
    839      QCameraHalHeap_t     mJpegMemory;
    840      QCameraHalHeap_t     mRawMemory;
    841      camera_frame_metadata_t mMetadata;
    842      camera_face_t           mFace[MAX_ROI];
    843      preview_format_info_t  mPreviewFormatInfo;
    844      friend void liveshot_callback(mm_camera_ch_data_buf_t *frame,void *user_data);
    845 
    846      //EXIF
    847      exif_tags_info_t       mExifData[MAX_EXIF_TABLE_ENTRIES];  //Exif tags for JPEG encoder
    848      exif_values_t          mExifValues;                        //Exif values in usable format
    849      int                    mExifTableNumEntries;            //NUmber of entries in mExifData
    850      int                 mNoDisplayMode;
    851      int                 mIsoValue;
    852 
    853      /* Used to show the process state of snapshot_jpeg_cb*/
    854      Mutex                  mSnapJpegCbLock;
    855      Condition              mSnapJpegCbWait;
    856      bool                   mSnapJpegCbRunning;
    857      bool                   mSnapCbDisabled;
    858 };
    859 
    860 }; // namespace android
    861 
    862 #endif
    863