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